RE: [xsl] result-document overwrites previous result

Subject: RE: [xsl] result-document overwrites previous result
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 2 Jun 2004 21:33:15 +0100
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] result-document overwrites previous result
> 
> Unlike the output file, the result-document file contains 
> only the last
> "Address" processed. My goal is to output addresses in a file 
> other than
> the "output file". Can I achieve this using result-document 
> or should I
> use a different approach?

xsl:result-document creates a complete document each time it is invoked.
It's supposed to be an error to write to the same URI more than once, but
Saxon isn't currently detecting this error (it simply overwrites the file).

xsl:result-document isn't designed to append - that would make the results
dependent on order of evaluation. If you want to create two output files,
you need to create one of them completely, then the other completely, you
can't interleave them. This means structuring your stylesheet differently.

It's possible that you could use (abuse!) Saxon's OutputURIResolver to
append to existing files, but it's not something I would recommend.

Michael Kay



> To top this, I would like to append to the file if "addressfilename"
> exists. Please help this newbie. Thanks.
> 
> I am using Saxon 7.9.1 and JDK 1.4.2
> The xslt file is-
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> 	<xsl:param name="addressfilename"/>
> 
> 	<xsl:output method="text"/>
> 
> 	<xsl:template match="/">
> 		<xsl:apply-templates select="Organization/Member"/>
> 	</xsl:template>
> 
> 	<xsl:template match="Member">
> 		<xsl:value-of select="@FirstName"/>
> 		<xsl:text>|</xsl:text>
> 		<xsl:value-of select="@LastName"/>
> 		<xsl:text>
> </xsl:text>
> 
> 		<xsl:if test="$addressfilename">
> 			<xsl:result-document
> href="file:///{$addressfilename}">
> 				<xsl:value-of select="concat(@ZipCode,
> '|', @Street, '|', @City, '|', @State)"/>
> 		<xsl:text>
> </xsl:text>
> 			</xsl:result-document>
> 		</xsl:if>
> 	</xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> --+------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
> 
> 



Current Thread