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

RE: Flat to Structured: Handling List Items with Subo

Subject: RE: Flat to Structured: Handling List Items with Subordinate Paragraphs
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 26 May 2009 22:20:52 +0100
RE:  Flat to Structured: Handling List Items with  Subo
> For example, I could have an ordered list followed by an 
> unordered list, which would give a group like:
> 
> <p type="li" container="ol" level="1">
> <p type="p" container="li" level="2">
> <p type="li" container="ol" level="1">
> <p type="p" container="li" level="2">
> <p type="li" container="ul" level="1">
> <p type="p" container="li" level="2">
> 
> Where the result should be:
> 
> <ol>
>   <li>
>     <p>
>   </li>
>   <li>
>     <p>
>   <li>
> </ol>
> <ul>
>   <li>
>    <p>
>   <li>
> </ul>
> 
> I don't see a way to get that result using 
> group-starting-with on the group members.
> 

I haven't followed the thread closely, but I would tackle the above by first
using group-starting with to build the levels

<xsl:for-each-group select="*" group-starting-with="*[@level='1']">

applied recursively if necessary for each level, giving

<p type="li" container="ol" level="1">
  <p type="p" container="li" level="2">
</p>
<p type="li" container="ol" level="1">
  <p type="p" container="li" level="2">
</p>
<p type="li" container="ul" level="1">
  <p type="p" container="li" level="2">
</p>

and then apply group-adjacent to the level 1's (and perhaps recursively to
each level?):

<xsl:for-each-group select="*" group-adjacent="@container">
  <xsl:element name="{current-grouping-key()}">
    <xsl:copy-of select="current-group()"/>
  </
</

to give your required structure, with a bit of trivial tweaking needed to
change <p type="li"> to <li>.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

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.