Package org.apache.cocoon.xml.dom

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


            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

                        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

        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

     */
    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

     *
     * @param values
     */
    public void setValue(NodeList values) {
        try {
            DOMBuilder builder = new DOMBuilder();

            builder.startDocument();
            builder.startElement(namespace, name, name, new AttributesImpl());

            DOMStreamer stream = new DOMStreamer(builder);

            for (int i = 0; i<values.getLength(); i++)
                stream.stream(values.item(i));

            builder.endElement(namespace, name, name);
            builder.endDocument();

            Document doc = builder.getDocument();

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

     * Appends children representing the object's state to the given node by using
     * the results of <code>toSAX()</code>.
     */
    public void toDOM(Node node) throws Exception
    {
        DOMBuilder builder = new DOMBuilder(node);
        this.toSAX(builder);
    }
View Full Code Here

    throws SAXException {
        //only build the DOM tree if session is available
        if (name.equalsIgnoreCase(rootElement) && sessionAvailable)  {
          getLogger().debug("WriteSessionTransformer: start building DOM tree");
          buildDom = true;
          builder = new DOMBuilder(parser);
          builder.startDocument();
          launchStoredMappings();
          builder.startElement(uri,name,raw,attributes);
        } else if (buildDom)  {
          builder.startElement(uri,name,raw,attributes);
View Full Code Here

    protected DOMBuilder builder;


    public AbstractDOMTransformer() {
        super();
        this.builder = new DOMBuilder(this);
    }
View Full Code Here

            extractLevel++;
            fragmentID++;
            getLogger().debug("FragmentExtractorTransformer extractLevel now " + extractLevel + ".");

            // Start the DOM document
            this.currentBuilder = new DOMBuilder();
            this.currentBuilder.startDocument();
            Iterator itt = prefixMap.entrySet().iterator();
            while (itt.hasNext()) {
                Map.Entry entry = (Map.Entry)itt.next();
                this.currentBuilder.startPrefixMapping(
View Full Code Here

TOP

Related Classes of org.apache.cocoon.xml.dom.DOMBuilder

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.