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

limitations of xslt

Subject: limitations of xslt
From: Earl Bingham <earl@xxxxxxxxxxxxxx>
Date: Sat, 23 Oct 1999 15:31:01 -0700 (PDT)
limitations of xslt
Once again I am faced with the following:

input file:

<?xml version="1.0"?>
<textItems>
   <title>Here is my first title!</title>
   <bullet>first group first bullet</bullet>
   <bullet>first group second bullet</bullet>
   <normal>first group first normal</normal>
   <bullet>first group third bullet</bullet>
   <title>Here is my second title!</title>
   <bullet>second group first bullet</bullet>
   <normal>second group first normal</normal>
   <bullet>second group second bullet</bullet>
   <bullet>second group third bullet</bullet>
</textItems>

xsl file:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
                xmlns:xt="http://www.jclark.com/xt"
                extension-element-prefixes="xt">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="textItems">
  <result>
    <xsl:for-each select="//title|//bullet|//normal">
     <xsl:if test="self::title">
     <section>
       <sectionTitle><xsl:value-of select="."/></sectionTitle>
       <xsl:for-each select="following::title|following::bullet|following::normal">
         <xsl:choose>
           <xsl:when test="self::normal">
	     <xsl:if test="preceding::title">
	       <text><xsl:value-of select="."/></text>
             </xsl:if>
           </xsl:when>
	   <xsl:when test="self::title">
	     <xsl:comment>Found next title, I would like to stop here</xsl:comment>
	     <xsl:for-each select="following::bullet|following::normal"/>
	   </xsl:when>
           <xsl:when test="preceding-sibling::*[1][self::bullet]"/>
           <xsl:otherwise><!--at the first of a group of siblings-->
             <ul><!--"walk" along all sibling bullets for list items-->
               <xsl:apply-templates select="." mode="sibling-bullets"/>
             </ul>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:for-each>
     </section>
     </xsl:if>
    </xsl:for-each>
  </result>
</xsl:template>

<xsl:template match="title">
  <section>
    <sectionTitle><xsl:value-of select="."/></sectionTitle>
     <xsl:apply-templates/>
  </section>
</xsl:template>

<!--place each of a group of adjacent siblings-->
<xsl:template match="bullet" mode="sibling-bullets">
   <li><xsl:apply-templates/></li> <!--put out this one-->
                                   <!--go to next one-->
   <xsl:apply-templates
             select="following-sibling::*[1][self::bullet]"
             mode="sibling-bullets"/>
</xsl:template>

<xsl:template match="normal">   <!--other stuff-->
   <text><xsl:apply-templates/></text>
</xsl:template>

</xsl:stylesheet>

output:

<result>
  <section>
    <sectionTitle>Here is my first title!</sectionTitle>
    <ul>
      <li>first group first bullet</li>
      <li>first group second bullet</li>
    </ul>
    <text>first group first normal</text>
    <ul>
      <li>first group third bullet</li>
    </ul>
    <!--Found next title, I would like to stop here-->
    <ul>
      <li>second group first bullet</li>
    </ul>
    <text>second group first normal</text>
    <ul>
      <li>second group second bullet</li>
      <li>second group third bullet</li>
    </ul>
  </section>
  <section>
    <sectionTitle>Here is my second title!</sectionTitle>
    <ul>
      <li>second group first bullet</li>
    </ul>
    <text>second group first normal</text>
    <ul>
      <li>second group second bullet</li>
      <li>second group third bullet</li>
    </ul>
  </section>
</result>

So as you can see this is my delima. Hope someone
might know the answer.

- Earl


Earl Bingham
1568 Plateau Avenue
Los Altos Hills, CA 94024
H: (650) 559-1738
C: (408) 806-6642

____________________________________________________
get your permanent, free email at http://www.flashemail.com


 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.