|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] following-sibling problem
This is driving me crazy.
Source: <bullets> <bullet level="0" marker-type="inherited"> <content>Heading</content> </bullet> <bullet level="1" marker-type="inherited"> <content>Bullet 1a</content> </bullet> <bullet level="1" marker-type="inherited"> <content>Bullet 1b</content> </bullet> <bullet level="2" marker-type="inherited"> <content>Bullet 2a - a quote</content> </bullet> <bullet level="2" marker-type="inherited" id="bullet-1"> <content>Bullet 2b</content> </bullet> </bullets> Templates: <xsl:template match="key:bullet[@level='0']" mode="normal">
<h2><xsl:value-of select="."/></h2>
<ul>
<xsl:apply-templates
select="following-sibling::key:bullet[@level='1']"/>
</ul>
</xsl:template><xsl:template match="key:bullet[@level='1']">
<li class="level1">
<xsl:value-of select="."/>
<xsl:if test="following-sibling::key:bullet[@level='2']">
<ul>
<xsl:apply-templates
select="following-sibling::key:bullet[@level='2']"/>
</ul>
</xsl:if>
</li>
</xsl:template><xsl:template match="key:bullet[@level='2']">
<li class="level2">
<xsl:value-of select="."/>
</li>
</xsl:template>Output: <h2>Heading</h2>
<ul>
<li class="level1">Bullet 1a<ul>
<li class="level2">Bullet 2a - a quote</li>
<li class="level2">Bullet 2b</li>
</ul>
</li>
<li class="level1">Bullet 1b<ul>
<li class="level2">Bullet 2a - a quote</li>
<li class="level2">Bullet 2b</li>
</ul>
</li>
</ul>What I want: <h2>Heading</h2>
<ul>
<li class="level1">Bullet 1a</li>
<li class="level1">Bullet 1b<ul>
<li class="level2">Bullet 2a - a quote</li>
<li class="level2">Bullet 2b</li>
</ul>
</li>
</ul>In other words, I only want the template for level 2 applied when there is a following-sibling immediately following a level 1 bullet. Bruce
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








