public static Map<String, Object> loadAttributes(Element e) { Map<String, Object> map = new HashMap<String, Object>(); NamedNodeMap nm = e.getAttributes(); for (int j = 0; j < nm.getLength(); j++) { Node n = nm.item(j); if (n instanceof Attr) { Attr attr = (Attr) n; map.put(attr.getName(), attr.getNodeValue()); } } return map; }
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()); }
public String getAttributeName(int index) { return decodeAttribute(((Attr) currentElement.getAttributes().item(index)).getName()); }
String namespaceURI0 = attr0.getNamespaceURI(); String namespaceURI1 = attr1.getNamespaceURI(); String name0 = attr0.getName(); String name1 = attr1.getName(); return name0.compareTo(name1);
public static Node importNode( Document document, Attr attr ) { Attr attribute = document.createAttributeNS( attr.getNamespaceURI(), attr.getName() ); attribute.setValue( attr.getValue() ); return attribute; }
if (n.getLocalName().equals("base") && !e.rendered) { baseAttrs.add(n); } else if (!loa.containsKey(n.getName())) { loa.put(n.getName(), n); Attr n = it.next(); if (n.getLocalName().equals("base")) { base = n.getValue(); baseAttr = n; break; Attr n = it.next(); if (base == null) { base = n.getValue(); baseAttr = n; } else { try { base = joinURI(n.getValue(), base); } catch (URISyntaxException ue) { if (log.isDebugEnabled()) {
/** * Returns the local name of an attribute. Unlike <code>Node.getLocalName() * </code>, properly handles elements that don't have a namespace. */ public static String getLocalName(Attr attr) { return (attr.getNamespaceURI() == null) ? attr.getName() : attr.getLocalName(); }
public static String attr(Element el, String... attr) { NamedNodeMap nnm = el.getAttributes(); for(int i = 0; i != nnm.getLength(); ++i) { Node node = nnm.item(i); if (node instanceof Attr) { Attr a = (Attr) node; for(String at: attr) { if (a.getName().equalsIgnoreCase(at)) { return a.getValue(); } } } } return null; } }
public static Node importNode( Document document, Attr attr ) { Attr attribute = document.createAttributeNS( attr.getNamespaceURI(), attr.getName() ); attribute.setValue( attr.getValue() ); return attribute; }
final String urlValue = urlAttribute.getValue(); try { connectionUri = new URI(urlValue); throw new XmlConfigurationException( String.format("Value of %s attribute on XML configuration element <%s> in <%s> is not a valid URI - '%s'", urlAttribute.getName(), item.getNodeName(), fragment.getTagName(), connectionUri), e); for (int j = 0; j < serverNodes.getLength(); j++) { final Node serverNode = serverNodes.item(j); final String host = ((Element)serverNode).getAttributeNode("host").getValue(); final Attr port = ((Element)serverNode).getAttributeNode("port"); InetSocketAddress address; address = InetSocketAddress.createUnresolved(host, 0); } else { String portString = port.getValue(); address = InetSocketAddress.createUnresolved(host, Integer.parseInt(portString));
public Attr getAttributeNodeNS(String namespaceURI, String localName) { for (int i=0; i<attrs.length; i++) { if (attrs[i].getName().equals(localName) && nsEquals(attrs[i].getNamespaceURI(), namespaceURI)) { return attrs[i]; } } return null; }
private static void fixupAttrsSingle(Element e) throws DOMException { removeXmlBase(e); Map<String, String> replace = new HashMap<String, String>(); NamedNodeMap attrs = e.getAttributes(); for (int j = 0; j < attrs.getLength(); j++) { Attr attr = (Attr) attrs.item(j); if (attr.getNamespaceURI() == null && !attr.getName().equals("xmlns")) { // NOI18N replace.put(attr.getName(), attr.getValue()); } } for (Map.Entry<String, String> entry : replace.entrySet()) { e.removeAttribute(entry.getKey()); e.setAttributeNS(null, entry.getKey(), entry.getValue()); } } private static void removeXmlBase(Element e) {
public static String getNamespaceDeclarationNamespace(Attr attr) { if(!W3C_XML_SCHEMA_XMLNS_URI.equals(attr.getNamespaceURI())) { throw new IllegalStateException("Attempt to get namespace from a attribute that is not a namespace declaration, it has namespace " + attr.getNamespaceURI()); } String attrName = attr.getName(); if(!attrName.startsWith("xmlns:") && !"xmlns".equals(attr.getName())) { throw new IllegalStateException("Attempt to get namespace from a attribute that is not a namespace declaration, it is "+attrName); } return attr.getValue(); }