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

Re: Re: Adding hierarchy

Subject: Re: Re: Adding hierarchy
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 13 Oct 2003 07:07:59 -0700 (PDT)
what does shopping hierarchy
> 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. 

You mean: does not *immediately* precede a line group?

If so, we need a slight change to reflect this modified requirement:


<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::*[1])"/> 

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

  <xsl:template 
   match="blankLine[following-sibling::*[1][self::lineGroup]]"> 
   <lineGroup type="stanza"> 
     <xsl:copy-of select="key('kLGroup', generate-id())"/> 
   </lineGroup> 
  </xsl:template> 

  <xsl:template 
   match="lineGroup[preceding-sibling::*[1][self::blankLine]]"/> 

</xsl:stylesheet> 


When this transformation is applied on your source.xml:

<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> 

the wanted result is produced:

<text>
   <lineGroup type="stanza">
      <lineGroup>
         <line/>
         <line/>
      </lineGroup>
   </lineGroup>
   <lineGroup>
      <line/>
      <line/>
      <lineGroup>
         <line/>
         <line/>
      </lineGroup>
      <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/>
      <lineGroup>
         <line/>
         <line/>
      </lineGroup>
      <line/>
   </lineGroup>
   <p/>
   <lineGroup type="stanza">
      <lineGroup>
         <line/>
         <line/>
      </lineGroup>
   </lineGroup>
   <lineGroup>
      <line/>
      <line/>
      <lineGroup>
         <line/>
         <line/>
      </lineGroup>
      <line/>
   </lineGroup>
   <p/>
</text>





 


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.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.