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

Re: grouping nesting items, including following items

Subject: Re: grouping nesting items, including following items
From: Don Smith <dtsmithisogen@xxxxxxxxx>
Date: Tue, 19 Jun 2007 08:48:41 -0700 (PDT)
Re:  grouping nesting items
Andrew,

Thanks. I won't be able to look at this until tonight.

Don
--- Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:

> On 6/19/07, Don Smith <dtsmithisogen@xxxxxxxxx>
> wrote:
> > I can't quite figure out how to group nested items
> and
> > also pick up items on the following axis for a
> given
> > group. Here's a sample source:
> >
> > <slide title="Introduction" id="x1">
> >  <point id="x2" >
> >   <text>First point</text>
> >   <subpoints id="x3">
> >    <point id="x3a">
> >     <text>First point, subpoint 1</text>
> >    </point>
> >    <point id="x3b">
> >     <text>First point, subpoint 2</text>
> >    </point>
> >    <point id="x3c">
> >     <text>First point, subpoint 3</text>
> >     <subpoints id="x3c1">
> >      <point id="x3c1a" newSlide="true" 
> title="Intro
> > (cont.)">
> >       <text>First point, subpoint 3, sub-subpoint
> 1 on
> > new slide</text>
> >      </point>
> >      <point id="x3c1b">
> >       <text>First point 4, subpoint 3,
> sub-subpoint 2
> > on new slide</text>
> >      </point>
> >     </subpoints>
> >    </point>
> >    <point id="x4d">
> >     <text>First point, subpoint 4 on new
> slide</text>
> >    </point>
> >   </subpoints>
> >  </point>
> >  <point id="x5" >
> >   <text>Second point, on new slide</text>
> >  </point>
> > </slide>
> >
> > Note the attribute "newSlide" on <point
> id="x3c1a">: I
> > need this element, all its descendants (if any),
> and
> > everything that follows, to be in a different
> group
> > than everything that comes before. Ideally, this
> would
> > mean each group is placed in its own document
> using
> > <xsl:result-document>.
> >
> > This is just one example, but "newSlide='true'"
> can
> > occur on any <point> or even any <subpoints>.
> 
> You need the "modified identity transform" - the one
> which walks the
> following-sibling axis:
> 
> <xsl:template match="node()">
> 	<xsl:copy>
> 		<xsl:copy-of select="@*"/>
> 		<xsl:apply-templates select="node()[1]"/>
> 	</xsl:copy>
> 	<xsl:apply-templates
> select="following-sibling::node()[1]"/>
> </xsl:template>
> 
> Then you just need to override it with a template
> containing the
> specific behaviour for elements with @newSlide =
> 'true':
> 
> <xsl:template match="*[@newSlide = 'true']">
> 	<xsl:result-document href="....">
> 	  <xsl:copy-of select="."/>
> 	  <xsl:copy-of select="following-sibling::*"/>
> 	</xsl:result-document>
> </xsl:template>
> 
> Notice how I've used copy-of instead of
> apply-templates here - you can
> only write one result document at once so nested
> @newSlide's  would
> cause an error.  To get around that don;t use
> xsl:result-document use
> a wrapper element, put the whole thing in a variable
> and then process
> that variable.  Post back for an example of that if
> its needed.
> 
> cheers
> andrew
> 
> 



       
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC

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.