[jdom-interest] JDOM and XSL
Charlie Wu
daydayup at pabell.net
Wed Feb 7 00:54:03 PST 2001
Jan:
I tried to play with your code with some minor alterations .. and I believe
I am using the latest xalan-j(2.0) and xerces.jar.. however when I tried to
run my program I'm getting this error (in debugger, if I run it directly it
hangs).. any ideas?
javax.xml.transform.TransformerException: Namespace not supported by
SAXParser
at
org.apache.xml.utils.DefaultErrorHandler.fatalError(DefaultErrorHandler.java
:231)
at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFa
ctoryImpl.java:813)
at mco.costanalysis.combat.XML2HTML.transform(XML2HTML.java:60)
at mco.costanalysis.combat.XML2HTML.main(XML2HTML.java:85)
at sun.tools.agent.MainThread.runMain(Native Method)
at sun.tools.agent.MainThread.run(MainThread.java:45)
Thanks
Charlie
----- Original Message -----
From: "Jan Peter Hecking" <jhecking at netgaroo.com>
To: <jdom-interest at jdom.org>
Sent: Thursday, January 25, 2001 2:49 AM
Subject: Re: [jdom-interest] JDOM and XSL
> On Thu, Jan 25, 2001 at 08:21:59AM +0200, Marco.Mistroni at nokia.com wrote:
> > i have just started playing with JDOM and i have one question:
> > has anyone ever used JDOM along with XSL?? or, how can i use it???
>
> Basically I'm useing XSLT with JDOM as described in the JDOM
> FAQ. But instead of Xalan-J 1 I'm using the beta of the new Xalan-J
> 2 where the API is changed quite a bit. But switching back to
> Xalan-J 1 should be trivial. Below is the essential part of my code:
>
> ------------------------------ snip --------------------------------
> // JDOM
> import org.jdom.Document;
> import org.jdom.input.SAXBuilder;
> import org.jdom.output.XMLOutputter;
>
> // Xalan-J 2
> import javax.xml.transform.Result;
> import javax.xml.transform.Source;
> import javax.xml.transform.Templates;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.stream.StreamSource;
> import javax.xml.transform.stream.StreamResult;
>
> import java.io.File;
> import java.io.PipedInputStream;
> import java.io.PipedOutputStream;
>
> public Document transform( Document sourceDoc, File xslt )
> {
> XMLOutputter xmlOutputter = new XMLOutputter();
> SAXBuilder saxBuilder = new SAXBuilder();
> TransformerFactory transformerFactory =
TransformerFactory.newInstance();
> Templates stylesheet = transformerFactory.newTemplates(
> new StreamSource( xslt ) );
> Transformer processor = stylesheet.newTransformer();
>
> PipedInputStream sourceIn = new PipedInputStream();
> PipedOutputStream sourceOut = new PipedOutputStream( sourceIn );
> StreamSource source = new StreamSource( sourceIn );
>
> PipedInputStream resultIn = new PipedInputStream();
> PipedOutputStream resultOut = new PipedOutputStream( resultIn );
> StreamResult result = new StreamResult( resultOut );
>
> xmlOutputter.output( sourceDoc, sourceOut );
> sourceOut.close();
>
> processor.transform( source, result );
> resultOut.close();
>
> Document targetDoc = saxBuilder.build( resultIn );
> return targetDoc;
> }
> ------------------------------ snip --------------------------------
>
> Hope this helps,
> Jan
>
> --
> Jan Peter Hecking jhecking at netgaroo.com
> University of Rostock Department of Computer Science
> Homepage: http://www.informatik.uni-rostock.de/~jhecking
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XML2HTML.java
Type: application/octet-stream
Size: 2553 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010207/7d81fd40/XML2HTML.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: su.xsl
Type: text/xml
Size: 843 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010207/7d81fd40/su.xml
-------------- next part --------------
A non-text attachment was scrubbed...
Name: su.xml
Type: text/xml
Size: 2447 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010207/7d81fd40/su-0001.xml
More information about the jdom-interest
mailing list