Re: [xsl] problem with xsl:choose

Subject: Re: [xsl] problem with xsl:choose
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 25 May 2001 11:33:13 +0100
Hi,

It would be very helpful if you gave an example of the output that
you're after.  But without that, I think that you want to have table
elements with a class of 'screen' for each screen element, and table
elements with a class of 'table' for each table element.  You can do
that with separate templates for the two types:

<xsl:template match="screen">
   <table class="screen" tID="{@h}">
      <xsl:call-template name="screenHdr" />
   </table>
</xsl:template>

<xsl:template match="table">
   <table class="table" tID="{@h}">
      <xsl:call-template name="tableHdr" />
   </table>
</xsl:template>

Applying templates to nodes is a good way of managing this because it
doesn't do anything unless the nodes exist in the first place.  If you
want to output something if they're not available, then you can add an
xsl:if that tests for it and emits an error as appropriate.

<xsl:template match="/">
   <xsl:apply-templates select="data/screen" />
   <xsl:apply-templates select="data/table" />
   <xsl:if test="not(data/screen or data/table)">
      error
   </xsl:if>
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread