[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: Eliot Kimber <ekimber@xxxxxxxxxxxx>
Date: Tue, 26 May 2009 15:31:21 -0500
Re:  Flat to Structured: Handling List Items with  Subo
On 5/26/09 3:04 PM, "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:

>> Can anyone point me in the right direction?
> Consider the solution below.  I'm making assumptions like a container
> is defined by adjacent elements with @container, and that the
> container type is homogenous (so I only need to look at the first),
> and that list items are always of type 'li'.  It gives what you are
> asking for, but you may need to modify it based on a more precise
> definition of containers.

Hmmm--took me a minute to see the boolean(@container) in this line:

<xsl:for-each-group select="*" group-adjacent="boolean(@container)">

So that has the effect of creating a group for each continguous sequence of
contained things, which is certainly a characteristic I can impose on my
data (I control both the set of named styles and how they map to the
annotations added the <p> elements in the data being processed).

Given that, I think I should be able to process the group of contained
things with recursive for-each-groups.


> I hope this helps.
> . . . . . . . . . .  Ken
> T:\ftemp>type eliot.xml
> <doc>
> <p type="para" level="1">Para 1</p>
> <p container="ol" type="li" level="1">ol item 1</p>
> <p container="li" type="para" level="2">Para w/in li</p>
> <p container="ol" type="li" level="1">ol item 2</p>
> <p container="li" type="para" level="2">Para w/in li</p>
> <p type="para" level="1">Para 2</p>
> </doc>
> T:\ftemp>xslt2 eliot.xml eliot.xsl
> <?xml version="1.0" encoding="UTF-8"?>
> <para>Para 1</para>
> <ol>
>     <li>ol item 1<para>Para w/in li</para>
>     </li>
>     <li>ol item 2<para>Para w/in li</para>
>     </li>
> </ol>
> <para>Para 2</para>
> T:\ftemp>type eliot.xsl
> <?xml version="1.0" encoding="US-ASCII"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                  version="2.0">
> <xsl:output indent="yes"/>
> <xsl:template match="doc">
>    <!--determine containers by the members being adjacent-->
>    <xsl:for-each-group select="*" group-adjacent="boolean(@container)">
>      <xsl:choose>
>        <xsl:when test="@container">
>          <!--at a container of a particular type-->
>          <!--create the necessary kind of container-->
>          <xsl:element name="{@container}">
>            <!--populate the container-->
>            <xsl:for-each-group select="current-group()"
>                                group-starting-with="*[@type='li']">
>              <li>
>                <xsl:apply-templates select="node()"/>
>                <xsl:apply-templates select="current-group()[position()>1]"/>
>              </li>
>            </xsl:for-each-group>
>          </xsl:element>
>        </xsl:when>
>        <xsl:otherwise>
>          <!--not at a container; just constitute the elements-->
>          <xsl:apply-templates select="current-group()"/>
>        </xsl:otherwise>
>      </xsl:choose>
>    </xsl:for-each-group>
> </xsl:template>
> <xsl:template match="*">
>    <xsl:element name="{@type}">
>      <xsl:apply-templates/>
>    </xsl:element>
> </xsl:template>
> </xsl:stylesheet>
> T:\ftemp>
> --
> XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08
> Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
> Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
> Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
> Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
> G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
> Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
> Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Eliot Kimber | Senior Solutions Architect | Really Strategies, Inc.
email:  ekimber@xxxxxxxxxxxx <mailto:ekimber@xxxxxxxxxxxx>
office: 610.631.6770 | cell: 512.554.9368
2570 Boulevard of the Generals | Suite 213 | Audubon, PA 19403
www.reallysi.com <http://www.reallysi.com>  | http://blog.reallysi.com
<http://blog.reallysi.com> | www.rsuitecms.com <http://www.rsuitecms.com> 

Current Thread


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.
First Name
Last Name
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.