[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XTDE1490 and using the Saxon transformer multiple

Subject: RE: XTDE1490 and using the Saxon transformer multiple times
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 26 Jun 2007 22:48:10 +0100
RE:  XTDE1490 and using the Saxon transformer multiple
I've logged a bug entry for this and there's a patch in the Subversion
repository.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Norman Gray [mailto:norman@xxxxxxxxxxxxxxx] 
> Sent: 26 June 2007 12:57
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XTDE1490 and using the Saxon transformer multiple times
> 
> 
> Greetings.
> 
> I'm getting an error (XTDE1490) when I use the Saxon 8.9 
> Transformer multiple times.
> 
> It's not obvious to me what I'm doing wrong, the explanation 
> of XTDE1490 at [1] doesn't apply, and there's no obvious 
> insight in the list archive for the various searches I've tried.
> 
> 
> My (complete) test program is
> 
> import javax.xml.transform.*;
> import javax.xml.transform.stream.StreamSource;
> import javax.xml.transform.stream.StreamResult;
> public class SaxonTry {
>      public static void main(String[] args) {
>          String xsltFile = "identity.xslt";
>          Source[] sources = new Source[args.length];
>          Result[] results = new Result[args.length];
>          for (int i=0; i<args.length; i++) {
>              sources[i] = new StreamSource(args[i]);
>              results[i] = new StreamResult(args[i]+"-res");
>          }
>          try {
>              Transformer trans = TransformerFactory.newInstance()
>                      .newTransformer(new StreamSource(xsltFile));
>              for (int i=0; i<args.length; i++) {
>                  System.err.println("Transforming: " + sources
> [i].getSystemId()
>                                     + " -> " + 
> results[i].getSystemId ());
>                  trans.transform(sources[i], results[i]);
>              }
>          } catch (Exception e) {
>              System.err.println("Exception: " + e);
>          }
>      }
> }
> 
> The identity.xslt is the usual XSLT identity transform.
> 
> Running this with the default transformer works fine:
> 
> % CLASSPATH=. java SaxonTry test-in{1,2}.xml
> Transforming: test-in1.xml -> test-in1.xml-res
> Transforming: test-in2.xml -> test-in2.xml-res %
> 
> and produces two output files as expected.  Using the Saxon 
> 8.9 transformer, however, produces errors:
> 
> % CLASSPATH=$T/saxon-8.9/saxon8.jar:. java \
>    -
> Djavax.xml.transform.TransformerFactory=net.sf.saxon.Transform
> erFactoryI
> mpl \
>    SaxonTry test-in1.xml test-in2.xml
> Warning: at xsl:transform on line 3 of file:///Volumes/Lagrange/
> checkouts/me/code/misc/identity.xslt:
>    Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
> Transforming: test-in1.xml -> test-in1.xml-res
> Transforming: test-in2.xml -> test-in2.xml-res Error at 
> xsl:copy on line 6 of file:///Volumes/Lagrange/checkouts/me/
> code/misc/identity.xslt:
>    XTDE1490: Cannot write an implicit result document if an 
> explicit result document has been
>    written to the same URI: test-in1.xml-res
> Exception: net.sf.saxon.trans.DynamicError: Cannot write an 
> implicit result document if an explicit result document has 
> been written to the same URI: test-in1.xml-res %
> 
> There's no result-document element in the identity 
> transformation, but there's no need for once, since the
> javax.xml.transform.Transformer.transform() method is being 
> given explicit Source and Result arguments.
> 
> The javax.xml.transform.Transformer documentation[2] 
> indicates that the Transformer `may be used multiple times', 
> and that it `may then be used to process XML from a variety 
> of sources and write the transformation output to a variety 
> of sinks.'  That certainly suggests that I _ought_ to be able 
> to do what I'm doing by reusing the Transformer with multiple 
> Sources and Results.  What appears to be happening, however, 
> is that the Saxon Transformer is attempting to use the first 
> Result for both transformations (or something like that).
> 
> I've looked at Templates, but as far as I can tell from the 
> javadocs, the only issue there is that a Template is 
> thread-safe, and so can produce multiple (unsafe) 
> Transformers implementing a single  
> transformation, which can themselves be used in separate threads.   
> But that's not my situation here.
> 
> Am I doing something dim?
> 
> Thanks for any pointers.  Best wishes,
> 
> Norman
> 
> 
> 
> [1] http://www.w3.org/TR/xslt20/#err-XTDE1490
> [2] http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/
> Transformer.html
> 
> --
> ------------------------------------------------------------------
> Norman Gray  :  http://nxg.me.uk
> eurovotech.org  :  University of Leicester, UK

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.