Subject: Re: [xsl] conditional multiple outputs From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 14 May 2009 12:17:31 +0100 |
<xsl:result-document generates a complete file not appends to an existing file so the process stops on the third title as it tries to write file2 again. You shoult think of the external file as like an element if your desired end result had been <file1> <title>file 1 xxx </title> <title>file 1 abc </title> </file1> <file2> <title>file 2 efg </title> <title>file 2 xxx </title> <title>file 2 zzz </title> <title>file 2 ihk </title> </file2> <file3> <title>file 3 abc </title> <title>file 3 xyz </title> </file3> You would not, in xslt have tried to append to the child nodes of file2 in different templates, you would have opened file2, then generated using an xpath that selected the right titles all the relevant entries then closed the element. You need to treat xsl:result document in exactly the same way. somethinng like <xsl:for-each-group select="group/title" group-by="replace(.,'(^file\s*)([0-9]*).*','$2'"> <xsl:result-document href="file{current-grouping-key()}.xml"> <xsl:for-each select="current-group()"> <contentOfTitleElmt> <xsl:value-of select="."/> </contentOfTitleElmt> </xsl:for-each> </xsl:result-document> </xsl:for-each-group> Incidentally it's usually better to do <xsl:value-of select="."/> rather than <xsl:value-of select="./text()"/> the ./ at the front doesn't do anything so ./text() is equivalent to <xsl:value-of select="text()"/> which doesn't ignore for example comments in the input in the way you might expect (they will get translated to spaces, effectively). David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] conditional multiple outp, Michael Kay | Thread | [xsl] How to copy filtered rows fr, Raveendran, Reshma \ |
RE: [xsl] conditional multiple outp, Michael Kay | Date | [xsl] How to copy filtered rows fr, Raveendran, Reshma \ |
Month |