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

RE: problem creating containment during XHTML->XML

Subject: RE: problem creating containment during XHTML->XML
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 23 Feb 2004 23:35:24 -0000
selecting siblings xslt 2.0
Try a search for "XSLT positional grouping" (this is a classic problem).

In XSLT 2.0 this is child's play:

<xsl:for-each-group group-starting-with="heading">

In 1.0 it's quite hard. In the template that matches <heading> you've
got to process all the following siblings up to the next heading. One
way of selecting these is

following-sibling::*[generate-id(preceding-sibling::heading) =
generate-id(current())]

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Don Stinchfield
> Sent: 23 February 2004 22:07
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  problem creating containment during XHTML->XML 
> 
> 
> Hello,
> 
> I'm having a devil of a time trying to create the right node 
> set for my processing.  Any help would be appreciated. :-)
> 
> I'm in the process of breaking up an XHTML file into multiple 
> XML files. Here's the portion of the input file that's of 
> interest (I've already Modified the file by replacing HTML 
> headings with a heading tag)...
> 
>   [lots of html cruft]
>   <heading level="h1"><a name="content" 
> id="content"></a>Overview</heading>
>     <p>On February 20, 1865</p>
>     <p>Education and related research&#8212; 
>     <a href="degre.archi.deans.shtml">Architecture and Planning</a>; 
>     <a href="degre.engin.deans.shtml">Engineering</a>;</p>
>   <heading level="h3"><a name="mission" 
> id="mission"></a>Mission</heading>
>     <p>The mission of </p>
>     <p>The Institute is committed to </p>
>   <heading level="h3"> <a name="sf" id="sf"></a>Faculty</heading>
>     <p> total enrollment is approximately 10,300 students</p>
>     <p>The faculty numbers approximately 956</p>
>   [lots of html cruft]
> 
> I'm cleaning up a bit and would like to add structure as follows...
> 
>   <section>
>     <heading level="h1">Overview</heading>
>       <p>On February 20, 1865</p>
>       <p>Education and related research&#8212;   
>       <a href="degre.archi.deans.shtml">Architecture and 
> Planning</a>; 
>       <a href="degre.engin.deans.shtml">Engineering</a>;</p>
>   </section>
>   <section>
>     <heading level="h3"></a>Mission</heading>
>       <p>The mission of </p>
>       <p>The Institute is committed to </p>
>   </section>
>   <section>
>     <heading level="h3">Faculty</heading>
>       <p> total enrollment is approximately 10,300 students</p>
>       <p>The faculty numbers approximately 956</p>
>   </section>
> 
> In a final phase I'll break the file up.  One xml file per section.
> 
> Here's the XSLT file.  I've been working with.
> 
> - <xsl:template match="/">
>     <xsl:apply-templates select="//x:heading" /> 
>   </xsl:template>
> 
> - <xsl:template match="x:heading">
>   - <section>
>   -   <title>
>         <xsl:value-of select="." /> 
>       </title>
>       <xsl:apply-templates select="following-sibling::*" /> 
>     </section>
>   </xsl:template>
> 
> - <xsl:template match="text()|node()|@*">
>     <xsl:copy-of select="." /> 
>   </xsl:template>
> 
> The above puts me in an infinite loop.  I have no idea why.  
> I've tried loads of different techniques.  The above seems to 
> be close, but I don't know how to stop coping nodes that 
> don't belong in a specific section.  I'm thinking I need to 
> create a nodeset that contains all following siblings up to 
> but not including the next heading tag.  My gut tells me this 
> should be easy, but I've been looking at this problem long 
> enough that I'm cross eyed. Any help would be appreciated.
> 
> 
> Regards,
> Don Stinchfield
> Red Bridge Interactive, Inc.
> 
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.