Example usage for org.w3c.dom Element getAttributeNS

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

Introduction

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

Prototype

public String getAttributeNS(String namespaceURI, String localName) throws DOMException;

Source Link

Document

Retrieves an attribute value by local name and namespace URI.

Usage

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

/**
 * Parses a custom element that is a reference to a bean declared elsewhere.
 * //ww w.  jav  a 2s . c  om
 * @param element the element that references the bean
 * @param refAttribute the name of the attribute that contains the referenced bean's name
 * @param parserContext current parsing context
 * 
 * @return reference to the bean or null if the element did not contain the reference attribute
 */
public static RuntimeBeanReference parseCustomElementReference(Element element, String refAttribute,
        ParserContext parserContext) {
    String reference = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, refAttribute));
    if (reference != null) {
        return new RuntimeBeanReference(reference);
    }

    return null;
}

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

/**
 * Parses a bean definition using an xsi:type aware version of
 * BeanDefinitionParserDelegate.parseCustomElement(Element).
 * /*from www  . j a v a2  s . co m*/
 * @param element element to parse
 * @param idAttribute attribute that carries the unique ID for the bean
 * @param parserContext current parser context
 * 
 * @return bean definition reference
 */
public static RuntimeBeanReference parseCustomElement(Element element, String idAttribute,
        ParserContext parserContext) {
    createBeanDefinition(element, parserContext);
    RuntimeBeanReference beanRef = new RuntimeBeanReference(element.getAttributeNS(null, idAttribute));
    beanRef.setSource(element);
    return beanRef;
}

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
 *///from ww w. j  a  v a2s. c  o  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
 *///from  w ww.j  av a  2  s .co 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:DomUtils.java

/**
 * Get a boolean attribute from the supplied element.
 * @param element The element.//  w  ww.  ja  v a2s . c  om
 * @param namespaceURI Namespace URI of the required attribute.
 * @param attribName The attribute name.
 * @return True if the attribute value is "true" (case insensitive), otherwise false.
 */
public static boolean getBooleanAttrib(Element element, String attribName, String namespaceURI) {

    String attribVal = element.getAttributeNS(namespaceURI, attribName);

    return (attribVal != null ? attribVal.equalsIgnoreCase("true") : false);
}

From source file:edu.internet2.middleware.shibboleth.common.config.service.AbstractServiceBeanDefinitionParser.java

/**
 * Gets the ID of the service./*from  w  w w.  ja  va 2 s .  c  o m*/
 * 
 * @param configElement service configuration element
 * 
 * @return ID of the service
 */
protected String getServiceId(Element configElement) {
    return configElement.getAttributeNS(null, "id");
}

From source file:fi.vm.kapa.identification.shibboleth.extattribute.ShibbolethExtAttributeConnectorParser.java

protected void doV2Parse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String proxyUrl = element.getAttributeNS(null, "proxyUrl");
    builder.addPropertyValue("proxyUrl", proxyUrl);
}

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

/**
 * Gets the ID of the metadata provider.
 * //  w  ww. j  av a2s.c  o m
 * @param config metadata provider configuration element
 * 
 * @return ID of the metadata provider
 */
protected String getProviderId(Element config) {
    return DatatypeHelper.safeTrimOrNullString(config.getAttributeNS(null, "id"));
}

From source file:edu.internet2.middleware.shibboleth.idp.config.profile.saml1.SAML1ArtifactResolutionProfileHanderBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element config, BeanDefinitionBuilder builder) {
    super.doParse(config, builder);

    builder.addConstructorArgReference(config.getAttributeNS(null, "artifactMapRef"));
}

From source file:DomUtils.java

/**
 * Get attribute value, returning <code>null</code> if unset.
 * <p/>/* w w  w . j  ava 2 s  .c om*/
 * Some DOM implementations return an empty string for an unset
 * attribute.
 * @param element The DOM element.
 * @param attributeName The attribute to get.
 * @param namespaceURI Namespace URI of the required attribute, or null
 * to perform a non-namespaced get.
 * @return The attribute value, or <code>null</code> if unset.
 */
public static String getAttributeValue(Element element, String attributeName, String namespaceURI) {

    String attributeValue;

    if (namespaceURI == null) {
        attributeValue = element.getAttribute(attributeName);
    } else {
        attributeValue = element.getAttributeNS(namespaceURI, attributeName);
    }

    if (attributeValue.length() == 0 && !element.hasAttribute(attributeName)) {
        return null;
    }

    return attributeValue;
}