This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Saxon question..


>
> Not sure if this is the best place to ask this, but I know
> the author of
> Saxon frequents this list. Basically, I want to know if Saxon
> has built in
> ability to handle XML and XSL in various manners?
> Specifically, I have the
> need to do one of two things with XML/XSL:
>
> 1) Pass in an XML and XSL, and get out an XML.
>
> 2) Pass in an XML and XSL, and get out a Document (Jaxp
> compatible) object, already parsed.

You can get a DOM Document as the result of your transformation by supplying
a DOMResult object instead of a StreamResult.

If the DOMResult already contains a Document object, Saxon will populate
that Document object. If it doesn't, Saxon will build its own. Saxon's
implementation of the DOM is rather minimal, so if you want to use DOM
interfaces seriously, it's probably best to use a product such as Xerces and
Crimson to create the Document object.

Mike Kay

>
> The first one, I have working using a little bit of Java code:
>
>   public static void transformXMLWithXSL(File sourceXML, File
> sourceXSL,
> File target)
>   {
>     StreamSource xslStream = new StreamSource(sourceXSL);
>     StreamSource xmlStream = new StreamSource(sourceXML);
>
>     try
>     {
>       Templates templates = tFactory.newTemplates(xslStream);
>       Transformer transformer = templates.newTransformer();
>       transformer.transform(xmlStream, new StreamResult(new
> FileOutputStream(target)));
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace(System.out);
>     }
>   }
>
> I don't know if this is the best way to do this, but it does
> work. I am
> attempting to create a simple API that any of our
> applications can use to
> allow conversion of one XML file format into our own format.
> Basically, we
> will provide a "hub" to convert any format to our own format
> so that we can
> more easily use our existing code to manipulate the incoming
> xml formats. We
> have different software apps exporting their own but similar
> formats. I am
> sure this is common to many of you. We will also like to use
> FO eventually
> to produce PDF and RTF output files.
>
> So before I go reinvent the wheel, does Saxon have built in
> API calls to do
> this already? Or does it just provide the engine to transform?
>
> Thanks.
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]