Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] JDOM + XSLT

himank gupta

2005-09-28


Hi all..
 
With the following code for transforming a xml file to html
 
 public Document transform(Document sourceDoc, File stylesheetFile)
 {
  
  // Set up the XSLT stylesheet for use with Xalan-J 2
    
  TransformerFactory transformerFactory = TransformerFactory.newInstance();
  Templates stylesheet = transformerFactory.newTemplates(new StreamSource(stylesheetFile));
  Transformer processor = stylesheet.newTransformer();
 
 //Output the Document to File
  FileOutputStream sourceOut = new FileOutputStream(new File("c:\\in.xml"));
  XMLOutputter xmlOutputter = new XMLOutputter();
  xmlOutputter.output(sourceDoc, sourceOut);
  sourceOut.close();
 
 //Take input Stream
  FileInputStream sourceIn = new FileInputStream(new File("c:\\in.xml"));
  StreamSource source = new StreamSource(sourceIn);
 
 //Make Output Stream
  FileOutputStream resultOut = new FileOutputStream("c:\\out.html");
  StreamResult result = new StreamResult(resultOut);
       
 // Feed the resultant I/O stream into the XSLT processor
   processor.transform(source, result);
   resultOut.close();
    }
 
I get this exception
 
    A '(' character or an element type is required in the declaration of element type "JavaXML:Title".
 
But if i am transforming without jdom that is by using org.apache....Process class from console the transformation works fine.
 
Regards
Himank Gupta.


Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.