Examples of DOMBuilder


Examples of org.apache.cocoon.xml.dom.DOMBuilder

            assertNotNull("Test lookup of transformer", transformer);

            transformer.setup(new SourceResolverAdapter(resolver, this.manager),
                                  objectmodel, source, parameters);

            DOMBuilder builder = new DOMBuilder();
            transformer.setConsumer(new WhitespaceFilter(builder));

            assertNotNull("Test if input document is not null", input);
            DOMStreamer streamer = new DOMStreamer(transformer);
            streamer.stream(input);

            document = builder.getDocument();
            assertNotNull("Test for transformer document", document);

        } catch (ComponentException ce) {
            getLogger().error("Could not retrieve transformer", ce);
            ce.printStackTrace();
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

                          source);
            assertionsource = resolver.resolveURI(source);
            assertNotNull("Test lookup of assertion source",
                          assertionsource);

            DOMBuilder builder = new DOMBuilder();
            assertNotNull("Test if inputstream of the assertion source is not null",
                          assertionsource.getInputStream());

            parser.parse(new InputSource(assertionsource.getInputStream()),
                         new WhitespaceFilter(builder),
                         builder);

            assertiondocument = builder.getDocument();
            assertNotNull("Test if assertion document exists", assertiondocument);

        } catch (ComponentException ce) {
            getLogger().error("Could not retrieve generator", ce);
            fail("Could not retrieve generator: " + ce.toString());
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

     * @throws SAXException If a SAX exception occurs.
     */
    static public Document toDOM(Source source)
                                   throws SAXException, IOException,
                                          ProcessingException {
        DOMBuilder builder = new DOMBuilder();

        toSAX(source, builder);

        Document document = builder.getDocument();

        if (document==null) {
            throw new ProcessingException("Could not build DOM for '"+
                                          source.getURI()+"'");
        }
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

    public void startRecording()
    throws SAXException {
        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("BEGIN startRecording");
        }
        DOMBuilder builder = new DOMBuilder();
        this.addRecorder(builder);
        builder.startDocument();
        builder.startElement("", "cocoon", "cocoon", new AttributesImpl());

        this.sendStartPrefixMapping();

        if (this.getLogger().isDebugEnabled() == true) {
            this.getLogger().debug("END startRecording");
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

            this.getLogger().debug("BEGIN endRecording");
        }

        this.sendEndPrefixMapping();

        DOMBuilder builder = (DOMBuilder)this.removeRecorder();
        builder.endElement("", "cocoon", "cocoon");
        builder.endDocument();

        // Create Document Fragment
        final Document doc = builder.getDocument();
        final DocumentFragment recordedDocFrag = doc.createDocumentFragment();
        final Node root = doc.getDocumentElement();
        root.normalize();
        Node child;
        boolean appendedNode = false;
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

    throws ProcessingException {
        if (this.layoutDOM == null && this.profile != null) {
            try {
                Map portalLayouts = (Map)this.profile.get(PortalConstants.PROFILE_PORTAL_LAYOUTS);
                Map copletLayouts = (Map)this.profile.get(PortalConstants.PROFILE_COPLET_LAYOUTS);
                DOMBuilder builder = new DOMBuilder();
                builder.startDocument();
                PortalManager.streamLayoutProfile(builder, portalLayouts, copletLayouts, this.mediaType);
                builder.endDocument();
                this.layoutDOM = builder.getDocument();
            } catch (SAXException local) {
                throw new ProcessingException("Unable to get portal." + local, local);
            }
        }
    }
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

            try {
                String contextID = null;
                if (this.copletID != null && this.copletNumber != null) {
                    contextID = "coplet_"+copletID+"_"+copletNumber;
                }
                DOMBuilder builder = new DOMBuilder();
                builder.startDocument();
                portal.streamConfiguration(builder,
                                            this.portalURI,
                                            this.profileID,
                                            this.mediaType,
                                            contextID);
                builder.endDocument();
                this.configurationDOM = builder.getDocument();
            } catch (SAXException local) {
                throw new ProcessingException("Unable to get portal." + local, local);
            }
        }
    }
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

                        throw new SAXParseException(exc.getMessage(),
                                                    ev.location,
                                                    exc);
                    }
                } else {
                    DOMBuilder builder = new DOMBuilder();
                    builder.startDocument();
                    builder.startElement(NS,
                                         "set",
                                         "set",
                                         EMPTY_ATTRS);
                    execute(builder, jexlContext, jxpathContext,
                            startSet.next,
                            startSet.endSet);
                    builder.endElement(NS,
                                       "set",
                                       "set");
                    builder.endDocument();
                    Node node = builder.getDocument().getDocumentElement();
                    NodeList nodeList = node.getChildNodes();
                    value = nodeList;
                }
                jxpathContext.getVariables().declareVariable(startSet.var,
                                                             value);
                jexlContext.put(startSet.var, value);
                ev = startSet.endSet.next;
                continue;
            } else if (ev instanceof StartElement) {
                StartElement startElement = (StartElement)ev;
                StartDefine def =
                    (StartDefine)definitions.get(startElement.qname);
                if (def != null) {
                    Map attributeMap = new HashMap();
                    Iterator i = startElement.attributeEvents.iterator();
                    while (i.hasNext()) {
                        String attributeName;
                        Object attributeValue;
                        AttributeEvent attrEvent = (AttributeEvent)
                            i.next();
                        attributeName = attrEvent.localName;
                        if (attrEvent instanceof CopyAttribute) {
                            CopyAttribute copy =
                                (CopyAttribute)attrEvent;
                            attributeValue = copy.value;
                        } else if (attrEvent instanceof
                                   SubstituteAttribute) {
                            SubstituteAttribute substEvent =
                                (SubstituteAttribute)attrEvent;
                            if (substEvent.substitutions.size() == 1 &&
                                substEvent.substitutions.get(0) instanceof
                                Expression) {
                                Expression expr = (Expression)
                                    substEvent.substitutions.get(0);
                                Object val;
                                try {
                                    val =
                                        getValue(expr.compiledExpression,
                                                 jexlContext,
                                                 jxpathContext);
                                } catch (Exception e) {
                                    throw new SAXParseException(e.getMessage(),
                                                                ev.location,
                                                                e);
                                }
                                attributeValue = val;
                            } else {
                                StringBuffer buf = new StringBuffer();
                                Iterator ii = substEvent.substitutions.iterator();
                                while (ii.hasNext()) {
                                    Subst subst = (Subst)ii.next();
                                    if (subst instanceof Literal) {
                                        Literal lit = (Literal)subst;
                                        buf.append(lit.value);
                                    } else if (subst instanceof Expression) {
                                        Expression expr = (Expression)subst;
                                        Object val;
                                        try {
                                            val =
                                                getValue(expr.compiledExpression,
                                                         jexlContext,
                                                         jxpathContext);
                                        } catch (Exception e) {
                                            throw new SAXParseException(e.getMessage(),
                                                                        ev.location,
                                                                        e);
                                        }
                                        if (val == null) {
                                            val = "";
                                        }
                                        buf.append(val.toString());
                                    }
                                }
                                attributeValue = buf.toString();
                            }
                        } else {
                            throw new Error("this shouldn't have happened");
                        }
                        attributeMap.put(attributeName, attributeValue);
                    }
                    DOMBuilder builder = new DOMBuilder();
                    builder.startDocument();
                    builder.startElement(startElement.namespaceURI,
                                         startElement.localName,
                                         startElement.raw,
                                         EMPTY_ATTRS);
                    execute(builder, jexlContext, jxpathContext,
                            startElement.next,
                            startElement.endElement);
                    builder.endElement(startElement.namespaceURI,
                                       startElement.localName,
                                       startElement.raw);
                    builder.endDocument();
                    Node node = builder.getDocument().getDocumentElement();
                    MyVariables vars =
                        (MyVariables)jxpathContext.getVariables();
                    Map saveLocals = vars.localVariables;
                    vars.localVariables = new HashMap();
                    MyJexlContext localJexlContext =
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

        this.namespace = namespace;
        this.name = name;

        try {
            // FIXME: There must be an easier way to create a DOM element
            DOMBuilder builder = new DOMBuilder();

            builder.startDocument();
            builder.startPrefixMapping(NS_PREFIX, namespace);
            AttributesImpl attrs = new AttributesImpl();

            attrs.addAttribute(XMLNS_NS, NS_PREFIX, "xmlns:"+NS_PREFIX,
                               "NMTOKEN", namespace);
            builder.startElement(namespace, name, D_PREFIX+name, attrs);
            builder.endElement(namespace, name, D_PREFIX+name);
            builder.endPrefixMapping(NS_PREFIX);

            Document doc = builder.getDocument();

            this.value = doc.getDocumentElement();
        } catch (SAXException se) {
            // do nothing
        }
View Full Code Here

Examples of org.apache.cocoon.xml.dom.DOMBuilder

     */
    public void setValue(String value) {
        // this.value = value;

        try {
            DOMBuilder builder = new DOMBuilder();

            builder.startDocument();
            builder.startPrefixMapping(NS_PREFIX, namespace);
            AttributesImpl attrs = new AttributesImpl();

            attrs.addAttribute(XMLNS_NS, NS_PREFIX, "xmlns:"+NS_PREFIX,
                               "NMTOKEN", namespace);
            attrs.addAttribute("", "foo", "foo", "NMTOKEN", "bar");

            builder.startElement(namespace, name, D_PREFIX+name, attrs);

            builder.characters(value.toCharArray(), 0, value.length());

            builder.endElement(namespace, name, D_PREFIX+name);
            builder.endPrefixMapping(NS_PREFIX);
            builder.endDocument();

            Document doc = builder.getDocument();

            this.value = doc.getDocumentElement();
        } catch (SAXException se) {
            // do nothing
        }
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.