Example usage for org.w3c.dom Element hasAttributeNS

List of usage examples for org.w3c.dom Element hasAttributeNS

Introduction

In this page you can find the example usage for org.w3c.dom Element hasAttributeNS.

Prototype

public boolean hasAttributeNS(String namespaceURI, String localName) throws DOMException;

Source Link

Document

Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise.

Usage

From source file:Main.java

public static String getAttribute(Element element, String namespaceName, String attributeName) {
    return (element.hasAttributeNS(namespaceName, attributeName)
            ? element.getAttributeNS(namespaceName, attributeName)
            : null);/*from  w w  w .j a  va 2 s. c  om*/
}

From source file:Main.java

private static boolean elementHasId(final Element element, final String namespace) {
    return element.hasAttributeNS(namespace, "Id");
}

From source file:Main.java

public static String getAttributeNS(Element elem, String namespace, String att) {
    String res = elem.getAttributeNS(namespace, att);
    return res.length() == 0 && !elem.hasAttributeNS(namespace, att) ? null : res;
}

From source file:Main.java

/**
 * Returns true if the element's containing document 
 * @param elem/*from  w ww. j av a 2 s. co  m*/
 * @return
 */
public static boolean isInDitaDocument(Element elem) {
    Element root = elem.getOwnerDocument().getDocumentElement();
    Element cand = root;
    if (cand.getTagName().equals(DITA_ELEM_TAGNAME)) {
        // FIXME: This a little weak but unlikely to return false positives.         
        return true;
    }
    return root.hasAttributeNS(DITA_ARCH_NS, DITA_ARCH_VERSION_ATTNAME);
}

From source file:de.betterform.xml.xforms.XFormsElement.java

/**
 * returns the value of a given XForms attribute. First tries to fetch it from
 * the XForms namespace. If not successful tries to find it in the null namespace.
 *
 * @param name the localname of the attribute
 * @return the value of the attribute as string or null if attribute is not found
 */// ww  w  .j av a2s .  co m
public static String getXFormsAttribute(Element element, String name) {
    if (element.hasAttributeNS(NamespaceConstants.XFORMS_NS, name)) {
        return element.getAttributeNS(NamespaceConstants.XFORMS_NS, name);
    }
    if (element.hasAttributeNS(null, name)) {
        return element.getAttributeNS(null, name);
    }
    return null;
}

From source file:de.betterform.xml.xforms.XFormsElement.java

/**
 * returns the value of a given BetterForm attribute. First tries to fetch it from
 * the XForms namespace. If not successful tries to find it in the null namespace.
 *
 * @param name the localname of the attribute
 * @return the value of the attribute as string or null if attribute is not found
 *///  ww w  . j a  va2s .  c  o m
public static String getBFAttribute(Element element, String name) {
    if (element.hasAttributeNS(NamespaceConstants.BETTERFORM_NS, name)) {
        return element.getAttributeNS(NamespaceConstants.BETTERFORM_NS, name);
    }
    if (element.hasAttributeNS(null, name)) {
        return element.getAttributeNS(null, name);
    }

    return null;
}

From source file:edu.internet2.middleware.shibboleth.common.config.metadata.RequiredValidUntilFilterBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    if (element.hasAttributeNS(null, "maxValidityInterval")) {
        long interval = SpringConfigurationUtils.parseDurationToMillis(
                "'maxValidityInterval' on metadata filter of type " + XMLHelper.getXSIType(element),
                element.getAttributeNS(null, "maxValidityInterval"), 1000) / 1000;
        builder.addConstructorArgValue(interval);
    }/*from  w ww. jav a 2  s .  c  om*/
}

From source file:edu.internet2.middleware.shibboleth.common.config.security.PKIXValidationOptionsBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    if (element.hasAttributeNS(null, "processEmptyCRLs")) {
        Attr attr = element.getAttributeNodeNS(null, "processEmptyCRLs");
        builder.addPropertyValue("processEmptyCRLs", XMLHelper.getAttributeValueAsBoolean(attr));
    }//from  w ww  .  ja  v  a2  s . c om

    if (element.hasAttributeNS(null, "processExpiredCRLs")) {
        Attr attr = element.getAttributeNodeNS(null, "processExpiredCRLs");
        builder.addPropertyValue("processExpiredCRLs", XMLHelper.getAttributeValueAsBoolean(attr));
    }

    if (element.hasAttributeNS(null, "processCredentialCRLs")) {
        Attr attr = element.getAttributeNodeNS(null, "processCredentialCRLs");
        builder.addPropertyValue("processCredentialCRLs", XMLHelper.getAttributeValueAsBoolean(attr));
    }

    if (element.hasAttributeNS(null, "defaultVerificationDepth")) {
        Integer depth = new Integer(
                DatatypeHelper.safeTrim(element.getAttributeNS(null, "defaultVerificationDepth")));
        builder.addPropertyValue("defaultVerificationDepth", depth);
    }

}

From source file:jp.co.mokha.shibboleth.idp.testing.TestingLoginHandlerBeanDefinitionParser.java

protected void doParse(Element config, BeanDefinitionBuilder builder) {
    super.doParse(config, builder);

    if (config.hasAttributeNS(null, "authenticationServletURL")) {
        builder.addPropertyValue("authenticationServletURL",
                DatatypeHelper.safeTrim(config.getAttributeNS(null, "authenticationServletURL")));
    } else {/*from   ww  w  . j  a  v a2 s.  c om*/
        builder.addPropertyValue("authenticationServletURL", "/Authn/TestingAuth");
    }
}

From source file:org.crisp.aai.idp.bridge.BridgeLoginHandlerBeanDefinitionParser.java

protected void doParse(Element config, BeanDefinitionBuilder builder) {
    super.doParse(config, builder);

    if (config.hasAttributeNS(null, "protectedServletPath")) {
        builder.addPropertyValue("protectedServletPath",
                DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "protectedServletPath")));
    } else {/*from  ww w.  j av  a 2 s  .co  m*/
        builder.addPropertyValue("protectedServletPath", "/Authn/Bridge");
    }
}