Java 8 NamespaceContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 NamespaceContext class.

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;
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
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;
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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()  
     */ 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getNamespaceURI
    if (colon + 1 >= string.length())
      throw new XMLStreamException(L.l("Invalid qualified name: {0}", string));
 
    String prefix = string.substring(0, colon);
    String localName = string.substring(colon + 1);
    String namespace = context.getNamespaceURI(prefix);
 
    if (NULL_NS_URI.equals(namespace))
      throw new XMLStreamException(L.l("No namespace for qualifed name: {0}", string));
 
    return new QName(namespace, localName, prefix);
  } 
 
  /** 
   * Ensures that a given namespace exists within the namespace context 
   * given. 
   **/ 
  public static void repairNamespace(XMLStreamWriter out, String namespace)
    throws XMLStreamException 
  { 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getNamespaceURI
               case 0: 
                   throw new IllegalArgumentException("Default prefix must be indicated by not using a colon: " + arg0);
                  default: 
                      String prefix = arg0.substring(0, offset);
                      localName = arg0.substring(offset+1);
                      uri = arg1.getNamespaceURI(prefix);
                      if (uri == null) {
                          throw new IllegalArgumentException("The prefix " + prefix + " is not bound.");
                      } 
        } 
        return new QName(uri, localName);
    } 
 
    public Calendar parseDateTime(String arg0) {
        XsDateTimeFormat format = new XsDateTimeFormat();
        ParsePosition pos = new ParsePosition(0);
        Calendar cal = (Calendar) format.parseObject(arg0, pos);
        if (cal == null) {
            throw new IllegalArgumentException("Failed to parse dateTime " + arg0 +
                    						   " at:" + arg0.substring(pos.getErrorIndex()));
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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; 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getNamespaceURI
        } 
         
        public String getNamespaceURI(String prefix) {
            String ret = map.get(prefix);
            if (ret == null && parent != null) {
                return parent.getNamespaceURI(prefix);
            } 
            return ret;
        } 
 
        public String getPrefix(String namespaceURI) {
            for (Map.Entry<String, String> e : map.entrySet()) {
                if (e.getValue().equals(namespaceURI)) {
                    return e.getKey();
                } 
            } 
            if (parent != null) {
                return parent.getPrefix(namespaceURI);
            } 
            return null; 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getNamespaceURI
    else 
      { 
        prefix = name.substring(0, ci);
        localName = name.substring(ci + 1);
      } 
    uri = nsctx.getNamespaceURI(prefix);
    if (uri == null)
      { 
        return (xpathFunctions.contains(localName)  ||
                xsltFunctions.contains(localName)) ?
          Boolean.TRUE : Boolean.FALSE;
      } 
    else if (Stylesheet.XSL_NS.equals(uri))
      { 
        return xsltFunctions.contains(localName) ?
          Boolean.TRUE : Boolean.FALSE;
      } 
    // TODO extension functions 
    return Boolean.FALSE;
  } 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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; 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 NamespaceContext Questions & Answers:

See Code Examples for Java 8 NamespaceContext Methods: