AW: [xsl] xsl:result-document appending

Subject: AW: [xsl] xsl:result-document appending
From: "Kloeck, Erwin" <Erwin.Kloeck@xxxxxx>
Date: Fri, 19 Sep 2003 15:45:34 +0200
Actually, random order would be fine. Though I don't understand
how this could happen, position() isn't random, is it?
What's really important for me is to collect my log entries from
different transformations in the same file.
The entries originating from one transformation should stay together though.

Right now this looks like I have to use both approaches simultaneously,
read the file before I write to it and run through the for-each loop twice, 
in order to read the file only once per transaction and not once for every
iteration in the for-each loop.

I guess, even this approach is still not entirely legal, since I still
read and write the same file from within one transformation.

Is it just me, or is this really clumsy?

Erwin



-----Ursprüngliche Nachricht-----
Von: Michael Kay [mailto:mhk@xxxxxxxxx]
Gesendet: Freitag, 19. September 2003 14:54
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: RE: [xsl] xsl:result-document appending


You can't do this; allowing it would break the non-sequential nature of
XSLT (unless you were happy to have the lines in your log file appear in
random order).

XSLT processing should generally be output-driven, not input-driven. If
you need to produce two different outputs that use the same input, then
access the input twice; if this looks as if it will be inefficient, then
save intermediate results in a variable.

Michael Kay


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Kloeck, Erwin
> Sent: 19 September 2003 09:13
> To: xsl-list@Lists. mulberrytech. com (E-Mail)
> Subject: [xsl] xsl:result-document appending
> 
> 
> Hi,
> 
> 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"?>
> <top>
>   <item value="hugo"/>
>   <item value="otto"/>
>   <item value="xaver"/>
> </top>
> 
> --------- log.xsl --------- 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="2.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>
>   
>   <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 >
>     </xsl:for-each>
>   </xsl:template>
> </xsl:stylesheet>
> 
> --------- 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.
> 
> 
> Thanks
> 
> Erwin
> 
> ..............................
> 
> Erwin Kloeck
> Produktentwicklung
> 
> 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:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread