Package org.apache.cocoon.xml

Examples of org.apache.cocoon.xml.IncludeXMLConsumer


                Node n = nodeList[i];
                //TODO: should this take stripRoot into account?
                executeDOM(consumer, n);
            }
        } else if (val instanceof XMLizable) {
            IncludeXMLConsumer includer = new IncludeXMLConsumer(consumer);
            includer.setIgnoreRootElement(stripRoot);
            ((XMLizable) val).toSAX(includer);
        } else {
            char[] ch = val == null ? ArrayUtils.EMPTY_CHAR_ARRAY : val
                    .toString().toCharArray();
            consumer.characters(ch, 0, ch.length);
View Full Code Here


    /**
     * dump a DOM document, using an IncludeXMLConsumer to filter out start/end document events
     */
    public static void executeDOM(final XMLConsumer consumer, Node node, boolean stripRoot)
            throws SAXException {
        IncludeXMLConsumer includer = new IncludeXMLConsumer(consumer);
        includer.setIgnoreRootElement(stripRoot);
        DOMStreamer streamer = new DOMStreamer(includer);
        streamer.stream(node);
    }
View Full Code Here

                    ServiceManager serviceManager = executionContext.getServiceManager();
                    SAXParser parser = null;
                    try {
                        parser = (SAXParser) serviceManager.lookup(SAXParser.ROLE);
                        InputSource source = new InputSource(new ByteArrayInputStream(val.toString().getBytes()));
                        IncludeXMLConsumer includeConsumer = new IncludeXMLConsumer(consumer);
                        includeConsumer.setIgnoreRootElement(stripRoot);
                        parser.parse(source, includeConsumer);
                    } finally {
                        serviceManager.release(parser);
                    }
                }
View Full Code Here

            XMLDeserializer deserializer = null;

            try {
                deserializer = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
                if (embed)
                    deserializer.setConsumer(new IncludeXMLConsumer(this.xmlConsumer));
                else
                    deserializer.setConsumer(this.xmlConsumer);
                deserializer.deserialize(fragment);
            } catch (ComponentException ce) {
                getLogger().debug("Could not retrieve XMLDeserializer component",
View Full Code Here

                String mimeType = null;
                if ( null != this.configurationParameters ) {
                    mimeType = this.configurationParameters.getParameter("mime-type", mimeType);                   
                }
                if ( this.compiling ) {
                    SourceUtil.toSAX(source, mimeType, new IncludeXMLConsumer(this.contentHandler, this.lexicalHandler));
                } else {
                    SourceUtil.toSAX(source, mimeType, this.filter);
                }
            }
View Full Code Here

                String mimeType = null;
                if ( null != this.configurationParameters ) {
                    mimeType = this.configurationParameters.getParameter("mime-type", mimeType);                   
                }
                if ( this.compiling ) {
                    SourceUtil.toSAX(source, mimeType, new IncludeXMLConsumer(this.contentHandler, this.lexicalHandler));
                } else {
                    SourceUtil.toSAX(source, mimeType, this.filter);
                }
            }
View Full Code Here

        attributes.addAttribute("", PROPERTY_TYPE_ATTR_NAME,
                                PROPERTY_TYPE_ATTR_NAME, "CDATA", "live");
        this.contentHandler.startElement(SOURCE_NS, PROPERTIES_NODE_NAME,
                                         PROPERTIES_NODE_QNAME, attributes);

        IncludeXMLConsumer consumer = new IncludeXMLConsumer(this.contentHandler);

        for (int i = 0; i<properties.length; i++) {
            property = properties[i];

            this.contentHandler.startPrefixMapping("",
View Full Code Here

        try {
            inspector = (SourceInspector) this.manager.lookup(SourceInspector.ROLE);

            SourceProperty[] properties = inspector.getSourceProperties(source);
            IncludeXMLConsumer consumer = new IncludeXMLConsumer(this.contentHandler);

            for (int i = 0; i<properties.length; i++) {
                this.contentHandler.startPrefixMapping("", properties[i].getNamespace());
                properties[i].toSAX(consumer);
                this.contentHandler.endPrefixMapping("");
View Full Code Here

    public void generate() throws IOException, SAXException, ProcessingException {
        xmlConsumer.startDocument();

        if (this.elementName != null) {
            xmlConsumer.startElement("", this.elementName, this.elementName, new AttributesImpl());
            XMLUtils.valueOf(new IncludeXMLConsumer(xmlConsumer), this.attrObject);
            xmlConsumer.endElement("", this.elementName, this.elementName);
        } else {
            XMLUtils.valueOf(new IncludeXMLConsumer(xmlConsumer), this.attrObject);
        }
       
        xmlConsumer.endDocument();
    }
View Full Code Here

    private void stream() throws SAXException  {
        if (attributeName != null)  {
            Object node = session.getAttribute(attributeName);
            if (node != null)  {
                getLogger().debug("Start streaming");
                XMLUtils.valueOf(new IncludeXMLConsumer(super.xmlConsumer), node);
            } else {
                getLogger().error("No attribute " + attributeName + " in session");
            }
        } else {
            getLogger().error("No "+ ATTRIBUTE_NAME + " parameter specified");
View Full Code Here

TOP

Related Classes of org.apache.cocoon.xml.IncludeXMLConsumer

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.