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

Generating implicit wrapper element

Subject: Generating implicit wrapper element
From: Ferdinand Soethe <xsl-list@xxxxxxxxxx>
Date: Tue, 30 Aug 2005 18:37:00 +0200
 Generating implicit wrapper element
I have a question about the problem below which has already been
identified as a 'positional grouping problem'. (I think) I understand
the Muenchian method-based solutions suggested (at least in theory).

What I don't understand is what is wrong about using the following simple
solution that I pieced together from different postings:

<xsl:template match="li">
    <xsl:if test="(name(preceding-sibling::*[1])!='li' )">
        <xsl:text disable-output-escaping="yes">&lt;ul&gt;</xsl:text>
    </xsl:if>
    <li><xsl:copy-of select="@*"/><xsl:apply-templates/></li>
    <xsl:if test="(name(following-sibling::*[1])!='li' )">
        <xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
    </xsl:if>
  </xsl:template>

Seems like it fits much better into my context of using
'apply-templates' as much as possible (no need to process all li's at
once and ignore them later) and - except for that hack of
smuggling half the ul-element into my output - it also seems quite
reasonable xsl, not?

Your input much appreciated,

--
Ferdinand Soethe


--- The problem ---

I have an XML-document with paragraphs and list items that have no
wrapper element around each list.

Something like this:

<par>my first para</par>
<par>second para</par>
<li>first list item of first list</li>
<li>second list item of first list</li>
<li>third list item of first list</li>
<par>third para</par>
<li>first list item of second list</li>
<par>fourth para</par>
<li>first list item of third list</li>
<li>second list item of third list</li>

In my transformation I would like to add these implicit wrapper
element around each of the list to get something like

<p>my first para</p>
<p>second para</p>
<ul>
<li>first list item of first list</li>
<li>second list item of first list</li>
<li>third list item of first list</li>
</ul>
<p>third para</p>
<ul>
<li>first list item of second list</li>
</ul>
<p>fourth para</p>
<ul>
<li>first list item of third list</li>
<li>second list item of third list</li>
</ul>

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.