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

Re: following-sibling problem

Subject: Re: following-sibling problem
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Thu, 28 Oct 2004 09:13:12 -0400
xsl following sibling
On Oct 27, 2004, at 9:38 AM, Michael Kay wrote:

For a very similar problem I used:

<xsl:template name="process-level">
<xsl:param name="population" required="yes" as="element()*"/>
<xsl:param name="level" required="yes" as="xs:integer"/>
<xsl:for-each-group select="$population"
group-starting-with="*[xs:integer(@level) eq $level]">
<xsl:element name="{@tag}">
<xsl:copy-of select="@ID[string(.)], @REF[string(.)]"/>
<xsl:value-of select="normalize-space(@text)"/>
<xsl:call-template name="process-level">
<xsl:with-param name="population" select="current-group() except
.."/>
<xsl:with-param name="level" select="$level + 1"/>
</xsl:call-template>
</xsl:element>
</xsl:for-each-group>
</xsl:template>


Prime this with the population parameter set to the entire sequence of key
elements, and level set to 0, and it will build the hierarchy for you; you
only need to change the instructions that construct new elements and
attributes in the new hierarchy.

I'm a little stuck on this; I end up sending Saxon into an infinite loop with my current code:


<xsl:template match="key:slide">
  <div class="slide">
    <xsl:apply-templates select="key:bullets"/>
  </div>
</xsl:template>

<xsl:template match="key:bullets">
<xsl:choose>
<xsl:when test="../@master-slide-id='master-slide-1'">
<xsl:apply-templates select="key:bullet[@level='0']" mode="title"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="process-level">
<xsl:with-param name="bullet" select="key:bullet"/>
<xsl:with-param name="level" select="0"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template match="key:bullet[@level='0']" mode="title">
  <h1><xsl:value-of select="$title"/></h1>
  <h3><xsl:value-of select="$author"/></h3>
</xsl:template>

<xsl:template name="process-level">
<xsl:param name="bullet" required="yes" as="element()*"/>
<xsl:param name="level" required="yes" as="xs:integer"/>
<xsl:for-each-group select="$bullet"
group-starting-with="*[xs:integer(@level) eq $level]">
<ul>
<li><xsl:value-of select="normalize-space(.)"/></li>
<xsl:call-template name="process-level">
<xsl:with-param name="bullet" select="current-group() except ..."/>
<xsl:with-param name="level" select="$level + 1"/>
</xsl:call-template>
</ul>
</xsl:for-each-group>
</xsl:template>


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.