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

RE: Templates for different kinds of tags?

Subject: RE: Templates for different kinds of tags?
From: cknell@xxxxxxxxxx
Date: Thu, 22 Mar 2007 14:32:08 -0400
RE:  Templates for different kinds of tags?
You don't need (and probably shouldn't use) <xsl:choose> for this purpose. Let the processor do the work, not the programmer.

For different table types:

<table style="simple">
<table style="xyz">


Write templates that match the specific table types:

<xsl:template match="table[@style='simple']">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="table[@style='xyz']">
    <xsl:apply-templates />
</xsl:template>

<xsl:template match="tr[parent::table[@style='simple']]">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="td[parent::tr[parent::table[@style='simple']]]">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="td[parent::tr[parent::table[@style='xyz']]]">
  <xsl:apply-templates />
</xsl:template>
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Thomas Zastrow <listen@xxxxxxxxxxxxxxxxx>
Sent:     Thu, 22 Mar 2007 19:19:15 +0100
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:   Templates for different kinds of tags?

Hi there,

I'm not so familiar with XSL, please be patient ;-)

I have a XML-document (not HTML) with tables like this:

<table>
<tr>
<td></td><td></td>
</tr>
</table>

So, I have three templates for them:

<xsl:template match="table">
<xsl:template match="tr">
<xsl:template match="td">

Now, I want to use different kinds of tables in my XML-doc like

<table style="simple">
<table style="xyz">

Depending on the style-attribut, I can change the template-code for 
<table> with  xsl:choose. But, the <tr>- and <td>-tags are still the 
same code, so, they will always use the same templates. But I also want 
to change the code for tr and td, depending on the style of the complete 
table.

Is this possible or have I to write the xsl:choose - statement again in 
the tr- and in the td-templates?

Thank you!

Best,

Tom

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.