Compiling XSLT program using Eclipse

F

fa.alshahwan

I am trying to transform xml file using java the code is as follows:

package chap5;


import java.io.*;

/**
* A simple demo of JAXP 1.1
*/
public class SimpleJaxp {

/**
* Accept two command line arguments: the name of an XML file, and
* the name of an XSLT stylesheet. The result of the
transformation
* is written to stdout.
*/
public static void main(String[] args)
throws javax.xml.transform.TransformerException {
if (args.length != 2) {
System.err.println("Usage:");
System.err.println(" java " + SimpleJaxp.class.getName
( )
+ " xmlFileName xsltFileName");
System.exit(1);
}

File xmlFile = new File(args[0]);
File xsltFile = new File(args[1]);

javax.xml.transform.Source xmlSource =
new javax.xml.transform.stream.StreamSource(xmlFile);
javax.xml.transform.Source xsltSource =
new javax.xml.transform.stream.StreamSource(xsltFile);
javax.xml.transform.Result result =
new javax.xml.transform.stream.StreamResult
(System.out);

// create an instance of TransformerFactory
javax.xml.transform.TransformerFactory transFact =
javax.xml.transform.TransformerFactory.newInstance
( );

javax.xml.transform.Transformer trans =
transFact.newTransformer(xsltSource);

trans.transform(xmlSource, result);
}
}

but I am getting the following error:
RROR: 'C:\Documents and Settings\Welcome\workspace
\XSLTTransform1\xsltFileName (The system cannot find the file
specified)'
FATAL ERROR: 'Could not compile stylesheet'
Exception in thread "main"
javax.xml.transform.TransformerConfigurationException: Could not
compile stylesheet
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates
(Unknown Source)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer
(Unknown Source)
at chap5.SimpleJaxp.main(SimpleJaxp.java:40)


can you tell me how to solve the problem please?
 
J

John B. Matthews

I am trying to transform xml file using java the code is as follows:

[...]

<http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=3>

Mr. Burke's code works correctly, as published.
but I am getting the following error:
[E]RROR: 'C:\Documents and Settings\Welcome\workspace
\XSLTTransform1\xsltFileName (The system cannot find the file
specified)' FATAL ERROR: 'Could not compile stylesheet' Exception in
thread "main" javax.xml.transform.TransformerConfigurationException:
Could not compile stylesheet
[...]
chap5.SimpleJaxp.main(SimpleJaxp.java:40)
[C]an you tell me how to solve the problem please?

I suspect you're supplying incorrect file(s) on the command line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top