Menu ▾ ▴

single xsl:result-document writes file twice

Help
tom1301
2006-12-31
2012-10-08
  • tom1301

    tom1301 - 2006-12-31

    Hi there,

    i have a Problem with Saxon 8.8 run via ant-xslt-task on Windows XP. Obviously a single <xsl:result-document/> yields TWO files (besides the main result file, of course).

    I have build a simple XSL to demonstrate the Problem:
    ...
    <xsl:template match="/">
    <xsl:value-of select="seconds-from-time(current-time())"/>
    <xsl:result-document href="{seconds-from-time(current-time())}.jrxml"/>
    </xsl:template>

    Executing this XSL on a suited XML ('test.xml' for example) yields the following files:

    • 'test.jrxml'
    • '6.165.jrxml'
    • '6.493.jrxml'

    The File 'test.jrxml' contains (as expected) only one line:
    <?xml version="1.0" encoding="UTF-8"?>6.493

    Why are there TWO files produced by the single xsl:result-document? Since 'test.jrxml' contains only the '6.493', the xsl:value-of obviously yields exactly one result, whereas xsl:result-document yields two.

    Any help is greatly appreciated.
    tom1301.

    P.S.: Of course omitting the time-function leads to the infamous "Cannot write more than one result document to the same URI, or write to a URI that has been read" error, which is the real problem i have.

    Appendix:
    The Ant Task:
    <xslt style ="${layout.generation.jsp.dir}/root.xsl"
    basedir ="${test.source.dir}/xml"
    destdir ="${test.target.jsp.dir}"
    extension =".jsp"
    force ="true"
    processor ="trax"
    classpathref="saxon.class.path">
    </xslt>

     
    • Michael Kay

      Michael Kay - 2006-12-31

      Since several calls on current-time() during the same transformation produce the same result, I would think the explanation is almost certainly that you have run the transformation more than once and it has produced different output files on each occasion. This would suggest the problem is at the Ant level.

       
    • tom1301

      tom1301 - 2006-12-31

      You are right, Michael.

      Without knowing your reply i tried meanwhile several solutions and workarounds and finally figured out the cause was the 'force="true"'-Parameter declared in the Ant-xslt-task.
      Omitting this parameter lets Saxon behave as expected.

      That fault gave me 6 hours of frustration. Well, at least i got it finally....

      Thank you very much, nevertheless.
      tom1301