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

following-sibling problem

Subject: following-sibling problem
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Wed, 27 Oct 2004 08:55:41 -0400
xsl following sibling
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

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.