I am using the following code for XSL transformation but getting these
errors :
Option 1: formatJMS.java
import java.io.*;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import java.util.Properties;
import javax.xml.transform.TransformerFactory;
import java.io.FileOutputStream;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
/**
* Use the TraX interface to perform a transformation in the simplest
manner possible
* (3 statements).
*/
public class formatJMS
{
public static void main(String args[]) throws TransformerException,
TransformerConfigurationException,FileNotFoundException, IOException
{
// Set the TransformerFactory system property.
// Note: For more flexibility, load properties from a properties file.
String key = "javax.xml.transform.TransformerFactory";
String value = "org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
Properties props = System.getProperties();
props.put(key, value);
System.setProperties(props);
String xslInURI="input.xsl";
String xmlInURI="input.xml";
String xmlInURI2;
String htmlOutURI="output.xml";
String htmlOutURI2;
// Instantiate the TransformerFactory, and use it along with a StreamSource
// XSL stylesheet to create a Transformer.
TransformerFactory tFactory = TransformerFactory.newInstance();
boolean bool = true;
tFactory.setAttribute("generate-translet",Boolean.TRUE);
tFactory.setAttribute("jar-name","xxx.jar");
tFactory.setAttribute("enable-inlining", Boolean.TRUE);
Transformer transformer =
tFactory.newTransformer(new StreamSource(xslInURI));
// Perform the transformation from a StreamSource to a StreamResult;
transformer.transform(new StreamSource(xmlInURI),
new StreamResult(new FileOutputStream(htmlOutURI)));
// Re-use the same transformer for a second transformation
//transformer.transform(new StreamSource(xmlInURI2),
// new StreamResult(new FileOutputStream(htmlOutURI2)));
}
It compiles perfectly, but i am not able to run the code .
When i give java formatJMS
it gives the following error :
Exception in thread "main" java.lang.IllegalArgumentException: Not
supported: ge
nerate-translet
at
org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(Transf
ormerFactoryImpl.java:558)
at formatJMS.main(formatJMS.java:100)
C:\Java\Xalan Samples\samples\Test\XSLTC>javac formatJMS.java
C:\Java\Xalan Samples\samples\Test\XSLTC>java formatJMS
Exception in thread "main" java.lang.IllegalArgumentException: Not
supported: en
able-inlining
at
org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(Transf
ormerFactoryImpl.java:558)
at formatJMS.main(formatJMS.java:103)
C:\Java\Xalan Samples\samples\Test\XSLTC>javac formatJMS.java
C:\Java\Xalan Samples\samples\Test\XSLTC>java formatJMS
Exception in thread "main" java.lang.IllegalAccessError: class
org.apache.xml.dt
m.ref.sax2dtm.SAX2DTM2$AncestorIterator cannot access its superclass
org.apache.
xml.dtm.ref.DTMDefaultBaseIterators$InternalAxisIteratorBase
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at
org.apache.xalan.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.jav
a:291)
at
org.apache.xalan.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.jav
a:174)
at
org.apache.xalan.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.ja
va:516)
at
org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl
.java:655)
at
org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl
.java:298)
at formatJMS.main(formatJMS.java:110)
Option 2: In the above code i remove the two lines , compile and try to run
props.put(key, value);
System.setProperties(props);
I get the errors :
Exception in thread "main" java.lang.IllegalArgumentException: Not
supported: ge
nerate-translet
at
org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(Transf
ormerFactoryImpl.java:558)
at formatJMS.main(formatJMS.java:44)
i have the following classpath :
C:\Java\xalan-j_2_5_0\xalan-j_2_5_0\bin\xalan.jar;.
-----------------------+
cf-xml mailing list
http://torchbox.com/xml/list.cfm