[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: conditional multiple outputs

Subject: Re: conditional multiple outputs
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 14 May 2009 12:17:31 +0100
Re:  conditional multiple outputs
 <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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.