private void addNamespaces(Node element) { if (element.getParentNode() != null) { addNamespaces(element.getParentNode()); } if (element instanceof Element) { Element el = (Element)element; NamedNodeMap map = el.getAttributes(); for (int x = 0; x < map.getLength(); x++) { Attr attr = (Attr)map.item(x); if ("xmlns".equals(attr.getPrefix())) { namespaceMap.put(attr.getLocalName(), attr.getValue()); } } } } }
/** * Loads the given attribute in the current sequence. * * @param attr The W3C DOM attribute node to load. */ private void load(Attr attr) { handlePrefixMapping(attr.getNamespaceURI(), attr.getPrefix()); load(this.efactory.makeAttribute(attr.getNamespaceURI(), attr.getLocalName(), attr.getNodeName(), attr.getValue())); }
protected Attribute attribute(org.w3c.dom.Attr attr) { return attribute(DOCUMENT_FACTORY.createQName(attr.getLocalName(), attr .getPrefix(), attr.getNamespaceURI())); }
public QName getAttributeName(int i) { Attr at = getAttribute(i); String prefix = at.getPrefix(); String ln = getLocalName(at); // at.getNodeName(); String ns = at.getNamespaceURI(); if (prefix == null) { return new QName(ns, ln); } return new QName(ns, ln, prefix); }
static String getNSDeclPrefix(Attr attr) { String prefix = attr.getPrefix(); return prefix == null ? null : attr.getLocalName(); } }
protected Map defineNamespaces(Element element, Map namespaces) { Map answer = null; String prefix = element.getPrefix(); if (prefix != null && prefix.length() > 0 && !namespaces.containsKey(prefix)) { answer = new HashMap(namespaces); defineNamespace(answer, prefix, element.getNamespaceURI()); } NamedNodeMap attributes = element.getAttributes(); int length = attributes.getLength(); for (int i = 0; i < length; i++) { Attr attribute = (Attr) attributes.item(i); prefix = attribute.getPrefix(); if (prefix != null && prefix.length() > 0 && !namespaces.containsKey(prefix)) { if (answer == null) { answer = new HashMap(namespaces); } defineNamespace(answer, prefix, attribute.getNamespaceURI()); } } return (answer != null) ? answer : namespaces; }
protected Attribute createAttribute(org.w3c.dom.Attr newAttr) { QName qname = null; String name = newAttr.getLocalName(); if (name != null) { String prefix = newAttr.getPrefix(); String uri = newAttr.getNamespaceURI(); qname = getDocumentFactory().createQName(name, prefix, uri); } else { name = newAttr.getName(); qname = getDocumentFactory().createQName(name); } return new DOMAttribute(qname, newAttr.getValue()); }
/** * Retrieves the name of the node * * @return Name of the node */ public QName node_name() { QName name = new QName(_value.getPrefix(), _value.getLocalName(), _value.getNamespaceURI()); return name; }
public QName getAttributeName(int i) { Attr at = getAttribute(i); String prefix = at.getPrefix(); String ln = getLocalName(at); // at.getNodeName(); String ns = at.getNamespaceURI(); if (prefix == null) { return new QName(ns, ln); } return new QName(ns, ln, prefix); }
/** * Recursively visit ancestors and build up {@link NamespaceSupport} oject. */ private void buildNamespaceSupport(NamespaceSupport nss, Node node) { if(node==null || node.getNodeType()!=Node.ELEMENT_NODE) return; buildNamespaceSupport( nss, node.getParentNode() ); nss.pushContext(); NamedNodeMap atts = node.getAttributes(); for( int i=0; i<atts.getLength(); i++ ) { Attr a = (Attr)atts.item(i); if( "xmlns".equals(a.getPrefix()) ) { nss.declarePrefix( a.getLocalName(), a.getValue() ); continue; } if( "xmlns".equals(a.getName()) ) { nss.declarePrefix( "", a.getValue() ); continue; } } }
private void parseDescriptionRootAttr(XMPMetadata xmp, Element description, Attr attr, TypeMapping tm) throws XmpSchemaException, XmpParsingException String namespace = attr.getNamespaceURI(); XMPSchema schema = xmp.getSchema(namespace); if (schema == null && tm.getSchemaFactory(namespace) != null) schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, attr.getPrefix()); loadAttributes(schema, description); new QName(attr.getNamespaceURI(), attr.getLocalName())); attr.getLocalName(), attr.getValue(), type.type()); container.addProperty(sp); e.getMessage() + " in " + schema.getPrefix() + ":" + attr.getLocalName(), e);
protected void runTest() throws Throwable { String attrName = "attrIdentifier"; Document doc = dbf.newDocumentBuilder().newDocument(); Attr attr = doc.createAttribute(attrName); assertThat(attr.getNodeName()).isEqualTo(attrName); assertThat(attr.getName()).isEqualTo(attrName); assertThat(attr.getPrefix()).isNull(); assertThat(attr.getLocalName()).isNull(); assertThat(attr.getNamespaceURI()).isNull(); } }
public QName getAttributeName(int i) { Attr at = getAttribute(i); String prefix = at.getPrefix(); String ln = getLocalName(at); // at.getNodeName(); String ns = at.getNamespaceURI(); if (prefix == null) { return new QName(ns, ln); } else { return new QName(ns, ln, prefix); } }
public void serializeURIs(Object element, XMLSerializer target) { NamedNodeMap al = ((Element)element).getAttributes(); int len = al.getLength(); NamespaceContext2 context = target.getNamespaceContext(); for( int i=0; i<len; i++ ) { Attr a = (Attr)al.item(i); if ("xmlns".equals(a.getPrefix())) { context.force(a.getValue(), a.getLocalName()); continue; } if ("xmlns".equals(a.getName())) { if (element instanceof org.w3c.dom.Element) { context.declareNamespace(a.getValue(), null, false); continue; } else { context.force(a.getValue(), ""); continue; } } String nsUri = a.getNamespaceURI(); if(nsUri!=null && nsUri.length()>0) context.declareNamespace( nsUri, a.getPrefix(), true ); } }
/** * Loads the given attribute in the current sequence. * * @param attr The W3C DOM attribute node to load. */ private void load(Attr attr) { handlePrefixMapping(attr.getNamespaceURI(), attr.getPrefix()); load(this.efactory.makeAttribute(attr.getNamespaceURI(), attr.getLocalName(), attr.getNodeName(), attr.getValue())); }
/** * remove a an attribue * @param oldAttr * @return oldAttr * @throws DOMException */ public Attr removeAttributeNode(Attr oldAttr) throws DOMException { makeAttributesEditable(); Name name = new PrefixedQName(oldAttr.getNamespaceURI(), oldAttr.getLocalName(), oldAttr.getPrefix()); removeAttribute(name); return oldAttr; }
int attrsLength = attrs.getLength(); for (int i = 0; i < attrsLength; i++) { Attr attribute = (Attr) attrs.item(i); String NName = attribute.getLocalName(); String NNodeValue = attribute.getNodeValue(); if (!XMLNS_URI.equals(attribute.getNamespaceURI())) { String prefix = attribute.getPrefix(); if (prefix != null && !(prefix.equals(XML) || prefix.equals(XMLNS))) { visiblyUtilized.add(prefix);
/** {@inheritDoc} */ protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException { SignatureConfirmation sc = (SignatureConfirmation) xmlObject; QName attrName = QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix()); if (SignatureConfirmation.WSU_ID_ATTR_NAME.equals(attrName)) { sc.setWSUId(attribute.getValue()); attribute.getOwnerElement().setIdAttributeNode(attribute, true); } else if (SignatureConfirmation.VALUE_ATTRIB_NAME.equals(attribute.getLocalName())) { sc.setValue(attribute.getValue()); } else { super.processAttribute(xmlObject, attribute); } }
/** * remove a an attribue * @param oldAttr * @return oldAttr * @throws DOMException */ public Attr removeAttributeNode(Attr oldAttr) throws DOMException { makeAttributesEditable(); Name name = new PrefixedQName(oldAttr.getNamespaceURI(), oldAttr.getLocalName(), oldAttr.getPrefix()); removeAttribute(name); return oldAttr; }
int length = atts.getLength(); Attr att = (Attr) atts.item(i); String attributeNamespace = att.getNamespaceURI(); if ("http://www.w3.org/2000/xmlns/".equals(attributeNamespace)) { String prefix = att.getPrefix(); NamespaceNode ns = new NamespaceNode((Node)contextNode, prefix, attributeNamespace); Attr att = (Attr) atts.item(i); String attributeNamespace = att.getNamespaceURI(); if ("http://www.w3.org/2000/xmlns/".equals(attributeNamespace)) { NamespaceNode ns =