[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Frustrated by result-document
Subject: Frustrated by result-document From: "davidpbrown" <lists@xxxxxxxxxxxxxxxxx> Date: Sun, 6 Jun 2004 13:29:33 +0100 |
I've had a lot of fun learning XSLT, and it's mostly been straightforward but was surprised to find that result-document appears only to update a file once. This with Saxon 7.9.1. I have an input that suggests files to update, and often this results in files needing multiple updates. Using a <for-each input, update the result-document suggested in the current input>, I find only the last update is being made. I'm taking this to suggest the result-document isn't releasing a new file at </result-document>. I'm worried about the prospect of having to internalise all the files to then find all the updates needed for each file, so as to generate just one update per file. Am I going to have to do this, or is there a better approach?.. I have looked to read around this but not found anything explicitly suggesting this behaviour. Regards davidpbrown Example of the problem The transform below acting on this input <?xml version="1.0" encoding="utf-8"?> <data> <item name="x" id="136">item1</item> <item name="y" id="137"/> <item name="z" id="138">item3</item> </data> I would hope to give this output <?xml version="1.0" encoding="utf-8"?> <data> <item name="newinput" id="136">newinput2</item> <item name="newinput" id="136">newinput1</item> <item name="x" id="136">item1</item> <item name="y" id="137"/> <item name="z" id="138">item3</item> </data> but instead gives <?xml version="1.0" encoding="utf-8"?> <data> <item name="newinput" id="136">newinput2</item> <item name="x" id="136">item1</item> <item name="y" id="137"/> <item name="z" id="138">item3</item> </data> The simplified transform that highlights my problem is.. <?xml version="1.0"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="no" encoding="utf-8"/> <xsl:template match="/"> <xsl:variable name="files"> <file>data.xml</file> <file>data.xml</file> </xsl:variable> <xsl:for-each select="$files/file"> <xsl:variable name="position" select="position()"/> <xsl:variable name="filename" select="concat('file:///C:/xslttest/',.)"/> <xsl:choose> <xsl:when test="document($filename)"> <xsl:variable name="input"><xsl:copy-of select="document($filename)/data/*"/></xsl:variable> <xsl:message><xsl:copy-of select="$input/item/*"/></xsl:message> <xsl:result-document href="{$filename}"> <xsl:text> </xsl:text> <data> <xsl:text> </xsl:text> <item name="newinput" id="136">newinput<xsl:value-of select="$position"/></item> <xsl:for-each select="$input/child::*"> <xsl:text> </xsl:text> <xsl:copy-of select="."/> </xsl:for-each> <xsl:text> </xsl:text> </data> </xsl:result-document> </xsl:when> <xsl:otherwise> <xsl:message>error</xsl:message> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> <xsl:template match="text()|@*"/> </xsl:transform>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] how to get the position o, Joe Fawcett | Thread | RE: [xsl] Frustrated by result-docu, Michael Kay |
RE: [xsl] xsl-list@..., Michael Kay | Date | Re: [xsl] Recursive selection, eleg, Robert Koberg |
Month |
Keywords