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

Re: Conditional in-context nodeset variables

Subject: Re: Conditional in-context nodeset variables
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 3 Jan 2008 16:38:50 +0000
Re:  Conditional in-context nodeset variables
On 03/01/2008, Vyacheslav Sedov <vyacheslav.sedov@xxxxxxxxx> wrote:
> yep - it small simplified part of big code (more precisely - just testcase),
> i don`t use xsl:...group since it make my code behavior like it use pull model,
> but i am trying to use push model - maybe it wrong & i just not
> familiar with grouping,
> i feel myself with this task like cow on ice :)

a cow on ice... :)

Don't worry too much about push and pull - for grouping you have to
use pull - and for-each-group is excellent (like most things in XSLT
once you 'get' them)

Here's an example using for-each-group with group-ending-with:

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="2.0">

    <xsl:output indent="yes"/>

    <xsl:variable name="input">
        <div>
            <p>p</p>
            <h1></h1>
            <h2></h2>
            <p>p2</p>
        </div>
    </xsl:variable>

    <xsl:template match="/">
        <xsl:for-each-group select="$input/div/*" group-ending-with="h1|h2">
            <group>
                <xsl:copy-of select="current-group()"/>
            </group>
        </xsl:for-each-group>
    </xsl:template>

</xsl:stylesheet>

It generates this output:

<group>
   <p>p</p>
   <h1/>
</group>
<group>
   <h2/>
</group>
<group>
   <p>p2</p>
</group>

Is that what you were after?  If not, modify the input and and
required output and post back.


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.