org.w3c.dom.Element.getAttributeNodeNS()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.w3c.dom.Element.getAttributeNodeNS()方法的一些代码示例,展示了Element.getAttributeNodeNS()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getAttributeNodeNS()方法的具体详情如下:
包路径:org.w3c.dom.Element
类名称:Element
方法名:getAttributeNodeNS

Element.getAttributeNodeNS介绍

[英]Retrieves an Attr node by local name and namespace URI.
Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.
[中]按本地名称和命名空间URI检索Attr节点。
根据[{$0$}],如果应用程序希望没有命名空间,则必须将值null用作方法的namespaceURI参数。

代码示例

代码示例来源:origin: plutext/docx4j

/**
 * 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();
}

代码示例来源:origin: org.apache.poi/poi-ooxml

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() + "' !");

代码示例来源:origin: plutext/docx4j

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) {

代码示例来源:origin: plutext/docx4j

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) {

代码示例来源:origin: apache/pdfbox

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());
}

代码示例来源:origin: wsdl4j/wsdl4j

/**
 * 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;
}

代码示例来源:origin: org.apache.neethi/neethi

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());
}

代码示例来源:origin: org.apache.neethi/neethi

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());
}

代码示例来源:origin: com.sun.xml.ws/jaxws-rt

public static String getAttributeNSOrNull(
  Element e,
  String name,
  String nsURI) {
  Attr a = e.getAttributeNodeNS(nsURI, name);
  if (a == null)
    return null;
  return a.getValue();
}

代码示例来源:origin: org.walkmod/walkmod-core

/**
 * 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;
}

代码示例来源:origin: walkmod/walkmod-core

/**
 * 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;
}

代码示例来源:origin: org.apache.woden/woden-impl-dom

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;
}

代码示例来源:origin: org.apache.struts.xwork/xwork-core

/**
 * 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;
}

代码示例来源:origin: javaee/metro-jax-ws

public static String getAttributeNSOrNull(
  Element e,
  String name,
  String nsURI) {
  Attr a = e.getAttributeNodeNS(nsURI, name);
  if (a == null)
    return null;
  return a.getValue();
}

代码示例来源:origin: com.sun.xml.ws/rt

public static String getAttributeNSOrNull(
  Element e,
  String name,
  String nsURI) {
  Attr a = e.getAttributeNodeNS(nsURI, name);
  if (a == null)
    return null;
  return a.getValue();
}

代码示例来源:origin: org.apache.woden/woden-core

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;
}

代码示例来源:origin: org.apache.struts.xwork/xwork-core

/**
 * 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;
}

代码示例来源:origin: com.github.lafa.pdfbox/xmpbox

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());
}

代码示例来源:origin: NGDATA/lilyproject

/**
 * 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;
}

代码示例来源:origin: org.apache.struts.xwork/xwork-core

/**
 * 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;
}

相关文章

微信公众号

最新文章

更多