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

RE: Generating implicit wrapper element

  • To: <xml-dev@l...>
  • Subject: RE: Generating implicit wrapper element
  • From: "Harbarth, Juliane" <Juliane.Harbarth@s...>
  • Date: Tue, 30 Aug 2005 15:20:03 +0200
  • Thread-index: AcWtYrze+7i1r4pTQoiB6bNWMm59QgAAvWqg
  • Thread-topic: Generating implicit wrapper element

wrapper element xml
 

Hi Ferdinand,

there is an XSL list at http://www.mulberrytech.com/xsl/xsl-list/ that
is more appropriate for your question.

Anyway, the idea to pack all li's into one ul is to have a template
for the first li (match="li[1]") that introduces both the <ul> and the 
</ul> tag and includes all li's in between using the following-sibling 
axis. Another template is needed to ignore the non-first li's.

Regards,
Juliane.

-----Original Message-----
From: Ferdinand Soethe [mailto:xml-dev@s...] 
Sent: Dienstag, 30. August 2005 14:56
To: xml-dev@l...
Subject:  Generating implicit wrapper element


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>

My attempt to solve this with

<xsl:template match="Aufzaehlungspunkt">
    
  <xsl:if test="not(preceding-sibling::li)">
    <ul>
  </xsl:if>
  
  <li><xsl:apply-templates/></li>

  <xsl:if test="not(following-sibling::li)">
    </ul>
  </xsl:if>

</xsl:template>

ran into two separate problems:

1. I'm not allowed to use <ul> without the matching </ul> (even though
   that is in a separate if-branch below.

2. The preceding-sibling and following-sibling-axes are only true when
   dealing with the very first and the very last <li> in the document.
   So rather than meaning 'previous element is not <li>' the meaning
   'there is no more previous <li>-element in this document'.

Any ideas how to solve these problems with XML?

Oh, btw. I saw the solution suggested some years ago

<officers>
<xsl:for-each select='/doc/person[@er="officer"]'>
<person><xsl:value-of select='.'/></person> </xsl:for-each> </officers>

<xsl:for-each select='/doc/person[not(@er="officer")]'>
<person><xsl:value-of select='.'/></person> </xsl:for-each>

</perslist>
 </xsl:template>

 but this doesn't seem to be an option since I'm not using the
procedural style of processing my document.

 Thanks for any input,

 --
 Ferdinand

--
Ferdinand Soethe


-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://www.oasis-open.org/mlmanage/index.php>


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.