Package com.volantis.xml.pipeline.sax

Examples of com.volantis.xml.pipeline.sax.XMLProcess


        DefaultXMLPipelineProcess outerPipeline =
                new DefaultXMLPipelineProcess(pipeline.getPipelineContext());

        XMLPipelineProcess xmlProcess =
                (XMLPipelineProcess)pipeline.getPipelineProcess();
        XMLProcess next = xmlProcess.getNextProcess();
        outerPipeline.setNextProcess(next);

        outerPipeline.addTailProcess(wrapper.createContextUpdatingProcess());

        outerPipeline.addTailXMLPipelineProcess(xmlProcess);

        final XMLProcess cap =
            wrapper.createContextAnnotatingProcess(setBaseURIOnRoot);
        outerPipeline.addTailProcess(cap);

        return new XMLPipelineFilterAdapter(outerPipeline) {
            // javadoc inherited from the XMLReader interface
            public void parse(InputSource input)
                    throws IOException,
                    SAXException {
                super.parse(input);
                cap.stopProcess();
            }
        };
    }
View Full Code Here


                                                "never be called.");
    }

    // javadoc inherited from ContentHandler interface
    public void startDocument() throws SAXException {
        XMLProcess consumer = getConsumerProcess();
        if (null != consumer) {
            consumer.startDocument();
        }
    }
View Full Code Here

        }
    }

    // javadoc inherited from ContentHandler interface
    public void endDocument() throws SAXException {
        XMLProcess consumer = getConsumerProcess();
        if (null != consumer) {
            consumer.endDocument();
        }
    }
View Full Code Here

        }
    }

    // javadoc inherited from ContentHandler interface
    public void setDocumentLocator(Locator locator) {
        XMLProcess consumer = getConsumerProcess();
        if (null != consumer) {
            consumer.setDocumentLocator(locator);
        }
    }
View Full Code Here

    }

    // javadoc inherited from ContentHandler interface
    public void startPrefixMapping(String prefix, String uri)
            throws SAXException {
        XMLProcess consumer = getConsumerProcess();
        if (null != consumer) {
            consumer.startPrefixMapping(prefix, uri);
        }
    }
View Full Code Here

        }
    }

    // javadoc inherited from ContentHandler interface
    public void endPrefixMapping(String prefix) throws SAXException {
        XMLProcess consumer = getConsumerProcess();
        if (null != consumer) {
            consumer.endPrefixMapping(prefix);
        }
    }
View Full Code Here

     * @param message The Message to forward.
     */
    private void forwardMessageAsXML(Message message)
            throws SAXException, IOException {

        XMLProcess consumer = getNextProcess();

        XMLPipelineContext context = getPipelineContext();

        String partNamespace = (String)
                context.getProperty(PART_NAMESPACE_URI_KEY);
        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

        super.startProcess();
    }

    // javadoc inherited
    public void stopProcess() throws SAXException {
        XMLProcess consumer = getConsumerProcess();
        if (consumer != null) {
            consumer.endDocument();
        }
        super.stopProcess();
    }
View Full Code Here

     * We must generate a start document event before any other event is seen.
     * @throws SAXException
     */
    protected void generateStartDocument() throws SAXException {
        if (!generatedStartDocumentEvent) {
            XMLProcess consumer = getConsumerProcess();
            if (consumer != null) {
                ContextWrapperLocator locator =
                        new ContextWrapperLocator(getPipelineContext());
                consumer.setDocumentLocator(locator);
                consumer.startDocument();
                generatedStartDocumentEvent = true;
            }
        }
    }
View Full Code Here

        configuration.setRecordPerEventLocation(true);
        recorder = factory.createSAXRecorder(configuration);

        recordingHandler = recorder.getContentHandler();
        if (pipeline != null) {
            XMLProcess cap = new ContextAnnotatingProcess(true);
            cap.setPipeline(pipeline);
            XMLHandlerAdapter adapter = new XMLHandlerAdapter();
            adapter.setContentHandler(recordingHandler);
            cap.setNextProcess(adapter);
            cap.startProcess();

            streamAnnotatingProcess = cap;
            recordingHandler = streamAnnotatingProcess;
        }
    }
View Full Code Here

TOP

Related Classes of com.volantis.xml.pipeline.sax.XMLProcess

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.