[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problem with SimpleTransform servlet

Subject: RE: Problem with SimpleTransform servlet
From: "Duffey, Kevin" <KDuffey@xxxxxxxxxxxx>
Date: Thu, 18 Oct 2001 13:47:42 -0700
xalan simpletransform
I created a very simple static method that allows you to pass in the source
XML, transform XSL, and target XML file name and it will do this for you
using Saxon or Xalan (I recommend Saxon..much faster). That be helpful for
you? Then you don't need to create another servlet, you just call the static
transform method from your first servlet.


> -----Original Message-----
> From: Karen Fox [mailto:kfox@xxxxxxxxx]
> Sent: Thursday, October 18, 2001 12:25 PM
> To: XSL List
> Subject:  Problem with SimpleTransform servlet
> 
> 
> I'm using the Xalan SimpleTransform servlet to transform an XML file
> into another XML file.  It appears to be working as far as 
> creating the
> new file, but all it writes is the header data.  The rest is blank and
> the file appears to be open because I can't delete it without 
> restarting
> JRun.
> 
> I'm using Xalan 2.1.0 and the SimpleTransform code is below.  We
> modified it slightly so we could call it from another servlet.
> 
> // Imported TraX classes
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.stream.StreamSource;
> import javax.xml.transform.stream.StreamResult;
> import javax.xml.transform.TransformerException;
> import javax.xml.transform.TransformerConfigurationException;
> 
> 
> // Imported java classes
> import java.io.FileOutputStream;
> import java.io.FileNotFoundException;
> import java.io.IOException;
> 
> /**
>  *  Use the TraX interface to perform a transformation in the simplest
> manner possible
>  *  (3 statements).
>  */
> public class SimpleTransform2
> {
>         public static void main(String args[])
>         {
>         }
> 
>         public void transform(String xmlFile, String xslFile, String
> outFile)
>     throws TransformerException, TransformerConfigurationException, 
>            FileNotFoundException, IOException
>   {  
> 
>         System.out.println("Entering transform");
>   // Use the static TransformerFactory.newInstance() method to
> instantiate 
>   // a TransformerFactory. The javax.xml.transform.TransformerFactory 
>   // system property setting determines the actual class to 
> instantiate
> --
>   // org.apache.xalan.transformer.TransformerImpl.
>         TransformerFactory tFactory = 
> TransformerFactory.newInstance();
>         
>         // Use the TransformerFactory to instantiate a 
> Transformer that
> will
> work with  
>         // the stylesheet you specify. This method call also processes
> the
> stylesheet
>   // into a compiled Templates object.
>         Transformer transformer = tFactory.newTransformer(new
> StreamSource(xslFile));
> 
>         // Use the Transformer to apply the associated 
> Templates object
> to an
> XML document
>         // (foo.xml) and write the output to a file (foo.out).
>         transformer.transform(new StreamSource(xmlFile), new
> StreamResult(new
> FileOutputStream(outFile)));
>         
>         //System.out.println("************* The result is in 
> " + outFile
> +
> "*************");
>   }
> }
> 
> This is all that prints out:
> <?xml version="1.0" encoding="UTF-8"?>
> <ROWSET xmlns:fo="http://www.w3.org/1999/XSL/Format"/>
> 
> I'd appreciate any suggestions of what else I can try to fix this. 
> Thank you.
> 
> Karen Fox
> The MITRE Corporation
> kfox@xxxxxxxxx
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.