Package com.volantis.xml.namespace

Examples of com.volantis.xml.namespace.NamespacePrefixTracker


            XMLPipelineConfiguration configuration,
            EnvironmentInteraction environmentInteraction) {


        // factor a NamespacePrefixTracker
        NamespacePrefixTracker namespaceTracker =
                wrapper.getNamespaceFactory().createPrefixTracker();

        // factor an EnvironmentInteractionTracker
        EnvironmentFactory environmentFactory =
                EnvironmentFactory.getDefaultInstance();
View Full Code Here


        String partPrefix = (String)context.getProperty(PART_PREFIX_KEY);

        String responseNamespace = configuration.getResponseNamespaceURI();
        String responsePrefix = configuration.getResponseDefaultPrefixURI();

        NamespacePrefixTracker namespaceManager =
                context.getNamespacePrefixTracker();
        namespaceManager.startPrefixMapping(responsePrefix,
                                            responseNamespace);

        consumer.startPrefixMapping(responsePrefix, responseNamespace);

        // Get the qnames that are constant for this operation process
        String responseQName = SAXUtils.createPrefixedName(responsePrefix,
                                                           RESPONSE);
        String messageQName = SAXUtils.createPrefixedName(responsePrefix,
                                                          MESSAGE);

        consumer.startElement(responseNamespace, RESPONSE, responseQName,
                              new AttributesImpl());

        consumer.startElement(responseNamespace, MESSAGE, messageQName,
                              new AttributesImpl());

        // If the parts have a prefix we need to map them now.
        if (partPrefix != null) {
            namespaceManager.startPrefixMapping(partPrefix,
                                                partNamespace);

            consumer.startPrefixMapping(partPrefix, partNamespace);

        }

        for (int i = 0; i < message.size(); i++) {
            Part part = message.retrievePart(i);
            String partQName = SAXUtils.createPrefixedName(partPrefix,
                                                           part.getName());
            consumer.startElement(partNamespace, part.getName(), partQName,
                                  new AttributesImpl());

            Object value = part.getValue();
            if (value instanceof Element) {
                // This is a DOM Element. Use DOMToSAX.
                Node node = (Node)value;
                DOMToSAX dom2SAX = new DOMToSAX(node);

                ContextManagerProcess cup = new ContextManagerProcess(true);
                cup.setPipeline(getPipeline());
                cup.setNextProcess(consumer);
                dom2SAX.setContentHandler(cup);

                dom2SAX.parse();
            } else {
                // Just a bunch of characters.
                String chars = value.toString();
                consumer.characters(chars.toCharArray(), 0, chars.length());
            }
            consumer.endElement(partNamespace, part.getName(), partQName);
        }

        // If the parts have a prefix we need to unmap them now.
        if (partPrefix != null) {
            consumer.endPrefixMapping(partPrefix);
            namespaceManager.endPrefixMapping(partPrefix);
        }

        consumer.endElement(responseNamespace, MESSAGE, messageQName);
        consumer.endElement(responseNamespace, RESPONSE, responseQName);

        consumer.endPrefixMapping(responsePrefix);
        namespaceManager.endPrefixMapping(responsePrefix);
    }
View Full Code Here

        // The given name could be a prefixed name, so go through these
        // hoops to ensure that we register the variable against the
        // correct namespace (the namespace for no prefix is "no namespace"
        // according to http://www.w3.org/TR/xpath20/#id-variables - this
        // is modelled using the "default namespace" for variables)
        NamespacePrefixTracker namespacePrefixTracker =
                context.getNamespacePrefixTracker();
        ExpandedName name = namespacePrefixTracker.resolveQName(
                new ImmutableQName(variable), "");

        // Create a new TemplateExpressionValue
        TemplateExpressionValue initialValue = new TemplateExpressionValue(
                parameter, value, pipelineContext);
View Full Code Here

     * @return the expression context
     */
    private ExpressionContext createExpressionContext() {
        EnvironmentInteractionTracker eit =
                new SimpleEnvironmentInteractionTracker();
        NamespacePrefixTracker npt = new DefaultNamespacePrefixTracker();
        ExpressionContext context = ExpressionFactory.getDefaultInstance().
                createExpressionContext(eit, npt);
        return context;
    }
View Full Code Here

    /**
     * Ensures that a qualified variable reference can be evaluated
     * @throws Exception if an error occurs
     */
    public void testQualifiedVariableEvaluate() throws Exception {
        NamespacePrefixTracker manager = context.getNamespacePrefixTracker();
        manager.startPrefixMapping("p", "http://myNamespace");

        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("http://myNamespace",
                                          "var"),
                result);
View Full Code Here

    }
   
    public void testFunctionArgSequence() throws Exception {
        ImmutableExpandedName functionName =
                new ImmutableExpandedName("http://myNamespace", "test");
        NamespacePrefixTracker manager = context.getNamespacePrefixTracker();

        manager.startPrefixMapping("function",
                                   functionName.getNamespaceURI());

        context.registerFunction(
                functionName,
                new Function() {
View Full Code Here

   

    public void testExpressionWithFunction() throws Exception {
        ImmutableExpandedName functionName =
                new ImmutableExpandedName("http://myNamespace", "test");
        NamespacePrefixTracker manager = context.getNamespacePrefixTracker();

        manager.startPrefixMapping("function",
                                   functionName.getNamespaceURI());

        context.getCurrentScope().declareVariable(
                new ImmutableExpandedName("", "myVar"),
                result);
View Full Code Here

     * @throws Exception if an unexpected exception occurs
     */
    public void testFunctionThrowingExpressionException() throws Exception {
        ImmutableExpandedName functionName =
                new ImmutableExpandedName("http://myNamespace", "test");
        NamespacePrefixTracker manager = context.getNamespacePrefixTracker();

        manager.startPrefixMapping("function",
                                   functionName.getNamespaceURI());

        context.registerFunction(
                functionName,
                new Function() {
View Full Code Here

    // Javadoc inherited
    public void startPrefixMapping(String prefix, String uri)
            throws SAXException {

        // retrieve the NamespacePrefixTracker from the pipeline context
        NamespacePrefixTracker namespaceManager =
                getPipelineContext().getNamespacePrefixTracker();

        // forward this event to the tracker
        namespaceManager.startPrefixMapping(prefix, uri);

        // forward this event to the next process
        super.startPrefixMapping(prefix, uri);
    }
View Full Code Here

    }

    // Javadoc inherited
    public void endPrefixMapping(String prefix) throws SAXException {
        // retrieve the NamespacePrefixTracker from the pipeline context
        NamespacePrefixTracker namespaceManager =
                getPipelineContext().getNamespacePrefixTracker();

        // forward this event to the tracker
        namespaceManager.endPrefixMapping(prefix);

        // forward this event to the next process
        super.endPrefixMapping(prefix);
    }
View Full Code Here

TOP

Related Classes of com.volantis.xml.namespace.NamespacePrefixTracker

Copyright © 2018 www.massapicom. 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.