Code example for Element

Methods: getLocalNamegetNamespaceURIgetNodeNamegetPrefix

0
     * @return The QName of the given Element definition. 
     * 
     */ 
    public static QName getElementQName(Element xml)
    { 
        String uri = xml.getNamespaceURI();
        String prefix = xml.getPrefix();
        String name = xml.getLocalName();
         
        // 
        // support for DOM Level 1 - no NS concept 
        // 
        if (name == null)
            return new QName(xml.getNodeName());
         
        // 
        // prefix is not required, but it CANNOT be null 
        // 
        if (prefix != null && prefix.length() > 0)
            return new QName(uri, name, prefix);