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 com.caucho.xpath.NamespaceContext

        println();
        println("_namespaces = new NamespaceContext[] { ");
        pushDepth();

        for (int i = 0; i < _namespaces.size(); i++) {
          NamespaceContext ns = _namespaces.get(i);

          printNamespaceDef(ns);
          println(",");
        }
        popDepth();
    View Full Code Here

    Examples of com.caucho.xpath.NamespaceContext

        if (nodeName == null) {
          if (child.getNodeType() == child.TEXT_NODE)
            generateText(child);
          else if (child.getNodeType() == child.ELEMENT_NODE) {
            NamespaceContext oldNamespace = addNamespace((Element) child);
            printElement((Element) child);
            _namespace = oldNamespace;
          }
          return;
        }

        if (child instanceof QElement) {
          NamespaceContext oldNamespace = addNamespace((QElement) child);
          generateChild(child, code);
          _namespace = oldNamespace;
        }
        else
          generateChild(child, code);
    View Full Code Here

    Examples of com.caucho.xpath.NamespaceContext

       *
       * @return the old namespace context
       */
      protected NamespaceContext addNamespace(Element elt)
      {
        NamespaceContext oldNamespace = _namespace;

        Node attr = ((QElement) elt).getFirstAttribute();
        for (; attr != null; attr = attr.getNextSibling()) {
          String name = attr.getNodeName();

          if (name.startsWith("xmlns:"))
            name = name.substring(6);
          else if (name.equals("xmlns"))
            name = "";
          else
            continue;

          // Note: according to the spec, the default namespace is not used
         
          String url = attr.getNodeValue();
          if (url.equals(XSLNS) || url.equals(XTPNS))
            continue;

          if (url.startsWith("quote:"))
            url = url.substring(6);

          _namespace = new NamespaceContext(_namespace, name, url);
        }

        return oldNamespace;
      }
    View Full Code Here

    Examples of com.caucho.xpath.NamespaceContext

          url = url.substring(6);
        */
       
        String localName = name.getLocalName();

        _outputNamespace = new NamespaceContext(_outputNamespace, localName, url);

        if (! localName.equals("xmlns")) {
          // xsl/04w3
          _matchNamespace = new NamespaceContext(_matchNamespace, localName, url);
        }
      }
    View Full Code Here

    Examples of com.consol.citrus.model.config.core.NamespaceContext

    */
    public class NamespaceContextSpringBeanConverter implements SpringBeanConverter<NamespaceContext> {

        @Override
        public NamespaceContext convert(SpringBean springBean) {
            NamespaceContext context = new ObjectFactory().createNamespaceContext();

            for (Property property : springBean.getProperties()) {
                if (property.getName().equals("namespaceMappings")) {
                    for (Entry entry : property.getMap().getEntries()) {
                        NamespaceContext.Namespace namespace = new NamespaceContext.Namespace();
                        namespace.setPrefix(entry.getKey());
                        namespace.setUri(entry.getValue());
                        context.getNamespaces().add(namespace);
                    }
                }
            }

            return context;
    View Full Code Here

    Examples of com.ibm.commons.xml.NamespaceContext

        /**
         * Return the NamespaceContext based on this XML element.
         * @return
         */
        public static NamespaceContext getNamespaceContext(final Element docElement) {
          return new NamespaceContext() {

          public String getNamespaceURI(String prefix) {
                    if (docElement == null) {
                        return null;
                    }
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

            assertEquals(1, sr.getNamespaceCount());
            assertEquals("ns", sr.getNamespacePrefix(0));
            assertEquals("http://foo", sr.getNamespaceURI(0));

            NamespaceContext nsCtxt = sr.getNamespaceContext();
            assertNotNull(nsCtxt);
            /* 28-Apr-2006, TSa: Alas, namespace access is only fully
             *   implemented in DOM Level 3 (JDK 1.5+)... thus, can't check:
             */
            /*
     
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

                +"</root>";
            XMLStreamReader2 sr = getNsReader(XML, true);

            assertEquals(START_ELEMENT, sr.next());
            assertEquals("root", sr.getLocalName());
            NamespaceContext curr = sr.getNamespaceContext();
            assertNotNull(curr);
            checkValidityOfNs1(curr);
            NamespaceContext nc1 = sr.getNonTransientNamespaceContext();
            assertNotNull(nc1);
            checkValidityOfNs1(nc1);

            assertEquals(START_ELEMENT, sr.next());
            assertEquals("branch", sr.getLocalName());
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

            // Ok, got the start element... is it ok?
            assertTrue(evt.isStartElement());
            StartElement se = evt.asStartElement();
            testEventWritability(se);

            NamespaceContext nsCtxt = se.getNamespaceContext();

            assertNotNull("StartElement.getNamespaceContext() should never return null", nsCtxt);
            // First, ones we shouldn't get:
            assertNull(nsCtxt.getPrefix("a"));
            assertNull(nsCtxt.getPrefix("http://foobar"));
            assertNull(nsCtxt.getNamespaceURI("b"));
            assertNull(nsCtxt.getNamespaceURI("http://my"));

            {
                Iterator it = nsCtxt.getPrefixes("http://foobar");
                // Specs don't specify if we should get null, or empty iterator
                assertTrue((it == null) || !it.hasNext());
                it = nsCtxt.getPrefixes("a");
                assertTrue((it == null) || !it.hasNext());
            }
            // Then ones we should:

            assertEquals("a", nsCtxt.getPrefix("ns:attrs"));
            assertEquals("", nsCtxt.getPrefix("http://my"));
            assertEquals("http://my", nsCtxt.getNamespaceURI(""));
            assertEquals("ns:attrs", nsCtxt.getNamespaceURI("a"));

            // Plus, let's check the other namespace access:
            Iterator it = se.getNamespaces();
            assertEquals(2, countElements(it));
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

            StartElement se = evt.asStartElement();
            testEventWritability(se);

            // Let's first check that it has 1 declaration:
            assertEquals(0, countElements(se.getNamespaces()));
            NamespaceContext nsCtxt = se.getNamespaceContext();
            assertNotNull("StartElement.getNamespaceContext() should never return null", nsCtxt);
            assertNull(nsCtxt.getPrefix("a"));
            assertNull(nsCtxt.getNamespaceURI("b"));

            // then first leaf:
            evt = er.nextEvent();
            assertTrue(evt.isStartElement());
            se = evt.asStartElement();
            assertEquals("leaf", se.getName().getLocalPart());
            assertEquals(1, countElements(se.getNamespaces()));
            assertEquals("x", se.getName().getNamespaceURI());
            nsCtxt = se.getNamespaceContext();
            assertEquals("x", nsCtxt.getNamespaceURI(""));
            assertEquals("", nsCtxt.getPrefix("x"));
            testEventWritability(se);

            evt = er.nextEvent();
            assertTrue(evt.isEndElement());
            testEventWritability(evt);

            // Ok, branch:
            evt = er.nextEvent();
            assertTrue(evt.isStartElement());
            se = evt.asStartElement();
            assertEquals("branch", se.getName().getLocalPart());
            assertEquals(2, countElements(se.getNamespaces()));
            nsCtxt = se.getNamespaceContext();
            assertEquals("a", nsCtxt.getPrefix("b"));
            assertEquals("b", nsCtxt.getNamespaceURI("a"));
            assertEquals("x", nsCtxt.getPrefix("url"));
            assertEquals("url", nsCtxt.getNamespaceURI("x"));
            testEventWritability(se);

            // second leaf
            evt = er.nextEvent();
            assertTrue(evt.isStartElement());
            se = evt.asStartElement();
            nsCtxt = se.getNamespaceContext();
            assertEquals("leaf", se.getName().getLocalPart());
            // only one declared in this particular element
            assertEquals(1, countElements(se.getNamespaces()));
            // but should still show the other bound ns from parent
            nsCtxt = se.getNamespaceContext();
            assertEquals("a", nsCtxt.getPrefix("c"));
            assertEquals("c", nsCtxt.getNamespaceURI("a"));
            assertEquals("x", nsCtxt.getPrefix("url"));
            assertEquals("url", nsCtxt.getNamespaceURI("x"));
            // ok, but how about masking:
            assertNull(nsCtxt.getPrefix("b"));

            // Ok, fine... others we don't care about:
            assertTrue(er.nextEvent().isEndElement());
        }
    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.