Manage this page

0. Feedback

1. Display

Java Links

1. Notes on java logging api

2. java forums from sun

142 api

142 api Cheat sheat

XSLT links

1. xslt theory/samples from w3.org


TransformerFactory tf = TransformerFactory.newInstance();

This is the entry point for getting an xslt "Transformer" object to do a transform.


Transformer t 
  = tf.newTransformer(
       new StreamSource(
             new StringReader(xsltString)));
DOMSource
SAXSource
StreamSource 
File
InputStream
Reader
a string representing a URL 

Notice a string is not a stream source directly. If you do pass a string it will be thought of as a url and a url look up will be done


new StreamSource(new StringReader(yourstring));

Notice StringBufferInputStream is deprecated.


   public static void transform(String xmlString, 
                     String xsltString, 
                     Writer outputWriter)
   throws TransformException
   {
      try
     {
         TransformerFactory tf = TransformerFactory.newInstance();
       
         Transformer t = tf.newTransformer(
             new StreamSource(
               new StringReader(xsltString)));
         
         t.transform(new StreamSource( 
                   new StringReader(xmlString)),
                     new StreamResult(outputWriter));
     }
      catch(TransformerConfigurationException x)
     {
         throw new TransformException("Error:xslt not properly configured.",x);
     }
      catch(TransformerException x)
     {
         throw new TransformException("Error:xslt transformation error.",x);
     }
   }