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

Re: Trouble creating tables while looping through ele

Subject: Re: Trouble creating tables while looping through elements
From: Charles-Louis De Maere <charles-louis.demaere@xxxxxxxxxxxxxxx>
Date: Mon, 10 May 2010 11:31:02 +0200
Re:  Trouble creating tables while looping through  ele
Hi Robby, & Michael

Thanks for your help.

I will have to take the table declaration outside of the <xsl:template>
tag, because otherwise I create different tables for each node, which is
not what I expected.

Therefore, my resulting code looks like this :

<table><tbody><xsl:apply-templates select="node[condition
1]"/></tbody></table>
<table><tbody><xsl:apply-templates select="node[condition
2]"/></tbody></table>
...

<xsl:template match="node[condition 1]">
<tr>
    some processing
</tr>
</xsl:template>


On 10/05/2010 11:13, Michael Kay wrote:
Wrong approach: XSLT stylesheets produce a tree as the output, not lexical
XML; XSLT instructions create nodes on the tree, not tags in the serialized
XML.  So you can't write end tags and start tags as separate operations.

Ok, thanks for this explanation, it makes sense now that I see XSLT producing a tree rather than producing a raw text content.


Cheers,


Charles-Louis

On 10/05/2010 11:01, Robby Pelssers wrote:
Hi Charles,

It doesnt seem right to me that you create a tbody for each node. A table
typically has 1<thead> and 1<tbody> tag.

If you want to create different tables for different nodes based on some
condition it's best to create different templates using specific predicates.

<xsl:template match="node[condition predicitate 1]"> <table> ... </table> </xsl:template>

<xsl:template match="node[condition predicitate 2]">
   <table>
    ...
   </table>
</xsl:template>

Cheers,
Robby Pelssers

-----Original Message-----
From: Charles-Louis De Maere [mailto:charles-louis.demaere@xxxxxxxxxxxxxxx]
Sent: Monday, May 10, 2010 10:14 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Trouble creating tables while looping through elements

Dear all,

I'm looping through a (sorted) list of nodes, and would like to put them
in different tables based on a certain condition using xslt.

At the moment, I'm doing the following :

<table>
<xsl:for-each select="node">
<tbody>
          ... some formatting ...
</tbody>
<xsl:if test="not(subnode = following-sibling::node/subnode)">
</table>
<h2>Some Title</h2>
<table>
</xsl-if>
</xsl:for-each>
</table>

However, this XSLT file is invalid (XMLSpy indicates a warning when I
save it, because of the closing<table>  tag underneath the if-test), and
Firefox refuses to display it for the same reason.

Is there any easy way to have some kind of separation within the
for-each loop, or should I take this formatting out of the loop ?


Thanks in advance,


Charles-Louis de Maere

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.