[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 11:37:44 -0400
li bullet type
One problem with the below is that I can't work out how to only add the
nested ul element if there's content.  I end up with this, for example:

         <div class="slide">
            <h2>Heading</h2>
            <ul>
               <li>Bullet 1a
                  <ul>
                     <li>B2
                        <ul></ul>
                     </li>
                  </ul>
               </li>
               <li>Bullet 1b
                  <ul>
                     <li>Bullet 2a
                        <ul></ul>
                     </li>
                     <li>Bullet 2b
                        <ul></ul>
                     </li>
                  </ul>
               </li>
            </ul>
         </div>

Source fragment:

			<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: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>
      <h2><xsl:value-of select="key:bullet[@level='0']"/></h2>
      <ul>
        <xsl:call-template name="process-level">
          <xsl:with-param name="bullet" select="key:bullet"/>
          <xsl:with-param name="level" select="1"/>
        </xsl:call-template>
      </ul>
    </xsl:otherwise>
  </xsl:choose>
</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[not(@level='0')]"
                group-starting-with="*[xs:integer(@level) eq $level]">
      <li><xsl:value-of select="normalize-space(.)"/>
        <ul>
          <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>
      </li>
  </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.