p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

xslt thread: SAXSource transformation error with JAXP 1.1


Message #1 by "Abid Farooqui" <farooqui@t...> on Thu, 5 Jul 2001 06:20:15
The class com.icl.saxon.aelfred.SAXDriver is a SAX parser, not a JAXP parser
factory, hence the ClassCastException. You should specify
com.icl.saxon.aelfred.SAXParserFactoryImpl

Mike Kay
Software AG

> -----Original Message-----
> From: Abid Farooqui [mailto:farooqui@t...]
> Sent: 05 July 2001 06:20
> To: P2P_XSLT
> Subject: [xslt] SAXSource transformation error with JAXP 1.1
>
>
> Can anyone help me with this? Forgive my ignorance I am learning JAXP
> along with some popular XSLT processors
>
> I am getting an exception using JAXP Tranformation API with SAXON as
> follows:
>
> Exception in thread "main"
> javax.xml.transform.TransformerFactoryConfigurationError:
> java.lang.ClassCastException: com.icl.saxon.aelfred.SAXDriver
>         at com.icl.saxon.TransformerFactoryImpl.getStyleParser
> (TransformerFactoryImpl.java:502)
>         at com.icl.saxon.TransformerFactoryImpl.getSAXSource
> (TransformerFactoryImpl.java:143)
>         at com.icl.saxon.TransformerFactoryImpl.newTemplates
> (TransformerFactoryImpl.java:124)
>         at com.nl.transformer.Translator.doSAX2SAXTransformation
> (Translator.java:101)
>         at com.nl.transformer.Translator.main(Translator.java:196)
>
> Relevent code is provided below:
>
> Method:
> public SAXResult doSAX2SAXTransformation(SAXSource
> inputSource, SAXSource
> styleSource)
>     throws TransformerException, TransformerConfigurationException,
>             SAXException, IOException, ParserConfigurationException,
>             MalformedURLException, Exception {
>
>     // Create a transform factory instance
>     TransformerFactory tfactory  = TransformerFactory.newInstance();
>     SAXResult result = new SAXResult();
>     if (!tfactory.getFeature(SAXSource.FEATURE)) {
>       System.err.println("SAX input is not supported by the
> current XSLT
> processor: \n" +
>                          System.getProperty
> ("javax.xml.transform.TransformerFactory"));
>     }
>     else {
>       Templates templates = tfactory.newTemplates(styleSource);
>       // do the transformation
>       Transformer t = templates.newTransformer();
>       t.transform(inputSource, result);
>     }
>     return result;
> }
>
> Driving code:
> String parserSAX        = "com.icl.saxon.aelfred.SAXDriver";
> String parserDOM
> = "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl";
> String xsltProcessor    = "com.icl.saxon.TransformerFactoryImpl";
>
> // init sets the relevent System Properties to these values
> myTranslator.init(parserDOM, parserSAX, xsltProcessor);
>
> InputSource iSource        = new InputSource(new File(source).toURL
> ().toString());
> InputSource iStyle         = new InputSource(new File(style).toURL
> ().toString());
>
> SAXSource sourceSAXInput = new SAXSource(iSource);
> SAXSource styleSAXInput  = new SAXSource(iStyle);
> System.out.println("sourceSAXInput: \n" +
> sourceSAXInput.getXMLReader());
> SAXResult outputSAX 
> myTranslator.doSAX2SAXTransformation(sourceSAXInput,
> styleSAXInput);
>
> Thanks
> Sincerely,
> Abid Farooqui
>
> ---
> When you work at Microsoft, you don't have to wait for the
> latest technologies to be released. You'll create them ? with
> XML, SOAP, and C# -- and help decide what happens next.
> Find out where your career can take you: take a look at our
> software design engineer opportunities at
> http://www.microsoft.com/jobs.
>


  Return to Index