Code example for QName

Methods: getLocalPart, getNamespaceURI, getPrefix

0
     * @return An empty Element whose owner is the given Document. 
     * 
     */ 
    private static Element createEmptyElement(Document doc, QName qname)
    { 
        String prefix = qname.getPrefix();
        String name = qname.getLocalPart();
         
        // 
        // NOTE: The DOM API requires that elements with qualified names  
        //       be created with prefix:localName as the tag name. We  
        //       CANNOT just use the localName and expect the API to fill  
        //       in a prefix, nor can we use setPrefix after creation. For  
        //       parsing to work correctly, the second argument to the  
        //       createElementNS method MUST be a qualified name. 
        // 
        if (prefix != null && prefix.length() > 0)
            name = prefix + ':' + name;
         
        String uri = qname.getNamespaceURI();
         
        return doc.createElementNS(uri, name);
    } 
     
    /**