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

RE: processing following-siblings to a point

Subject: RE: processing following-siblings to a point
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 10 Jul 2009 00:15:20 +0100
RE:  processing following-siblings to a point
> I've run into a structure that I must transform that I just 
> haven't found a solution for. XSL 1.0 only. (I just don't 
> have the proficiency for 2.0 yet).

I think you've got that the wrong way around. With positional grouping in
XSLT 2.0 (<xsl:for-each-group group-starting-with="title">) this is quite an
easy problem. In XSLT 1.0 you need to write recursive templates, which
requires a much higher level of proficiency in the language.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


> 
> I'm transforming what was a rather flat SGML structure to an 
> XML structure.  Here's the input structure:
> 
> <gen>
> <title>TITLE_1</title>
> <subtitle>SUBTITLE_1</subtitle>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> <title>TITLE_2</title>
> <subtitle>SUBTITLE_2</subtitle>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> <title>TITLE_2</title>
> <subtitle>SUBTITLE_2</subtitle>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> </gen>
> 
> Resulting structure tree:
> 
> <para0>
> <title>TITLE_1</title>
> <subpara1>
> <title>SUBTITLE_1</title>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> </subpara1>
> </para0>
> <para0>
> <title>TITLE_2</title>
> <subpara1>
> <title>SUBTITLE_2</title>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> </subpara1>
> </para0>
> <para0>
> <title>TITLE_3</title>
> <subpara1>
> <title>SUBTITLE_3</title>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> <para>Text.</para>
> </subpara1>
> </para0>
> 
> My template (or at least the important part).
> 
>     <xsl:template match="gen/title" mode="move">
> 
>         <para0>
>             <title>
>                 <xsl:value-of select="."/>
>             </title>
>             <subpara1>
>                 <title><xsl:value-of 
> select="following-sibling::subtitle[1]"/></title>
>                 <xsl:apply-templates 
> select="following-sibling::para"/>
>             </subpara1>
>         </para0>
> 
> My problem is with the <xsl:apply-templates 
> select="following-sibling::para"/> line. Of course, all of 
> the para elements are following siblings of all the gen/title 
> elements. How can I express the <apply-templates> to process 
> only the para element siblings BEFORE the next following 
> title sibling. (This is difficult because EVERYTHING is a 
> sibling of everything else).
> 
> Charles Flanders
> IETM Developer

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.