/** * Look up an attribute's value by Namespace name. * * @param uri The Namespace URI, or the empty String if the * name has no Namespace URI. * @param localName The local name of the attribute. * @return The attribute value as a string, or null if the * attribute is not in the list. */ public String getValue(String uri, String localName) { Node a=m_attrs.getNamedItemNS(uri,localName); return (a==null) ? null : a.getNodeValue(); }
/** * Look up an attribute's value by Namespace name. * * @param uri The Namespace URI, or the empty String if the * name has no Namespace URI. * @param localName The local name of the attribute. * @return The attribute value as a string, or null if the * attribute is not in the list. */ public String getValue(String uri, String localName) { Node a=m_attrs.getNamedItemNS(uri,localName); return (a==null) ? null : a.getNodeValue(); }
/** * Look up an attribute's value by Namespace name. * * @param uri The Namespace URI, or the empty String if the * name has no Namespace URI. * @param localName The local name of the attribute. * @return The attribute value as a string, or null if the * attribute is not in the list. */ public String getValue(String uri, String localName) { Node a=m_attrs.getNamedItemNS(uri,localName); return (a==null) ? null : a.getNodeValue(); }
public static String getAttribute(Node node, String localName, String namespaceURI) { Node attributeNode = node.getAttributes().getNamedItemNS(namespaceURI, localName); if (attributeNode == null) { return null; } return attributeNode.getTextContent(); }
/** * Look up an attribute's value by Namespace name. * * @param uri The Namespace URI, or the empty String if the * name has no Namespace URI. * @param localName The local name of the attribute. * @return The attribute value as a string, or null if the * attribute is not in the list. */ public String getValue(String uri, String localName) { Node a=m_attrs.getNamedItemNS(uri,localName); return (a==null) ? null : a.getNodeValue(); }
/** * Helper function that uses a default value when value not set. * * @param elementNode that should have the attribute * @param attrName that is to be looked up * @param defValue String to return if not set * @return value of the attribute or defValue */ public static String getAttributeValue(final Node elementNode, final String attrName, final String defValue) { final Node attrNode = elementNode.getAttributes().getNamedItemNS(null, attrName); if (attrNode == null) { return defValue; } return attrNode.getNodeValue(); }
/** * Helper function that hides the null return from {@link org.w3c.dom.NamedNodeMap#getNamedItem(String)} * * @param elementNode that could be null * @param attrName that is to be looked up * @return null or value of the attribute */ public static String getAttributeValueOrNull(final Node elementNode, final String attrName) { if (null == elementNode || null == elementNode.getAttributes()) { return null; } final Node attrNode = elementNode.getAttributes().getNamedItemNS(null, attrName); if (null == attrNode) { return null; } return attrNode.getNodeValue(); }
/** * Helper function that throws an exception when the attribute is not set. * * @param elementNode that should have the attribute * @param attrName that is to be looked up * @return value of the attribute * @throws IllegalArgumentException if the attribute is not present */ public static String getAttributeValue(final Node elementNode, final String attrName) { final Node attrNode = elementNode.getAttributes().getNamedItemNS(null, attrName); if (attrNode == null || "".equals(attrNode.getNodeValue())) { throw new IllegalStateException( "Element '" + elementNode.getNodeName() + "' has empty or missing attribute: " + attrName); } return attrNode.getNodeValue(); }
private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) { if (a.getLength() != b.getLength()) { return false; } for (int i = 0; i < a.getLength(); i++) { Node aNode = a.item(i); Node bNode = aNode.getLocalName() == null ? b.getNamedItem(aNode.getNodeName()) : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName()); if (bNode == null || !aNode.isEqualNode(bNode)) { return false; } } return true; }
private boolean isResourceType(Node node) { Node parseType = node.getAttributes().getNamedItemNS(XMP.NS_RDF, "parseType"); return parseType != null && "Resource".equals(parseType.getNodeValue()); }
private String getToolkit(Document document) { NodeList xmpmeta = document.getElementsByTagNameNS(XMP.NS_X, "xmpmeta"); if (xmpmeta == null || xmpmeta.getLength() <= 0) { return null; } Node toolkit = xmpmeta.item(0).getAttributes().getNamedItemNS(XMP.NS_X, "xmptk"); return toolkit != null ? toolkit.getNodeValue() : null; }
/** * Return the gml:id of a Node (must be an Element). * * @param node * @return the gml:id */ protected String getID(Node node) { return node.getAttributes() .getNamedItemNS(GML.NAMESPACE, GML.id.getLocalPart()) .getNodeValue(); } }
/** * Return the gml:id of a Node (must be an Element). * * @param node * @return the gml:id */ protected String getID(Node node) { return node.getAttributes() .getNamedItemNS(GML.NAMESPACE, GML.id.getLocalPart()) .getNodeValue(); } }
/** * <b>DOM</b>: Implements {@link * org.w3c.dom.Element#hasAttributeNS(String,String)}. */ public boolean hasAttributeNS( String namespaceURI, String localName ) { if ( namespaceURI != null && namespaceURI.length() == 0 ) { namespaceURI = null; } return attributes != null && attributes.getNamedItemNS( namespaceURI, localName ) != null; }
public String getAttributeValue(Node node, String namespace, String name) { if(node == null) { return null; } Node attribute = node.getAttributes().getNamedItemNS(namespace, name); if(attribute == null) { return null; } return attribute.getTextContent(); }
public String getAttributeValue(String namespaceURI, String localName) { if (_state == START_ELEMENT) { if (_namedNodeMap != null) { Node attr = _namedNodeMap.getNamedItemNS(namespaceURI, localName); return attr != null ? attr.getNodeValue() : null; } return null; } throw new IllegalStateException("DOMStreamReader: getAttributeValue() called in illegal state"); }
public String getAttributeValue(String namespaceURI, String localName) { if (_state == START_ELEMENT) { if (_namedNodeMap != null) { Node attr = _namedNodeMap.getNamedItemNS(namespaceURI, localName); return attr != null ? attr.getNodeValue() : null; } return null; } throw new IllegalStateException("DOMStreamReader: getAttributeValue() called in illegal state"); }
public static String getAttribute(Node node, String localName, String namespaceURI) { Node attributeNode = node.getAttributes().getNamedItemNS(namespaceURI, localName); if(attributeNode == null) { return null; } return attributeNode.getTextContent(); }
/** {@inheritDoc} */ public Attr getAttributeNodeNS(String namespaceURI, String localName){ return (attributes==null)?null:(AttrImpl)getAttributes().getNamedItemNS(namespaceURI, localName); }
/** {@inheritDoc} */ public String getAttributeNS(String namespaceURI, String localName) { if (attributes==null) return ""; AttrImpl attr = (AttrImpl) getAttributes().getNamedItemNS(namespaceURI,localName); return attr==null?"":attr.getValue(); }