Hi Phillip,

>When I try to do a xsl transformation in dom4j, the following exception is
>raised.  The code that does the transformation follows the exception.  If I
>do a command line transformation with org.apache.xalan.xslt.Process
(version
>xalan-j_1_2_2) with the same files, all is well.

xalan needs xerces _in front_ of classpath. JaXP is normally configured to
use crimson so you have to put xerces _before_  jaxp. 
I recommend saxon for commandline operation, because it's faster and more
comfortable to use. You have to change the System property
javax.xml.transform.TransformerFactory
in order to use another Stylesheet processor with JaXP-driven Java
applications. See JaXP documentation for more information.


>  I am using the same
>version of xerces and xalan for both transformations (commandline and
>dom4j).
> 
>public static void process(String xmlFileName,String xslFileName) throws
>Exception {
>        //create doc
>        SAXReader reader = new SAXReader();
>        Document document =  reader.read(xmlFileName);
>        // load the transformer
>        TransformerFactory factory = TransformerFactory.newInstance();
>        Transformer transformer = factory.newTransformer( 
>            new StreamSource( xslFileName )
>        );
>        // now lets create the TRaX source and result
>        // objects and do the transformation
>        Source source = new DocumentSource( document );
>        DocumentResult result = new DocumentResult();
>        transformer.transform( source, result );
>        OutputFormat format = new OutputFormat();
>        // output the transformed document
>        Document transformedDoc = result.getDocument();
>        XMLWriter    writer = new XMLWriter( System.out, format );
>        writer.write( transformedDoc);

So far as I see is your code ok. It seems to me more a problem of your
stylesheet processor. You should always check your stylesheet at command line to
check if their are any error and if it works as it should. This QA method save
time when you use it in your application code.

Have a nice day.

Toby

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net

--
GMX Tipp:

Machen Sie Ihr Hobby zu Geld bei unserem Partner 1&1!
http://profiseller.de/info/index.php3?ac=OM.PS.PS003K00596T0409a


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to