Examples of NamespaceContext

All get*(*) methods operate in the current scope for Namespace URI and prefix resolution.

Note that a Namespace URI can be bound to multiple prefixes in the current scope. This can occur when multiple XMLConstants.XMLNS_ATTRIBUTE ("xmlns") Namespace declarations occur in the same Start-Tag and refer to the same Namespace URI. e.g.

 <element xmlns:prefix1="http://Namespace-name-URI" xmlns:prefix2="http://Namespace-name-URI"> 

This can also occur when the same Namespace URI is used in multiple XMLConstants.XMLNS_ATTRIBUTE ("xmlns") Namespace declarations in the logical parent element hierarchy. e.g.
 <parent xmlns:prefix1="http://Namespace-name-URI"> <child xmlns:prefix2="http://Namespace-name-URI"> ... </child> </parent> 

A prefix can only be bound to a single Namespace URI in the current scope.

@author JAXP Java Community Process @author JAXP Reference Implementation @version 1.0.proposed @see javax.xml.XMLConstants declarations of common XML values @see Namespaces in XML @see Namespaces in XML Errata @see XML Schema Part2: Datatypes
  • net.sf.toxicity.util.NamespaceContext
    @author Stefan Podkowinski
  • org.apache.commons.jxpath.ri.axes.NamespaceContext
    EvalContext that walks the "namespace::" axis. @author Dmitri Plotnikov @version $Revision: 1.7 $ $Date: 2003/03/11 00:59:20 $
  • org.apache.ws.util.xml.NamespaceContext
    Interface for read only XML Namespace context processing. @author Ian Springer (ian DOT springer AT hp DOT com)
  • org.apache.xerces.xni.NamespaceContext
    Represents an interface to query namespace information. @author Andy Clark, IBM @version $Id: NamespaceContext.java,v 1.3 2001/12/12 22:33:47 elena Exp $
  • org.apache.xmlbeans.impl.values.NamespaceContext
  • org.custommonkey.xmlunit.NamespaceContext
    Interface used by XpathEngine in order to map prefixes to namespace URIs.

    This is modelled after javax.xml.namespace.NamespaceContext but reduced to our needs.

  • org.jaxen.NamespaceContext
    Resolves namespace prefixes to namespace URIs.

    The prefixes used within an XPath expression are independant of those used within any target document. When evaluating an XPath against a document, only the resolved namespace URIs are compared, not their prefixes.

    A NamespaceContext is responsible for translating prefixes as they appear in XPath expressions into URIs for comparison. A document's prefixes are resolved internal to the document based upon its own namespace nodes.

    @see BaseXPath @see Navigator#getElementNamespaceUri @see Navigator#getAttributeNamespaceUri @author bob mcwhirter
  • org.wso2.carbon.humantask.utils.NamespaceContext

  • Examples of javax.xml.namespace.NamespaceContext

        }

        public static String getUniquePrefix(XMLStreamWriter writer) {
            int n = 1;
           
            NamespaceContext nc = writer.getNamespaceContext();
            while (true) {
                String nsPrefix = "ns" + n;

                if (nc == null || nc.getNamespaceURI(nsPrefix) == null) {
                    return nsPrefix;
                }

                n++;
            }
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

        protected void runTest() throws Throwable {
            InputStream in = TestGetNamespaceContext.class.getResourceAsStream("namespacecontext.xml");
            OMElement root = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), in).getDocumentElement();
            OMElement inner = root.getFirstElement().getFirstElement();
            NamespaceContext context = inner.getNamespaceContext(detached);
            assertEquals("urn:test2", context.getNamespaceURI("p"));
            assertEquals("urn:test3", context.getNamespaceURI("q"));
            assertEquals("urn:test3", context.getNamespaceURI("r"));
            assertEquals("urn:test4", context.getNamespaceURI(""));
            assertEquals("", context.getNamespaceURI("unbound"));
           
            assertNull(context.getPrefix("urn:test1"));
            assertEquals("p", context.getPrefix("urn:test2"));
            String prefix = context.getPrefix("urn:test3");
            assertTrue(prefix.equals("q") || prefix.equals("r"));
            assertEquals("", context.getPrefix("urn:test4"));
            assertNull(context.getPrefix("unbound"));
           
            Iterator it = context.getPrefixes("urn:test1");
            assertFalse(it.hasNext());
           
            it = context.getPrefixes("urn:test2");
            assertTrue(it.hasNext());
            assertEquals("p", it.next());
            assertFalse(it.hasNext());

            it = context.getPrefixes("urn:test3");
            Set prefixes = new HashSet();
            while (it.hasNext()) {
                prefixes.add(it.next());
            }
            assertEquals(2, prefixes.size());
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

            XMLStreamReader stream = cache ? element.getXMLStreamReader()
                    : element.getXMLStreamReaderWithoutCaching();
            stream.next();
            assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
            assertEquals("b", stream.getLocalName());
            NamespaceContext context = stream.getNamespaceContext();
            assertEquals("urn:ns1", context.getNamespaceURI(""));
            assertEquals("urn:ns2", context.getNamespaceURI("ns2"));
            assertEquals("urn:ns3", context.getNamespaceURI("ns3"));
            assertEquals("ns2", context.getPrefix("urn:ns2"));
            element.close(false);
        }
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

        public QName getName() {
            return state == STATE_PASS_THROUGH ? parent.getName() : XOPConstants.INCLUDE_QNAME;
        }

        public NamespaceContext getNamespaceContext() {
            NamespaceContext ctx = parent.getNamespaceContext();
            if (state != STATE_PASS_THROUGH) {
                ctx = new NamespaceContextWrapper(ctx);
            }
            return ctx;
        }
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

                            }
                        }
                        depth++;
                    }
                    if (depth > 0) {
                        NamespaceContext nc = reader.getNamespaceContext();
                        for (Iterator it = prefixes.iterator(); it.hasNext(); ) {
                            String prefix = (String)it.next();
                            String expectedUri = refNc.getNamespaceURI(prefix);
                            String actualUri = nc.getNamespaceURI(prefix);
                            assertEquals("Namespace URI for prefix '" + prefix + "'", expectedUri, actualUri);
                        }
                        for (Iterator it = namespaceURIs.iterator(); it.hasNext(); ) {
                            String namespaceURI = (String)it.next();
                            assertEquals(
                                    "Prefix for namespace URI '" + namespaceURI + "'",
                                    refNc.getPrefix(namespaceURI),
                                    nc.getPrefix(namespaceURI));
                            assertEquals(
                                    "Prefixes for namespace URI '" + namespaceURI + "'",
                                    toPrefixSet(refNc.getPrefixes(namespaceURI)),
                                    toPrefixSet(nc.getPrefixes(namespaceURI)));
                        }
                    }
                    if (eventType == XMLStreamReader.END_ELEMENT) {
                        refNc.endScope();
                        depth--;
    View Full Code Here

    Examples of net.sf.toxicity.util.NamespaceContext

                boolean optional = bind.optional();
               
                try {
                    // make ns available
                    if(!bind.nsUri().equals("")) {
                        NamespaceContext nsContext = new NamespaceContext();
                        nsContext.addPrefix(bind.nsUri(), bind.nsPrefix());
                        xpath.setNamespaceContext(nsContext);
                    }
                   
                    // check if condition applies before evaluation xpath
                    if(!cond.equals("")) {
    View Full Code Here

    Examples of org.apache.commons.jxpath.ri.axes.NamespaceContext

                        nodeTest,
                        false);
                case Compiler.AXIS_FOLLOWING_SIBLING :
                    return new ChildContext(context, nodeTest, true, false);
                case Compiler.AXIS_NAMESPACE :
                    return new NamespaceContext(context, nodeTest);
                case Compiler.AXIS_PARENT :
                    return new ParentContext(context, nodeTest);
                case Compiler.AXIS_PRECEDING :
                    return new PrecedingOrFollowingContext(context, nodeTest, true);
                case Compiler.AXIS_PRECEDING_SIBLING :
    View Full Code Here

    Examples of org.apache.ws.util.xml.NamespaceContext

              TopicExpressionResolutionException,
              InvalidTopicExpressionException,
              TopicExpressionException
       {
          String           expr          = getContent( topicExpr );
          NamespaceContext nsContext     = getNamespaceContext( topicExpr );
          QName            topicPath     = toQName( expr, nsContext );
          List             matchedTopics = evaluateTopicPath( topicSpaceSet, topicPath );
          return (Topic[]) matchedTopics.toArray( new Topic[0] );
       }
    View Full Code Here

    Examples of org.apache.ws.util.xml.NamespaceContext

              TopicExpressionResolutionException,
              InvalidTopicExpressionException,
              TopicExpressionException
       {
          String           expr             = getContent( topicExpr );
          NamespaceContext nsContext        = getNamespaceContext( topicExpr );
          StringTokenizer  exprTokenizer    = new StringTokenizer( expr, "|" );
          Set              allMatchedTopics = new HashSet(  );
          while ( exprTokenizer.hasMoreTokens(  ) )
          {
             QName topicPath     = toQName( exprTokenizer.nextToken(  ),
    View Full Code Here

    Examples of org.apache.ws.util.xml.NamespaceContext

              TopicExpressionResolutionException,
              InvalidTopicExpressionException,
              TopicExpressionException
       {
          String           expr          = getContent( topicExpr );
          NamespaceContext nsContext     = getNamespaceContext( topicExpr );
          QName            topicPath     = toQName( expr, nsContext );
          List             matchedTopics = evaluateTopicPath( topicSpaceSet, topicPath );
          return (Topic[]) matchedTopics.toArray( new Topic[0] );
       }
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.