Return-Path: Delivered-To: apmail-xml-cocoon-users-archive@xml.apache.org Received: (qmail 21961 invoked by uid 500); 23 Jun 2001 19:55:41 -0000 Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-users@xml.apache.org Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 21796 invoked from network); 23 Jun 2001 19:55:40 -0000 Message-ID: From: Thorsten Mauch To: "'cocoon-users@xml.apache.org'" Subject: cocoon and xalan2 Date: Sat, 23 Jun 2001 21:49:37 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C0FC1D.A302B720" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N ------_=_NextPart_000_01C0FC1D.A302B720 Content-Type: text/plain; charset="iso-8859-1" Hi I using Coocon 1.8.2 with Xalan2. I use the XalanTransformer privided by Rick Knowles. I'am not sure if it's the best way to do so, coz in the actual source distribution the patch is not included. Anyway i found a small bug in the class. xsl:include doesn't work for relative pathes: i changed the line s.setSystemId(sheetBase); in s.setSystemId("file:///"+inBase); I'am not sure if this doesn't have undesired side efectts, coz my knoewlage about xalan tends to sero. But it works :) To avoid naming confilics i renamed the XalanTransformer to Xalan2Transformer. If this is still the best way to use Xalan2 with cocoon maybe somebody can commit this class to the CVS. Thanx Thorsten <> ------_=_NextPart_000_01C0FC1D.A302B720 Content-Type: application/octet-stream; name="Xalan2Transformer.java" Content-Disposition: attachment; filename="Xalan2Transformer.java" package org.apache.cocoon.transformer; import java.io.*; import java.net.*; import java.util.*; import org.w3c.dom.*; import javax.xml.transform.*; // NEW import javax.xml.transform.dom.*; // NEW import javax.xml.transform.stream.*; // NEW import org.apache.cocoon.*; import org.apache.cocoon.parser.*; import org.apache.cocoon.processor.*; import org.apache.cocoon.framework.*; import org.xml.sax.InputSource; import org.xml.sax.EntityResolver; import org.xml.sax.SAXException; /** * This class implements the transformer interface for the Apache * Xalan XSLT processor. * * @author Rick Knowles * @version $Revision: 1.14 $ $Date: 2000/11/20 22:37:25 $ */ public class Xalan2Transformer extends AbstractActor implements Transformer, Status { Parser parser; public void init(Director director) { super.init(director); this.parser = (Parser) director.getActor("parser"); } public Document transform(Document in, String inBase, Document sheet, String sheetBase, Document out, Dictionary params) throws Exception { Source s = new DOMSource(sheet); // NEW=20 s.setSystemId("file:///"+inBase); // NEW TransformerFactory factory = TransformerFactory.newInstance(); // NEW //factory.setURIResolver(new myUriResolver(inBase)); javax.xml.transform.Transformer transformer = factory.newTransformer(s);// NEW //XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new XMLParser(parser)); // REMOVED Enumeration enum = params.keys(); while (enum.hasMoreElements()) { String name = (String) enum.nextElement(); String value = (String)params.get(name); transformer.setParameter(name, value); // NEW //processor.setStylesheetParam(name,processor.createXString(value)); //REMOVED } //transformer.setURIResolver(new myUriResolver()); //XSLTInputSource i = new XSLTInputSource(in); // REMOVED Source i = new DOMSource(in); // NEW // inBase needed for document function with 2 args to resolve correctly i.setSystemId(inBase); //XSLTResultTarget o = new XSLTResultTarget(out); // REMOVED Result o = new DOMResult(out); // NEW //processor.process(i, s, o); // REMOVED transformer.transform(i, o); // NEW return out; } public String getStatus() { return "Xalan2 XSLT Processor"; } } ------_=_NextPart_000_01C0FC1D.A302B720 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. To unsubscribe, e-mail: For additional commands, e-mail: ------_=_NextPart_000_01C0FC1D.A302B720--