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

Re: Adding hierarchy

Subject: Re: Adding hierarchy
From: Jim_Albright@xxxxxxxxxxxx
Date: Mon, 13 Oct 2003 09:15:45 -0400
xml blankline
Thank you Dimitre. I see that I didn't give you enough info.
Your solution is close but I get 
    <lineGroup type="stanza"/>
when blankLine does not precede a lineGroup. 

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:key name="kLGroup" match="lineGroup"
  use="generate-id(preceding-sibling::blankLine[1])"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="blankLine">
   <lineGroup type="stanza">
     <xsl:copy-of select="key('kLGroup', generate-id())"/>
   </lineGroup>
  </xsl:template>

  <xsl:template match="lineGroup"/>

</xsl:stylesheet>

but source.xml can be more complicated with blankLine not preceding 
lineGroup:

<text>
  <blankLine/>
  <lineGroup>
    <line> </line>
    <line> </line>
  </lineGroup>
  <lineGroup>
    <line> </line>
    <line> </line>
    <lineGroup>
      <line> </line>
      <line> </line>
    </lineGroup>
    <line> </line>
  </lineGroup>
  <p/>
  <blankLine/>
  <p>This also happens. But does not produce a stanza.</p>
  <p/>
  <p/>
  <p/>
<lineGroup>
    <line>Make sure there is no stanza here</line>
    <line> </line>
    <lineGroup>
      <line> </line>
      <line> </line>
    </lineGroup>
    <line> </line>
  </lineGroup>
  <p/>
  <blankLine/>
  <lineGroup>
    <line> </line>
    <line> </line>
  </lineGroup>
  <lineGroup>
    <line> </line>
    <line> </line>
    <lineGroup>
      <line> </line>
      <line> </line>
    </lineGroup>
    <line> </line>
  </lineGroup>
  <p/>
</text>



 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.