当前位置: 首页>>代码示例>>Java>>正文


Java Element.hasAttributeNS方法代码示例

本文整理汇总了Java中org.w3c.dom.Element.hasAttributeNS方法的典型用法代码示例。如果您正苦于以下问题:Java Element.hasAttributeNS方法的具体用法?Java Element.hasAttributeNS怎么用?Java Element.hasAttributeNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Element的用法示例。


在下文中一共展示了Element.hasAttributeNS方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: namespace

import org.w3c.dom.Element; //导入方法依赖的package包/类
protected void namespace(Element element, String prefix, String uri) {
    String qname;
    if ("".equals(prefix) || prefix == null) {
        qname = "xmlns";
    } else {
        qname = "xmlns:" + prefix;
    }

    // older version of Xerces (I confirmed that the bug is gone with Xerces 2.4.0)
    // have a problem of re-setting the same namespace attribute twice.
    // work around this bug removing it first.
    if (element.hasAttributeNS("http://www.w3.org/2000/xmlns/", qname)) {
        // further workaround for an old Crimson bug where the removeAttribtueNS
        // method throws NPE when the element doesn't have any attribute.
        // to be on the safe side, check the existence of attributes before
        // attempting to remove it.
        // for details about this bug, see org.apache.crimson.tree.ElementNode2
        // line 540 or the following message:
        // https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgNo=2767
        element.removeAttributeNS("http://www.w3.org/2000/xmlns/", qname);
    }
    // workaround until here

    element.setAttributeNS("http://www.w3.org/2000/xmlns/", qname, uri);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:SAX2DOMEx.java

示例2: visitAttribute

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public void visitAttribute(XmlContext context, Attr attribute) {
    super.visitAttribute(context, attribute);

    String value = attribute.getValue();
    if (Utils.stringIsEmpty(value)) return;

    //onClick 属性被赋值
    Element element = attribute.getOwnerElement();
    boolean has = element.hasAttributeNS(SdkConstants.ANDROID_URI, SdkConstants.ATTR_ID);
    if (!has) {

        Location location = context.getLocation(attribute);
        context.report(ISSUE_MISSING_ID, location, "the view with onClick attribute set should has id attribute");
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:17,代码来源:AutoPointLayoutOnclickDetector.java

示例3: doParse

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
        @Nonnull final BeanDefinitionBuilder builder) {

    super.doParse(config, parserContext, builder);
    if (config.hasAttributeNS(null, AS_ARRAY_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asArray",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_ARRAY_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_INT_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asInt",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_INT_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, STRING_DELIMETER_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("stringDelimiter",
                StringSupport.trimOrNull(config.getAttributeNS(null, STRING_DELIMETER_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_OBJECT_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asObject",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_OBJECT_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, FIELD_NAME_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("fieldName",
                StringSupport.trimOrNull(config.getAttributeNS(null, FIELD_NAME_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_BOOLEAN_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asBoolean",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_BOOLEAN_ATTRIBUTE_NAME)));
    }
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:32,代码来源:AbstractOIDCEncoderParser.java

示例4: doParse

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
        @Nonnull final BeanDefinitionBuilder builder) {
    
    super.doParse(config, parserContext, builder);
    
    if (config.hasAttributeNS(null, SCOPE_DELIMETER_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("scopeDelimiter",
                StringSupport.trimOrNull(config.getAttributeNS(null, SCOPE_DELIMETER_ATTRIBUTE_NAME)));
    }
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:13,代码来源:OIDCScopedStringEncoderParser.java

示例5: doNativeParse

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doNativeParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
        @Nonnull final BeanDefinitionBuilder builder) {
    super.doParse(config, builder);

    
    if (config.hasAttributeNS(null, "onlyIfEssential")) {
        builder.addPropertyValue("onlyIfEssential",
                StringSupport.trimOrNull(config.getAttributeNS(null, "onlyIfEssential")));
    }

    if (config.hasAttributeNS(null, "matchOnlyIDToken")) {
        builder.addPropertyValue("matchOnlyIDToken",
                StringSupport.trimOrNull(config.getAttributeNS(null, "matchOnlyIDToken")));
    }

    if (config.hasAttributeNS(null, "matchOnlyUserInfo")) {
        builder.addPropertyValue("matchOnlyUserInfo",
                StringSupport.trimOrNull(config.getAttributeNS(null, "matchOnlyUserInfo")));
    }

    if (config.hasAttributeNS(null, "matchIfRequestedClaimsSilent")) {
        builder.addPropertyValue("matchIfRequestedClaimsSilent",
                StringSupport.trimOrNull(config.getAttributeNS(null, "matchIfRequestedClaimsSilent")));
    }

}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:29,代码来源:AttributeInOIDCRequestedClaimsRuleParser.java

示例6: handleVisitIncludeTag

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void handleVisitIncludeTag(XmlContext context, Element element) {
    boolean hasAttr = element.hasAttributeNS(SdkConstants.ANDROID_URI,
            SdkConstants.ATTR_ID);

    if (!hasAttr) {
        context.report(ISSUE_INCLUDE, element, context.getLocation(element),
                "Missing required attribute 'id'");
    }
}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:10,代码来源:AutoPointerLayoutDetector.java

示例7: relativizeElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
protected static void relativizeElement(Element e) {
    // work from leaves to root in each subtree
    final NodeList children = e.getChildNodes();
    for (int i = 0; i < children.getLength(); ++i) {
      final Node n = children.item(i);
      if (n.getNodeType() == Node.ELEMENT_NODE)
        relativizeElement((Element) n);
    }

    // relativize the xlink:href attribute if there is one
    if (e.hasAttributeNS(XLinkSupport.XLINK_NAMESPACE_URI, "href")) {
      try {
        final URL url = new URL(new URL(e.getBaseURI()),
                                XLinkSupport.getXLinkHref(e));
        final String anchor = url.getRef();
        final String name = new File(url.getPath()).getName();
        XLinkSupport.setXLinkHref(e, name + '#' + anchor);
      }
      // FIXME: review error message
      catch (MalformedURLException ex) {
//        ErrorLog.warn(ex);
      }
    }

    // remove xml:base attribute if there is one
    e.removeAttributeNS(XMLSupport.XML_NAMESPACE_URI, "base");
  }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:28,代码来源:SVGImageUtils.java

示例8: getAttributeValueFrom

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static String getAttributeValueFrom(
    Element element,
    String uri,
    String localName,
    String prefix,
    String qualifiedName) {

    String nonzeroLengthUri =
        (uri == null || uri.length() == 0) ? null : uri;

    boolean mustUseGetAttributeNodeNS =  (nonzeroLengthUri != null);

    if (mustUseGetAttributeNodeNS) {

        if (!element.hasAttributeNS(uri, localName)) {
            return null;
        }

        String attrValue =
            element.getAttributeNS(nonzeroLengthUri, localName);

        return attrValue;
    }

    Attr attribute = null;
    attribute = element.getAttributeNode(qualifiedName);

    return attribute == null ? null : attribute.getValue();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:ElementImpl.java

示例9: elementHasId

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static boolean elementHasId(Element element, String namespace) {
    return element.hasAttributeNS(namespace, "Id");
}
 
开发者ID:xipki,项目名称:xitk,代码行数:4,代码来源:XmlUtil.java

示例10: circumventBug2650internal

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * This is the work horse for {@link #circumventBug2650}.
 *
 * @param node
 * @see <A HREF="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2650">
 * Namespace axis resolution is not XPath compliant </A>
 */
@SuppressWarnings("fallthrough")
private static void circumventBug2650internal(Node node) {
    Node parent = null;
    Node sibling = null;
    final String namespaceNs = Constants.NamespaceSpecNS;
    do {
        switch (node.getNodeType()) {
        case Node.ELEMENT_NODE :
            Element element = (Element) node;
            if (!element.hasChildNodes()) {
                break;
            }
            if (element.hasAttributes()) {
                NamedNodeMap attributes = element.getAttributes();
                int attributesLength = attributes.getLength();

                for (Node child = element.getFirstChild(); child!=null;
                    child = child.getNextSibling()) {

                    if (child.getNodeType() != Node.ELEMENT_NODE) {
                        continue;
                    }
                    Element childElement = (Element) child;

                    for (int i = 0; i < attributesLength; i++) {
                        Attr currentAttr = (Attr) attributes.item(i);
                        if (!namespaceNs.equals(currentAttr.getNamespaceURI())) {
                            continue;
                        }
                        if (childElement.hasAttributeNS(namespaceNs,
                                                        currentAttr.getLocalName())) {
                            continue;
                        }
                        childElement.setAttributeNS(namespaceNs,
                                                    currentAttr.getName(),
                                                    currentAttr.getNodeValue());
                    }
                }
            }
        case Node.ENTITY_REFERENCE_NODE :
        case Node.DOCUMENT_NODE :
            parent = node;
            sibling = node.getFirstChild();
            break;
        }
        while ((sibling == null) && (parent != null)) {
            sibling = parent.getNextSibling();
            parent = parent.getParentNode();
        }
        if (sibling == null) {
            return;
        }

        node = sibling;
        sibling = node.getNextSibling();
    } while (true);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:65,代码来源:XMLUtils.java

示例11: matches

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public boolean matches(Element element) {
    return element.hasAttributeNS(null, localName);
}
 
开发者ID:i49,项目名称:cascade,代码行数:5,代码来源:AttributeNameMatcher.java


注:本文中的org.w3c.dom.Element.hasAttributeNS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。