Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2008, 09:49 PM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default xml-xslt tranformation

Hi,
i am doing an xsl transformation
i have my xml,xsl and the java class in same folder when i run this code from java class its working fine but when use the same in a webapplication deployed in tomcat i am getting the below error.

CODE:

StreamSource source = new StreamSource("abc.xml")
StreamSource stylesource = new StreamSource("abc.xsl"); TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(stylesource); StreamResult result = new StreamResult(System.out);

 StringWriter sw = new StringWriter();
transformer.transform(source, new StreamResult(sw));

String sReturn = sw.toString();


Exception:
ERROR: 'C:\Documents and Settings\hp.ln\Desktop\apache-tomcat-6.0.16\bin\abc.xsl (The system cannot find the file specified)'
FATAL ERROR: 'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationExcept ion: Could not compile stylesheet
    at com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl.newTemplates(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl.newTransformer(Unknown Source)


pls anyone sort out my prob .Thanks in ADV---Raj

 
Old September 17th, 2008, 03:58 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

new StreamSource("abc.xml")

It's not a good idea to use a relative URI as an argument to "new StreamSource()". The specification doesn't say what it's relative to, and therefore the effect is completely unpredictable. It will probably be the current directory, but that's not a very predictable concept either in an environment like tomcat. Use the mechanisms you would use to access any other file in a web server environment, for example getResourceAsStream.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 17th, 2008, 08:25 PM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Kay

String sXSLFileName = "directory.xsl";

InputStream is = getClass().getResourceAsStream(sXSLFileName);

i have used this way and i am done with it.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me out with XML-HTML tranformation tutukun XSLT 4 May 13th, 2007 04:41 PM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
XSLT for complicated xml to xml transf. required doug@sirvisetti XSLT 3 June 17th, 2005 04:26 PM
merge two xml file and make new xml using xslt ketan XSLT 0 September 21st, 2004 08:48 AM
Merge XML files into a xml file using xslt lxu XML 4 November 6th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.