Best code examples for Java 8 NamespaceContext class (javax.xml.namespace.NamespaceContext)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 NamespaceContext class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 NamespaceContext examples from Open Source projects
This code example shows how to use the following methods: getPrefix
            return new QName(null);
        } 
         
        QName qName = null;
        try { 
            qName = DatatypeConverterImpl.getInstance().parseQName((String) value, namespaceContext);
        } 
        catch( Exception e ) {
            //could occur if a prefix that was not registered was found 
        } 
         
        //try to set the prefix 
        if (qName != null && (qName.getPrefix() == null || qName.getPrefix().equals( "") ) ) {
            if ( qName.getNamespaceURI() != null && !"".equals(qName.getNamespaceURI()) ) {
                String prefix = namespaceContext.getPrefix(qName.getNamespaceURI());
                if ( prefix != null && !"".equals( prefix ) ) {
                    qName = new QName( qName.getNamespaceURI(), qName.getLocalPart(), prefix );
                } 
            } 
            return qName;
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getNamespaceURI
     */ 
    @Test
    public void findsDefaultNamespaces() throws Exception {
        final NamespaceContext ctx = new XPathContext();
        MatcherAssert.assertThat( 
            ctx.getNamespaceURI("xhtml"),
            Matchers.equalTo("http://www.w3.org/1999/xhtml") 
        ); 
        MatcherAssert.assertThat( 
            ctx.getNamespaceURI("xsl"),
            Matchers.equalTo("http://www.w3.org/1999/XSL/Transform") 
        ); 
        MatcherAssert.assertThat( 
            ctx.getNamespaceURI("xsi"),
            Matchers.equalTo("http://www.w3.org/2001/XMLSchema-instance") 
        ); 
        MatcherAssert.assertThat( 
            ctx.getNamespaceURI("xs"),
            Matchers.equalTo("http://www.w3.org/2001/XMLSchema") 
        ); 

5
CodeRank
This code example shows how to use the following methods: getPrefix
            return new QName(null);
        } 
         
        QName qName = null;
        try { 
            qName = DatatypeConverterImpl.getInstance().parseQName((String) value, namespaceContext);
        } 
        catch( Exception e ) {
            //could occur if a prefix that was not registered was found 
        } 
         
        //try to set the prefix 
        if (qName != null && (qName.getPrefix() == null || qName.getPrefix().equals( "") ) ) {
            if ( qName.getNamespaceURI() != null && !"".equals(qName.getNamespaceURI()) ) {
                String prefix = namespaceContext.getPrefix(qName.getNamespaceURI());
                if ( prefix != null && !"".equals( prefix ) ) {
                    qName = new QName( qName.getNamespaceURI(), qName.getLocalPart(), prefix );
                } 
            } 
            return qName;
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getNamespaceURI
        this.namespaceContext = nsContext;
    }  
 
 
    public String getNamespaceForPrefix( String prefix ) {
        return namespaceContext.getNamespaceURI( prefix );
    } 
 
    /** 
     * Return the base identifier. 
     * 
     * @return null 
     */ 
    public String getBaseIdentifier() {
        return null; 
    } 
 
    /** 
     * @see PrefixResolver#handlesNullPrefixes()  
     */ 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getNamespaceURI
    } 
 
    public String getNamespaceURI(String prefix) {
        String answer = map.get(prefix);
        if (answer == null && parent != null) {
            return parent.getNamespaceURI(prefix);
        } 
        return answer;
    } 
 
    public String getPrefix(String namespaceURI) {
        for (Entry<String, String> entry : map.entrySet()) {
            if (namespaceURI.equals(entry.getValue())) {
                return entry.getKey();
            } 
        } 
        if (parent != null) {
            return parent.getPrefix(namespaceURI);
        } 
        return null; 
Full Snippet Info
5
CodeRank
Related Java 8 NamespaceContext Questions & Answers:
See Code Examples for Java 8 NamespaceContext Methods: