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

RE: XSLT 1.0: Grouping Adjacent Elements in Embedded

Subject: RE: XSLT 1.0: Grouping Adjacent Elements in Embedded Lists
From: "Joe Heidenreich" <HeidenreichJ@xxxxxxxx>
Date: Fri, 5 Nov 2004 10:33:45 -0500
xsl 1.0 grouping
Hi Wendell,

When I do this:

> <xsl:if test="not(preceding-sibling::OL_LI)">
>    <p>
>      <ol>
>        <xsl:apply-templates select="." mode="li"/>
>      </ol>
>    </p>
> </xsl:if>

Then, my <OL_LI> items aren't processed at all in the embedded list. Though I
have an <OL_LI> list without embedded items that shows up fine.

And when I do this:

> <xsl:if test="not(preceding-sibling::*[1][self::OL_LI|self::EM_OL_LI])">
>    <p>
>      <ol>
>        <xsl:apply-templates select="." mode="li"/>
>      </ol>
>    </p>
> </xsl:if>

<p>
   <ol>
      <li>Top: Item 1</li>
      <p>
         <ol>
            <li>Sub A: Item 1</li>
         </ol>
      </p>
   </ol>
</p>

Which truncates the list when encountering the first <OL_LI> after a
<EM_OL_LI> tag. I am indeed using a very flat file which I am trying to add
hierarchy to. PARA tags are mixed in with OL_LI tags and EM_OL_LI tags. Sample
input is like:

<HEAD>
<PARA>
<PARA>
<OL_LI>
<OL_LI>
<EM_OL_LI>
<OL_LI>
<HEAD>
<PARA>

And I'm adding hierarchy through this:

<xsl:key name='stuffchildren' match="PARA | OL_LI"
  use="generate-id((..|preceding-sibling::HEAD)[last()])"/>

<xsl:template name="process-body">
  <xsl:apply-templates select="key('stuffchildren', generate-id())"/>
  <xsl:apply-templates select="HEAD"/>
</xsl:template>


<xsl:template match="HEAD">
  <sec>
    <title>
      <xsl:apply-templates/>
    </title>
    <xsl:apply-templates select="key('stuffchildren', generate-id())"/>
  </sec>
</xsl:template>


Which I thought could be part of my problem. But when I change it to be

<xsl:key name='stuffchildren' match="PARA | OL_LI | EM_OL_LI"
  use="generate-id((..|preceding-sibling::HEAD)[last()])"/>

so that it accounts for <EM_OL_LI> tags as well I get:

<p>
   <ol>
      <li>Top: Item 1</li>
      <p>
         <ol>
            <li>Sub A: Item 1</li>
         </ol>
      </p>
   </ol>
</p>
<p>
   <ol>
      <li>Sub A: Item1</li>
   </ol>
</p>
...

With all of the embedded lists being repeated in separate paragraphs at the
top level.

Thanks!

-Joe

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.