Package org.apache.cocoon.transformation

Examples of org.apache.cocoon.transformation.Transformer


                compiler.startDocument();

                XMLConsumer nextConsumer = compiler;
                NodeList transformations = DOMUtil.selectNodeList(copletConf,
                                                        "transformation/stylesheet");
                Transformer xslT = null;
                ArrayList transformers = new ArrayList();
                ComponentSelector selector = null;
                Request request = ObjectModelHelper.getRequest(this.objectModel);

                try {
                    if (transformations != null && transformations.getLength() > 0) {
                        selector = (ComponentSelector) this.manager.lookup(Transformer.ROLE + "Selector");
                        nextConsumer = new IncludeXMLConsumer(nextConsumer);
                        for(int k = transformations.getLength()-1; k >=0; k--) {
                            xslT = (Transformer)selector.select("xslt");
                            transformers.add(xslT);
                            xslT.setup(resolver,
                                       objectModel,
                                       DOMUtil.getValueOfNode(transformations.item(k)),
                                       new Parameters());
                            xslT.setConsumer(nextConsumer);
                            nextConsumer = xslT;
                        }
                        nextConsumer.startDocument();
                    }
                    boolean includeFragment = true;
                    boolean handlesParameters = DOMUtil.getValueAsBooleanOf(copletConf, "configuration/handlesParameters", true);
                    String size = p.getParameter("size", "max");
                    includeFragment = size.equals("max");
                    if (includeFragment == false) {
                        if (this.logger.isWarnEnabled() == true) {
                            this.logger.warn("Minimized coplet '"+copletID+"' not handled correctly.");
                        }
                    }
                    if ( includeFragment ) {
                        if (this.logger.isDebugEnabled() ) {
                            this.logger.debug("portal: Loading coplet " + copletID);
                        }
                        // add the parameters to the request attributes
                        Map info = new HashMap(3);
                        SessionContextImpl.copletInfo.set(info);
                        info.put(PortalConstants.COPLETINFO_PARAMETERS, p);
                        info.put(PortalConstants.COPLETINFO_PORTALURI, request.getRequestURI());
                        info.put(PortalConstants.COPLETINFO_STATUSPROFILE, loadedCoplet[7]);
                        XMLConsumer xc = new IncludeXMLConsumer(nextConsumer);
                        Source source = null;
                        try {
                            source = SourceUtil.getSource(resource,
                                                          null,
                                                          (handlesParameters == true ? p : null),
                                                          resolver);
                            resolver.toSAX(source, xc);
                        } finally {
                            resolver.release(source);
                        }

                        if (this.logger.isDebugEnabled()) {
                            this.logger.debug("portal: Loaded coplet " + copletID);
                        }
                    }
                       
                   
                    if (xslT != null) {
                        xslT.endDocument();
                        xslT = null;
                    }
                } finally {
                    SessionContextImpl.copletInfo.set(null);
                    if (selector != null) {
View Full Code Here


     * @param input Input document.
     */
    public final Document transform(String type, String source, Parameters parameters, Document input) {

        ComponentSelector selector = null;
        Transformer transformer = null;
        SourceResolver resolver = null;
        SAXParser parser = null;
        Source inputsource = null;

        Document document = null;
        try {
            selector = (ComponentSelector) this.manager.lookup(Transformer.ROLE+
                "Selector");
            assertNotNull("Test lookup of transformer selector", selector);

            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            assertNotNull("Test lookup of source resolver", resolver);

            parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
            assertNotNull("Test lookup of parser", parser);


            assertNotNull("Test if transformer name is not null", type);
            transformer = (Transformer) selector.select(type);
            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);

View Full Code Here

            Iterator transformerItt = this.transformers.iterator();
            Iterator transformerSourceItt = this.transformerSources.iterator();
            Iterator transformerParamItt = this.transformerParams.iterator();

            while ( transformerItt.hasNext() ) {
                Transformer trans = (Transformer)transformerItt.next();
                trans.setup(
                    environment,
                    environment.getObjectModel(),
                    (String)transformerSourceItt.next(),
                    (Parameters)transformerParamItt.next()
                );
View Full Code Here

    throws ProcessingException {
        XMLProducer prev = (XMLProducer)this.generator;

        Iterator itt = this.transformers.iterator();
        while ( itt.hasNext() ) {
            Transformer trans = (Transformer) itt.next();
            this.connect( environment, prev, trans );
            prev = trans;
        }

        // insert the serializer
View Full Code Here

            final int transformerSize = super.transformers.size();
            boolean continueTest = true;

            while (this.firstNotCacheableTransformerIndex < transformerSize
                    && continueTest) {
                final Transformer trans =
                    (Transformer)super.transformers.get(this.firstNotCacheableTransformerIndex);
                key = null;
                if (trans instanceof CacheableProcessingComponent) {
                    key = ((CacheableProcessingComponent)trans).getKey();
                    this.transformerIsCacheableProcessingComponent[this.firstNotCacheableTransformerIndex] = true;
View Full Code Here

            } else {
                validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.generator).generateValidity());
            }
        } else if (index <= firstNotCacheableTransformerIndex) {
            // test transformer
            final Transformer trans = (Transformer)super.transformers.get(index-1);
            if (this.transformerIsCacheableProcessingComponent[index-1]) {
                validity = ((CacheableProcessingComponent)trans).getValidity();
            } else {
                validity = CacheValidityToSourceValidity.createValidity(((Cacheable)trans).generateValidity());
            }
View Full Code Here

            Iterator transformerParamItt = this.transformerParams.iterator();

            int index = 1;

            while (transformerItt.hasNext()) {
                Transformer trans = (Transformer) transformerItt.next();

                time = System.currentTimeMillis();
                trans.setup(environment, environment.getObjectModel(),
                            (String) transformerSourceItt.next(),
                            (Parameters) transformerParamItt.next());
                this.data.setSetupTime(index++,
                                       System.currentTimeMillis()-time);
            }
View Full Code Here

            Iterator transformerParamItt = this.transformerParams.iterator();

            int index = 1;

            while (transformerItt.hasNext()) {
                Transformer trans = (Transformer) transformerItt.next();

                time = System.currentTimeMillis();
                trans.setup(environment, environment.getObjectModel(),
                            (String) transformerSourceItt.next(),
                            (Parameters) transformerParamItt.next());
                this.data.setSetupTime(index++,
                                       System.currentTimeMillis()-time);
            }
View Full Code Here

            Iterator transformerItt = this.transformers.iterator();
            Iterator transformerSourceItt = this.transformerSources.iterator();
            Iterator transformerParamItt = this.transformerParams.iterator();

            while ( transformerItt.hasNext() ) {
                Transformer trans = (Transformer)transformerItt.next();
                trans.setup(
                    environment,
                    environment.getObjectModel(),
                    (String)transformerSourceItt.next(),
                    (Parameters)transformerParamItt.next()
                );
View Full Code Here

                    next = connect;
                    prev.setConsumer(next);
                    prev = connect;
                }
                // Connect next component.
                Transformer trans = (Transformer) itt.next();
                next = trans;
                prev.setConsumer(next);
                prev = trans;
            }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.transformation.Transformer

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.