RE: [xsl] xsl:result-document appending

Subject: RE: [xsl] xsl:result-document appending
From: "Jim Fuller" <jim.fuller@xxxxxxxxxxxxxxxxxx>
Date: Fri, 19 Sep 2003 12:02:00 +0100
u can take the existing log file in using the unparsed-text, though cant remember if saxon supports it

place this in a variable, which you concatanate your results to

then you could just xsl:output the whole result as text overwriting the file.

gl, jim fuller

-----Original Message-----
From: Kloeck, Erwin [mailto:Erwin.Kloeck@xxxxxx]
Sent: 19 September 2003 09:13
To: xsl-list@Lists. mulberrytech. com (E-Mail)
Subject: [xsl] xsl:result-document appending


I want to write out something like a log file from within a for-each loop.
I do some processing and at one point within the loop I want to write a line
to a different file. 

Here is what I do:

--------- log.xml --------- 
<?xml version="1.0" encoding="UTF-8"?>
  <item value="hugo"/>
  <item value="otto"/>
  <item value="xaver"/>

--------- log.xsl --------- 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl=""; xmlns:fo="";>
  <xsl:output name="log-format" method="text" omit-xml-declaration="yes"/>
  <xsl:template match="/">
    <xsl:for-each select="top/item">

	<!-- some involved processing with variables that are used in the log entry -->

      <xsl:result-document href="log.txt" format="log-format" >
        <xsl:value-of select="concat(string(position()), ' = ', @value)"/>
      </xsl:result-document >

--------- log.txt --------- 
3 = xaver

I would like log.txt to look like this:
--------- log.txt --------- 
1 = hugo
2 = otto
3 = xaver

For this I would like to be able to append to the existing log.txt file.
Is there a way to do this?

The alternative I can think of is to run trough the for-each loop twice, once to do the processing
and once to write the log file. I hope I have other options.




Erwin Kloeck

Oestreicher + Wagner 
Medientechnik GmbH
Frankenthaler Strasse 20
D-81539 Muenchen

Fon   +49 (0)89-68961 216 
Fax   +49 (0)89-68961 271

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread