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:Main.java

/**
 * Tests if an element is nil.//from  w w  w.j av a2  s  .  co  m
 * @param element the element to test
 * @return <tt>true</tt> if the element is nil
 */
public static boolean isNil(Element element) {
    String nil = element.getAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "nil");
    return "true".equals(nil) || "1".equals(nil);
}

From source file:Main.java

/**
 * Retrieves the client id of the client that locked the given node.
 * @param element the node that is locked.
 * @return the id of the locking client.
 *//*from   w w  w .  j  av a2 s  .c o  m*/
public static String getLockerId(Element element) {
    return element.getAttributeNS(CEFX_NAMESPACE, CEFX_LOCKED_ATTR_NAME);

}

From source file:Main.java

public static String getAttrValueNS(Element elem, String nsUri, String localName) {
    return elem.getAttributeNS(nsUri, localName);
}

From source file:Main.java

static public String getNamespaceURI(Document doc, String prefix) {
    Element e = doc.getDocumentElement();
    return e.getAttributeNS("", prefix);
}

From source file:Utils.java

public static String getAttribute(Element element, QName attName) {
    return element.getAttributeNS(attName.getNamespaceURI(), attName.getLocalPart());
}

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

/**
 * Checks if the given node is locked.//from  w  ww  .  j a  va  2 s  .c  om
 * @param element the node that is to be checked.
 * @return true if the node is locked.
 */
public static boolean isLocked(Element element) {
    String locked = element.getAttributeNS(CEFX_NAMESPACE, CEFX_LOCKED_ATTR_NAME);
    System.out.println("CEFXUtil.isLocked() " + locked + " element: " + element);
    if (locked.equals("") || locked == null) {
        // The node does not carry the Lock Attribute. It is not locked
        return false;
    } else {
        return true;
    }
}

From source file:Main.java

/**
 * Get a boolean attribute from the supplied element.
 * @param element The element.//from  w w  w . java2s .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"));
}

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.ja  v a2 s.c o  m
}

From source file:Main.java

/**
 * Get attribute value, returning <code>null</code> if unset.
 * Some DOM implementations return an empty string for an unset
 * attribute./*  w ww.j av  a2s .  c o m*/
 * @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 &lt;code&gt;null&lt;/code&gt; 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;
}