|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Errors when trying to use Xalan instead of Saxon
It may be way off the mark but Ive read (and used myself) that when dealing with in memory representations of data you might find StringReader useful: So for your case Reader reader = new StringReader(n); InputSource in = new InputSource(reader); TransformerFactory.newInstance().newTransformer(new SAXSource(n)); (untested) cheers andrew -----Original Message----- From: Jason Silva [mailto:jason.silva@xxxxxxxxxxx] Sent: 24 July 2002 14:56 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: Errors when trying to use Xalan instead of Saxon Thanks for the info Kumar, I tried a bunch of different variations but the problem lies in the conformity between Xerces and Crimson. You see, I am trying to have multiple stylesheets nested within one XSL file. I am using DOM, in particular the Node class to break up the file into chunks and then run the transformations in a loop. This worked fine with Crimson and Saxon but gives me an error with Xerces and Xalan. The problem lies when attempting to get a ByteStream from the myNode.toString() and then constructing a transform with this Stream. With Crimson the myNode.toString gives me a nice String containing the nested template. However with Xerces I get the root name and null. I have also tried instantiating the transformer with the Node itself but this doesn't work either. Below is what I have ... I think we run into diffuculty trying to have multiple stylesheets in one xsl file, but this should be do-able. Element root = transform.getDocumentElement(); if ( root.getTagName().equals("xsl:stylesheet") ) { Transformer transformer = TransformerFactory.newInstance().newTransformer(new DOMSource(root/*transform*/)); transformer.transform(new DOMSource(model), result); } else if ( root.getTagName().equals("pipeline") ) { NodeList l = root.getChildNodes(); for ( int i = 0, j = 1 ; i < l.getLength() ; i++ ) { Node n = l.item(i); if ( ! ( n instanceof Element ) ) continue; System.out.println("String: " + n.toString()); //Tried initializing with DOMSource(n) but that does not work either Transformer transformer = TransformerFactory.newInstance().newTransformer( new SAXSource(new InputSource (new ByteArrayInputStream(n.toString().getBytes())))); DOMResult domResult = new DOMResult(); transformer.transform(new DOMSource(model), domResult); model = (Document) domResult.getNode(); } // create an identity transform just to copy to the final result Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new DOMSource(model), result); } Sorry about the formatting. Any Suggestions would be much appreciated Thanks a bunch Jason Silva XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.373 / Virus Database: 208 - Release Date: 01/07/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.373 / Virus Database: 208 - Release Date: 01/07/2002 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








