• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xml-xml transformation exception

 
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I am trying to transform a xml to another xml via xslt in Weblogic8.1 with default transformer available, I am getting following exception.

; Line#: -1; Column#: -1
javax.xml.transform.TransformerException: Premature end of file.
at org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerIm
pl.java:739)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:715)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:1129)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:1107)
at com.toshiba.phoenix.ddc.ddcbatchprocess.XMLHelper.transformXML(XMLHel
per.java:70)
at com.toshiba.phoenix.ddc.ddcbatchprocess.DeviceDataCollectionWorkerThr
ead.run(DeviceDataCollectionWorkerThread.java:146)
at java.lang.Thread.run(Thread.java:534)

Here is the code for transformer:

Source inputXML= new StreamSource(in);
Source inputXSL = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream("DDCCommonDataEbridge.xslt"));
TransformerFactory tFact = TransformerFactory.newInstance();

Transformer tf = tFact.newTransformer(inputXSL);

Result result = new StreamResult(new BufferedOutputStream(new FileOutputStream(new File("test.xml"))));

tf.transform(inputXML,result);

[ August 26, 2005: Message edited by: Jignesh Patel ]
[ August 26, 2005: Message edited by: Jignesh Patel ]
 
Jignesh Patel
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moreover I have tried to implement inbuilt xlan processor with weblogic8.1
I got the following exception;
java.lang.ClassCastException
at weblogic.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1
531)
at weblogic.apache.xalan.xslt.XSLTEngineImpl.getSourceTreeFromInput(XSLT
EngineImpl.java:816)
at weblogic.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java
:390)
at com.toshiba.phoenix.ddc.ddcbatchprocess.XMLHelper.transformXML(XMLHel
per.java:90)
at com.toshiba.phoenix.ddc.ddcbatchprocess.DeviceDataCollectionWorkerThr
ead.run(DeviceDataCollectionWorkerThread.java:146)
at java.lang.Thread.run(Thread.java:534)

Here is the code:
XSLTInputSource source = new XSLTInputSource(in);

XSLTInputSource stylesheet= new XSLTInputSource(Thread.currentThread().getContextClassLoader().getResourceAsStream("DDCCommonDataEbridge.xslt"));
//System.out.println("test:"+stylesheet.getCharacterStream().read());

XSLTResultTarget target = new XSLTResultTarget(System.out);

And at the following line ClassCastException arises.

processor.process(source, stylesheet,target);
 
Jignesh Patel
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have identified the problem: before transformation, I used to pass inputstream object to SAXParser, so it was convert inputstream in SAX format, and during transformation I have coded by considering as common inputstream and that is where the problem is.

Now 1 more query: Is there any way of converting SAXResult object to inputstream object or XMLBeans object.
 
reply
    Bookmark Topic Watch Topic
  • New Topic