本文整理了Java中org.jdom2.Attribute.getNamespace()
方法的一些代码示例,展示了Attribute.getNamespace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute.getNamespace()
方法的具体详情如下:
包路径:org.jdom2.Attribute
类名称:Attribute
方法名:getNamespace
[英]This will return this Attribute
's Namespace
.
[中]这将返回此Attribute
的Namespace
。
代码示例来源:origin: simpligility/android-maven-plugin
@SuppressWarnings( "unchecked" )
private void appendElement( Element source, Element target )
{
for ( Iterator<Attribute> itr = source.getAttributes().iterator(); itr.hasNext(); )
{
Attribute a = itr.next();
itr.remove();
Attribute mergedAtt = target.getAttribute( a.getName(), a.getNamespace() );
if ( mergedAtt == null )
{
target.setAttribute( a );
}
}
for ( Iterator<Element> itr = source.getChildren().iterator(); itr.hasNext(); )
{
Content n = itr.next();
itr.remove();
target.addContent( n );
}
}
代码示例来源:origin: org.jdom/jdom
for (final Attribute a : attributes) {
if (prefix.equals(a.getNamespacePrefix())) {
return a.getNamespace();
代码示例来源:origin: org.jdom/jdom
if (att.getNamespace() == Namespace.NO_NAMESPACE) {
buffer.append("@").append(att.getName());
} else {
代码示例来源:origin: org.jdom/jdom
@Override
public List<Namespace> getNamespacesIntroduced() {
if (getParent() == null) {
return Collections.singletonList(getNamespace());
}
return Collections.emptyList();
}
代码示例来源:origin: org.jdom/jdom
/**
* Check if a <code>{@link Namespace}</code> collides with a
* <code>{@link Attribute}</code>'s namespace.
*
* @param namespace <code>Namespace</code> to check.
* @param attribute <code>Attribute</code> to check against.
* @return <code>String</code> reason for collision, or
* <code>null</code> if no collision.
*/
public static String checkNamespaceCollision(final Namespace namespace,
final Attribute attribute) {
String reason = null;
if (!attribute.getNamespace().equals(Namespace.NO_NAMESPACE)) {
reason = checkNamespaceCollision(namespace,
attribute.getNamespace());
if (reason != null) {
reason += " with an attribute namespace prefix on the element";
}
}
return reason;
}
代码示例来源:origin: org.jdom/jdom
/**
* Create a new in-scope level for the Stack based on an Attribute.
*
* @param att The attribute to contribute to the namespace scope.
*/
public void push(Attribute att) {
final List<Namespace> toadd = new ArrayList<Namespace>(1);
final Namespace mns = att.getNamespace();
// check to see whether the Namespace is new-to-scope.
Namespace[] newscope = checkNamespace(toadd, mns, scope[depth]);
pushStack(mns, newscope, toadd);
}
代码示例来源:origin: org.jdom/jdom
/**
* Return index of attribute with same name and Namespace, or -1 if one
* doesn't exist
*/
private int indexOfDuplicate(final Attribute attribute) {
return indexOf(attribute.getName(), attribute.getNamespace());
}
代码示例来源:origin: org.jdom/jdom
/**
* Check if <code>{@link Attribute}</code>'s namespace collides with a
* <code>{@link Element}</code>'s namespace.
*
* @param attribute <code>Attribute</code> to check.
* @param element <code>Element</code> to check against.
* @return <code>String</code> reason for collision, or
* <code>null</code> if no collision.
*/
public static String checkNamespaceCollision(final Attribute attribute,
final Element element) {
final Namespace namespace = attribute.getNamespace();
final String prefix = namespace.getPrefix();
if ("".equals(prefix)) {
return null;
}
return checkNamespaceCollision(namespace, element);
}
代码示例来源:origin: org.jdom/jdom
/**
* Check to see if the Content matches a predefined set of rules.
*
* @param content The Content to verify.
* @return <code>true</code> if the objected matched a predfined
* set of rules.
*/
@Override
public Attribute filter(Object content) {
if (content instanceof Attribute) {
Attribute att = (Attribute) content;
if (name == null) {
if (namespace == null) {
return att;
}
return namespace.equals(att.getNamespace()) ? att : null;
}
if (!name.equals(att.getName())) {
return null;
}
if (namespace == null) {
return att;
}
return namespace.equals(att.getNamespace()) ? att : null;
}
return null;
}
代码示例来源:origin: org.jdom/jdom
if (getParent() == null) {
ArrayList<Namespace> ret = new ArrayList<Namespace>(3);
ret.add(getNamespace());
ret.add(Namespace.XML_NAMESPACE);
return Collections.unmodifiableList(ret);
return orderFirst(getNamespace(), getParent().getNamespacesInScope());
代码示例来源:origin: org.jdom/jdom
@Override
public List<Namespace> getNamespacesInherited() {
if (getParent() == null) {
return Collections.singletonList(Namespace.XML_NAMESPACE);
}
return orderFirst(getNamespace(), getParent().getNamespacesInScope());
}
代码示例来源:origin: org.jdom/jdom
Namespace ns = att.getNamespace();
if (!namespaces.containsKey(ns.getPrefix())) {
namespaces.put(ns.getPrefix(), ns);
代码示例来源:origin: org.jdom/jdom
@Override
public javax.xml.stream.events.Attribute next() {
final Attribute att = source.next();
final Namespace ns = att.getNamespace();
if (ns == Namespace.NO_NAMESPACE) {
return fac.createAttribute(att.getName(), att.getValue());
}
return fac.createAttribute(ns.getPrefix(), ns.getURI(),
att.getName(), att.getValue());
}
代码示例来源:origin: org.jdom/jdom
/**
* This will handle printing of an <code>{@link Attribute}</code>.
*
* @param out
* <code>XMLStreamWriter</code> to use.
* @param fstack
* The current FormatStack
* @param attribute
* <code>Attribute</code> to output
* @throws XMLStreamException
* if the output fails
*/
protected void printAttribute(final XMLStreamWriter out, final FormatStack fstack,
final Attribute attribute) throws XMLStreamException {
if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) {
return;
}
final Namespace ns = attribute.getNamespace();
if (ns == Namespace.NO_NAMESPACE) {
out.writeAttribute(attribute.getName(), attribute.getValue());
} else {
out.writeAttribute(ns.getPrefix(), ns.getURI(),
attribute.getName(), attribute.getValue());
}
}
代码示例来源:origin: org.jdom/jdom
final Namespace ns = a.getNamespace();
if (ns == Namespace.NO_NAMESPACE) {
代码示例来源:origin: org.codehaus.izpack/izpack-util
/**
* Filters an element's attributes.
*
* @param element An element whose attributes will be filtered
* @return The input element whose attributes have been filtered
*/
private Element filterAttributes(Element element)
{
Element result = (Element) element.clone();
List<Attribute> attributes = result.getAttributes();
Iterator<Attribute> it = attributes.iterator();
while (it.hasNext())
{
Attribute attr = it.next();
if (attr.getNamespace().equals(m_namespace))
{
it.remove();
}
}
return result;
}
代码示例来源:origin: org.mycore/mycore-xeditor
public void undo(MCRChangeData data) {
Attribute attribute = data.getAttribute();
data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace());
}
}
代码示例来源:origin: org.mycore/mycore-mods
/**
* Copies those attributes from the other's element into this' element that do not exist in this' element.
*/
protected void mergeAttributes(MCRMerger other) {
for (Attribute attribute : other.element.getAttributes()) {
if (this.element.getAttribute(attribute.getName(), attribute.getNamespace()) == null) {
this.element.setAttribute(attribute.clone());
}
}
}
代码示例来源:origin: org.mycore/mycore-xeditor
public void undo(MCRChangeData data) {
Attribute attribute = data.getAttribute();
data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace());
data.getContext().setAttribute(attribute);
}
}
代码示例来源:origin: usethesource/rascal
private IConstructor convertElement(Element e, boolean trim) {
IListWriter kids = vf.listWriter(Factory.Node);
for (Object o: e.getAttributes()) {
Attribute attr = (Attribute)o;
IString key = vf.string(attr.getName());
IString val = vf.string(attr.getValue());
kids.insert(vf.constructor(Factory.Node_attribute, convertNamespace(attr.getNamespace()), key, val));
}
int len = e.getContentSize();
for (int i = 0; i < len; i++) {
try {
kids.append(convertContent(e.getContent(i), trim));
}
catch (Skip c) { // Ugh, terrible, but I'm in hurry
continue;
}
}
IString name = vf.string(e.getName());
return vf.constructor(Factory.Node_element, convertNamespace(e.getNamespace()), name, kids.done());
}
内容来源于网络,如有侵权,请联系作者删除!