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

RE: xslt 2.0: grouping flat element structures to make

Subject: RE: xslt 2.0: grouping flat element structures to make lists
From: "Derek Revill" <derek@xxxxxxxxxxxxxxxxxx>
Date: Thu, 26 May 2005 11:29:11 +0100
xslt following sibling
Thanks to David. Plan b) was the way to go for me i.e. using a clever switch
to a special "list-processing mode" and gathering the required item nodes
after the list-begin "trigger node". Creating a "dead-end" template in the
list-processing mode for any following-sibling NON list-item nodes ensured
the list only contained the required items, and that redundant node
processing in the list-processing mode was brought to an end. 

I had just assumed that I should be using the new XSLT v2 features to solve
my problem. Basic XSLT v1 approach was better in the end.

Thanks again.

Derek

For reference final solution was (NB:  my default mode here is called 'phase
2'):

<xsl:template match="par[@class='ListBegin']" mode="phase2"> 
	<list-match-ph2>		
		<!-- Switch to a list-processing mode to get following
items-->  
		<xsl:apply-templates select="following-sibling::*[1]"
mode="list-processing"/>
	</list-match-ph2>
</xsl:template>


<xsl:template match="par[@class='Listitem']" mode="list-processing"> 
	<item-lp><xsl:apply-templates mode="phase2"/></item-lp>
	<!-- Try processing the following-sibling, it may be another list
item -->
	<xsl:apply-templates select="following-sibling::*[1]"
mode="list-processing"/>
</xsl:template>

<!-- Soak-up nodes / Create dead-end processing -->
<xsl:template match="par[@class='Listitem']" mode="phase2"/>
<xsl:template match="*" mode="list-processing"/>



> 
> plan b) Don't use for-each group at all.
>  just have your normal transformation templates, then add a template
> 
> <xsl:template match="par[@class='Listitem']"/>
> 
> so all list items go in the main run
> 
> and have a template
> 
> <xsl:template match="par[@class='Listbegin']">
> that starts a <list> and grabs all the following items, something like
> 
> 
> <xsl:template match="par[@class='Listbegin']">
> <list>
> <xsl:apply-templates mode="l" select="following-sibling::*[1]"/>
> </list>
> </xsl:template>
> 
> <xsl:template mode="l" match="par[@class='Listitem']">
> <item><xsl:apply-templates/></xsl:item>
> <xsl:apply-templates mode="l" select="following-sibling::*[1]"/>
> </xsl:template>
> 
> 
> <xsl:template mode="l" match="*"/>
> 
> 
> Actually I was going to use plan (b) in my first reply, but then I
> noticed that you said you wanted to use XSLT 2 grouping constructs
> and plan b isn't very good as a teach-yourself-xslt2 example, as it's
> xslt1:-)
> 
> 
> David

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.