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

            fel.getContext().set("$page_content", validXml);
            Document doc = builder.parse(new ByteArrayInputStream(validXml.getBytes()));
            XPathFactory xfactory = XPathFactoryImpl.newInstance();
            XPath xpathParser = xfactory.newXPath();
            //设置命名空间
            xpathParser.setNamespaceContext(new NamespaceContext() {
                public String getPrefix(String uri) {
                    throw new UnsupportedOperationException();
                }
                public Iterator<?> getPrefixes(String uri) {
                    throw new UnsupportedOperationException();
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

            final String expectedDigestAlgorithm = binding.getAlgorithmSuite().getDigest();
            final String expectedCanonAlgorithm  = binding.getAlgorithmSuite().getInclusiveC14n();
               
            XPathFactory factory = XPathFactory.newInstance();
            XPath xpath = factory.newXPath();
            final NamespaceContext nsContext = this.getNamespaceContext();
            xpath.setNamespaceContext(nsContext);
           
            // Signature Algorithm
            final XPathExpression sigAlgoExpr =
                xpath.compile("/s:Envelope/s:Header/wsse:Security/ds:Signature/ds:SignedInfo"
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

        // TODO: This method can be removed when runOutInterceptorAndValidateSamlTokenAttached
        // is cleaned up.
        private void verifySignatureCoversAssertion(Document signedDoc, String assertionId) throws Exception {
            XPathFactory factory = XPathFactory.newInstance();
            XPath xpath = factory.newXPath();
            final NamespaceContext nsContext = this.getNamespaceContext();
            xpath.setNamespaceContext(nsContext);
           
            // Find the SecurityTokenReference for the assertion
            final XPathExpression strExpr = xpath.compile(
                "/s:Envelope/s:Header/wsse:Security/wsse:SecurityTokenReference/wsse:KeyIdentifier");
           
            final NodeList strKeyIdNodes =
                (NodeList) strExpr.evaluate(signedDoc, XPathConstants.NODESET);
           
            String strId = null;
            for (int i = 0; i < strKeyIdNodes.getLength(); i++) {
                Node keyIdNode = (Node) strKeyIdNodes.item(i);
                String strKey = keyIdNode.getTextContent();
                if (strKey.equals(assertionId)) {
                    Node strNode = (Node) keyIdNode.getParentNode();
                    strId = strNode.getAttributes().
                        getNamedItemNS(nsContext.getNamespaceURI("wsu"), "Id").getNodeValue();
                    break;
                }
            }
            assertNotNull("SecurityTokenReference for " + assertionId + " not found in security header.", strId);
           
    View Full Code Here

    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

             */
            String xsiTypeQname = root.getAttributeValue(XmlConstants.XSI_NS, "type");
            if (xsiTypeQname != null) {
                Matcher m = QNAME_PATTERN.matcher(xsiTypeQname);
                if (m.matches()) {
                    NamespaceContext nc = root.getNamespaceContext();
                    this.xsiType = new QName(nc.getNamespaceURI(m.group(1)), m.group(2), m.group(1));
                } else {
                    this.xsiType = new QName(this.namespace, xsiTypeQname, "");
                }
            }
        }
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

            if (prefix != null) {
                return null;
            } else {
               
                // Find an available prefix and bind it to the given uri
                NamespaceContext nsc = writer.getNamespaceContext();
                for (int i=1; ; i++) {
                    prefix = "ns" + i;
                    if (nsc.getNamespaceURI(prefix) == null) {
                        break;
                    }
                }
                writer.setPrefix(prefix, uri);
                return prefix;
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

                        // Use the prefix already bound to the given uri
                        return prefix + ":" + qname.getLocalPart();
                    } else {
                       
                        // Find an available prefix and bind it to the given uri
                        NamespaceContext nsc = writer.getNamespaceContext();
                        for (int i=1; ; i++) {
                            prefix = "ns" + i;
                            if (nsc.getNamespaceURI(prefix) == null) {
                                break;
                            }
                        }
                        writer.setPrefix(prefix, uri);
                        writer.writeNamespace(prefix, uri);
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

                    if (prefix != null) {
                        return;
                    } else {
                       
                        // Find an available prefix and bind it to the given uri
                        NamespaceContext nsc = writer.getNamespaceContext();
                        for (int i=1; ; i++) {
                            prefix = "ns" + i;
                            if (nsc.getNamespaceURI(prefix) == null) {
                                break;
                            }
                        }
                        writer.setPrefix(prefix, uri);
                    }
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

            if (prefix != null) {
                return null;
            } else {

                // Find an available prefix and bind it to the given URI
                NamespaceContext nsc = writer.getNamespaceContext();
                for (int i=1; ; i++) {
                    prefix = "ns" + i;
                    if (nsc.getNamespaceURI(prefix) == null) {
                        break;
                    }
                }
                writer.setPrefix(prefix, uri);
                return prefix;
    View Full Code Here

    Examples of javax.xml.namespace.NamespaceContext

          Element inlineSimpleType = XDOMUtil.getFirstChildElementNS(
              restrictionEl, XmlSchema.SCHEMA_NS, "simpleType");

          if (restrictionEl.hasAttribute("base")) {
            NamespaceContext ctx = NodeNamespaceContext.getNamespaceContext(restrictionEl);
            restriction.baseTypeName = getRefQName(restrictionEl
                .getAttribute("base"), ctx);
          } else if (inlineSimpleType != null) {

            restriction.baseType = handleSimpleType(schema,
    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.