Refine search
/** * Returns the attribute value for the attribute with the specified name. * Returns null if there is no such attribute, or * the empty string if the attribute value is empty. * * <p>This works around a limitation of the DOM * <code>Element.getAttributeNode</code> method, which does not distinguish * between an unspecified attribute and an attribute with a value of * "" (it returns "" for both cases). * * @param elem the element containing the attribute * @param name the name of the attribute * @return the attribute value (may be null if unspecified) */ public static String getAttributeValue(Element elem, String name) { Attr attr = elem.getAttributeNodeNS(null, name); return (attr == null) ? null : attr.getValue(); }
if (attr.getValue().equals(PackageNamespaces.MARKUP_COMPATIBILITY)) throw new InvalidFormatException( "OPC Compliance error [M4.2]: A format consumer shall consider the use of the Markup Compatibility namespace to be an error."); if (el.getAttributeNodeNS(XMLConstants.XML_NS_URI, "lang") != null) throw new InvalidFormatException( "OPC Compliance error [M4.4]: Producers shall not create a document element that contains the xml:lang attribute. Consumers shall consider a document element that violates this constraint to be an error."); Attr typeAtt = el.getAttributeNodeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type"); if (typeAtt == null) throw new InvalidFormatException("The element '" + elName if (!typeAtt.getValue().equals(el.getPrefix() + ":W3CDTF")) throw new InvalidFormatException("The element '" + elName + "' must have the 'xsi:type' attribute with the value '" + el.getPrefix() + ":W3CDTF', but had '" + typeAtt.getValue() + "' !");
String NUri = attribute.getNamespaceURI(); String NName = attribute.getLocalName(); String NValue = attribute.getValue(); Attr xmlns = element.getAttributeNodeNS(XMLNS_URI, XMLNS); Node n = null; if (xmlns == null) {
String NUri = attribute.getNamespaceURI(); String NName = attribute.getLocalName(); String NValue = attribute.getValue(); Attr xmlns = element.getAttributeNodeNS(XMLNS_URI, XMLNS); Node n = null; if (xmlns == null) {
public static boolean isParseTypeResource(Element element) { Attr parseType = element.getAttributeNodeNS(XmpConstants.RDF_NAMESPACE, XmpConstants.PARSE_TYPE); return parseType != null && XmpConstants.RESOURCE_NAME.equals(parseType.getValue()); }
/** * Returns the value of an attribute of an element. Returns null * if the attribute is not found (whereas Element.getAttributeNS * returns "" if an attrib is not found). * * @param el Element whose attrib is looked for * @param namespaceURI namespace URI of attribute to look for * @param localPart local part of attribute to look for * @return the attribute value */ static public String getAttributeNS (Element el, String namespaceURI, String localPart) { String sRet = null; Attr attr = el.getAttributeNodeNS (namespaceURI, localPart); if (attr != null) { sRet = attr.getValue (); } return sRet; }
public static boolean isOptional(Element el) { Attr optional = el.getAttributeNodeNS(Constants.URI_POLICY_13_NS, Constants.ATTR_OPTIONAL); if (optional == null) { optional = el.getAttributeNodeNS(Constants.URI_POLICY_15_NS, Constants.ATTR_OPTIONAL); } if (optional == null) { optional = el.getAttributeNodeNS(Constants.URI_POLICY_15_DEPRECATED_NS, Constants.ATTR_OPTIONAL); } return optional == null ? false : Boolean.parseBoolean(optional.getValue()); }
public static boolean isIgnorable(Element el) { Attr ignorable = el.getAttributeNodeNS(Constants.URI_POLICY_15_NS, Constants.ATTR_IGNORABLE); if (ignorable == null) { ignorable = el.getAttributeNodeNS(Constants.URI_POLICY_15_DEPRECATED_NS, Constants.ATTR_IGNORABLE); } return ignorable == null ? false : Boolean.parseBoolean(ignorable.getValue()); }
public static String getAttributeNSOrNull( Element e, String name, String nsURI) { Attr a = e.getAttributeNodeNS(nsURI, name); if (a == null) return null; return a.getValue(); }
/** * Returns the URI of an element (DOM flavor) * * @param elem * the element that holds the location information * @return the element's URI or "<code>[unknown location]</code>" if * <code>elem</code> has no location information. */ public static String getURI(Element elem) { Attr attr = elem.getAttributeNodeNS(URI, SRC_ATTR); return attr != null ? attr.getValue() : LocationUtils.UNKNOWN_STRING; }
/** * Returns the URI of an element (DOM flavor) * * @param elem * the element that holds the location information * @return the element's URI or "<code>[unknown location]</code>" if * <code>elem</code> has no location information. */ public static String getURI(Element elem) { Attr attr = elem.getAttributeNodeNS(URI, SRC_ATTR); return attr != null ? attr.getValue() : LocationUtils.UNKNOWN_STRING; }
private String getAttributeNS (Element el, String namespaceURI, String localPart) { String sRet = null; Attr attr = el.getAttributeNodeNS (namespaceURI, localPart); if (attr != null) { sRet = attr.getValue (); } return sRet; }
/** * Returns the URI of an element (DOM flavor) * * @param elem the element that holds the location information * @return the element's URI or "<code>[unknown location]</code>" if <code>elem</code> * has no location information. */ public static String getURI(Element elem) { Attr attr = elem.getAttributeNodeNS(URI, SRC_ATTR); return attr != null ? attr.getValue() : LocationUtils.UNKNOWN_STRING; }
public static String getAttributeNSOrNull( Element e, String name, String nsURI) { Attr a = e.getAttributeNodeNS(nsURI, name); if (a == null) return null; return a.getValue(); }
public static String getAttributeNSOrNull( Element e, String name, String nsURI) { Attr a = e.getAttributeNodeNS(nsURI, name); if (a == null) return null; return a.getValue(); }
private String getAttributeNS (Element el, String namespaceURI, String localPart) { String sRet = null; Attr attr = el.getAttributeNodeNS (namespaceURI, localPart); if (attr != null) { sRet = attr.getValue (); } return sRet; }
/** * Returns the line number of an element (DOM flavor) * * @param elem the element that holds the location information * @return the element's line number or <code>-1</code> if <code>elem</code> * has no location information. */ public static int getLine(Element elem) { Attr attr = elem.getAttributeNodeNS(URI, LINE_ATTR); return attr != null ? Integer.parseInt(attr.getValue()) : -1; }
public static boolean isParseTypeResource(Element element) { Attr parseType = element.getAttributeNodeNS(XmpConstants.RDF_NAMESPACE, XmpConstants.PARSE_TYPE); return parseType != null && XmpConstants.RESOURCE_NAME.equals(parseType.getValue()); }
/** * Returns the line number of an element (DOM flavor) * * @param elem the element that holds the location information * @return the element's line number or <code>-1</code> if <code>elem</code> * has no location information. */ public static int getLine(Element elem) { Attr attr = elem.getAttributeNodeNS(URI, LINE_ATTR); return attr != null ? Integer.parseInt(attr.getValue()) : -1; }
/** * Returns the column number of an element (DOM flavor) * * @param elem the element that holds the location information * @return the element's column number or <code>-1</code> if <code>elem</code> * has no location information. */ public static int getColumn(Element elem) { Attr attr = elem.getAttributeNodeNS(URI, COL_ATTR); return attr != null ? Integer.parseInt(attr.getValue()) : -1; }