/** * Registers an XML namespace with this node list. Once registered, you can * refer to the registered namespace using its prefix in the * {@link #get(String)} method from this node list and all other * node lists that are derived from this node list. Use the * <tt>nodelist["prefix:localname"]</tt> or the * <tt>nodelist["@prefix:localname"]</tt> syntax to reach elements and * attributes whose names are namespace-scoped. Note that the namespace * prefix need not match the actual prefix used by the XML document itself * since namespaces are compared solely by their URI. You can also register * namespaces during template evaluation using the * <tt>nodelist._registerNamespace(prefix, uri)</tt> syntax in the template. * This mechanism is completely independent from the namespace declarations * in the XML document itself; its purpose is to give you an easy way * to refer to namespace-scoped elements in {@link #get(String)} and * in XPath expressions passed to {@link #exec(List)}. Note also that * the namespace prefix registry is shared among all node lists that * are created from a single node list - modifying the registry in one * affects all others as well. If you want to obtain a namespace * "detached" copy of the node list, use the <code>_copy</code> key on * it (or call <code>nodeList.get("_copy")</code> directly from your * Java code. The returned node list has all the namespaces that the * original node list has, but they can be manipulated independently * thereon. */ public void registerNamespace(String prefix, String uri) { synchronized (namespaces) { namespaces.put(prefix, Namespace.getNamespace(prefix, uri)); } }
@Override void getChildren(Object node, String localName, String namespaceUri, List result) { if (node instanceof Element) { Element e = (Element) node; if (localName == null) { result.addAll(e.getChildren()); } else { result.addAll(e.getChildren(localName, Namespace.getNamespace("", namespaceUri))); } } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (localName == null || (equal(root.getName(), localName) && equal(root.getNamespaceURI(), namespaceUri))) { result.add(root); } } }
return node.getChildren(localName).iterator(); return node.getChildren(localName, Namespace.getNamespace(namespacePrefix, namespaceURI)).iterator(); if (!Namespace.getNamespace(namespacePrefix, namespaceURI).equals(el.getNamespace())) { return JaxenConstants.EMPTY_ITERATOR;
/** * Retrieves an <code>Iterator</code> over the attribute elements that * match the supplied name. * * @param contextNode the origin context node * @param localName the local name of the attributes to return, always present * @param namespacePrefix the prefix of the namespace of the attributes to return * @param namespaceURI the URI of the namespace of the attributes to return * @return an Iterator that traverses the named attributes, not null */ public Iterator getAttributeAxisIterator( Object contextNode, String localName, String namespacePrefix, String namespaceURI) { if ( contextNode instanceof Element ) { Element node = (Element) contextNode; Namespace namespace = (namespaceURI == null ? Namespace.NO_NAMESPACE : Namespace.getNamespace(namespacePrefix, namespaceURI)); Attribute attr = node.getAttribute(localName, namespace); if (attr != null) { return new SingleObjectIterator(attr); } } return JaxenConstants.EMPTY_ITERATOR; }
result.addAll(e.getAttributes()); } else { Attribute attr = e.getAttribute(localName, Namespace.getNamespace("", namespaceUri)); if (attr != null) { result.add(attr);
/** * Returns the namespace used by RSS elements in document of the RSS 1.0 * <P> * * @return returns "http://purl.org/rss/1.0/". */ protected Namespace getRSSNamespace() { return Namespace.getNamespace(RSS_URI); }
@Override protected Namespace getSectionNamespace(){ return Namespace.getNamespace("uri:oozie:hive-action:0.5"); } }
@Override protected Namespace getSectionNamespace(){ return Namespace.getNamespace("uri:oozie:hive-action:0.5"); } }
/** * Returns the namespace used by RSS elements in document of the RSS 1.0 * <P> * * @return returns "http://purl.org/rss/1.0/". */ protected Namespace getRSSNamespace() { return Namespace.getNamespace(RSS_URI); }
/** * Returns the namespace used by RSS elements in document of the RSS 1.0 * <P> * * @return returns "http://purl.org/rss/1.0/". */ protected Namespace getRSSNamespace() { return Namespace.getNamespace(RSS_URI); }
public static Element getSLAElement(Element elem) { Element eSla_1 = elem.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI)); Element eSla_2 = elem.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAMESPACE_URI_2)); return (eSla_2 != null) ? eSla_2 : eSla_1; }
private Element getElement(Element element, String child) { if (element != null) { return element.getChild(child, Namespace.getNamespace(NAMESPACE)); } return null; }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); Object prefix = in.readObject(); Object uri = in.readObject(); if (prefix != null) { // else leave namespace null here namespace = Namespace.getNamespace((String) prefix, (String) uri); } } }
protected void removeImports(Element schema) { List children = schema.getChildren("import", Namespace.getNamespace(SoapConstants.XSD)); for (Iterator sitr = children.iterator(); sitr.hasNext();) { sitr.next(); sitr.remove(); } }
/** * Constructs a new <code>DDSXMLParser</code>. * The OPeNDAP namespace is defined during the construction * of an instance of this class. */ public DDSXMLParser(String nameSpace) { super(); opendapNameSpace = Namespace.getNamespace(nameSpace); lastDoc = null; _Debug = Debug.isSet("DDSXMLParser"); }
public void writeDefaultNamespace(String namespace) throws XMLStreamException { currentNode.addNamespaceDeclaration(Namespace.getNamespace("", namespace)); }
private String getValue(Element element, String child) { if (element != null) { Element childElement = element.getChild(child, Namespace.getNamespace(NAMESPACE)); if (childElement != null) { return childElement.getValue(); } } return null; }
public void writeAttribute(String prefix, String namespace, String local, String value) throws XMLStreamException { currentNode.setAttribute(new Attribute(local, value, Namespace.getNamespace(prefix, namespace))); }
public void writeNamespace(String prefix, String namespace) throws XMLStreamException { Namespace decNS = currentNode.getNamespace(prefix); if (decNS == null || !decNS.getURI().equals(namespace)) { currentNode.addNamespaceDeclaration(Namespace.getNamespace(prefix, namespace)); } }
public void writeNamespace(String prefix, String namespace) throws XMLStreamException { Namespace decNS = currentNode.getNamespace(prefix); if (decNS == null || !decNS.getURI().equals(namespace)) { currentNode.addNamespaceDeclaration(Namespace.getNamespace(prefix, namespace)); } }