Subject: Re: [xsl] #Please Help: Nested conditions From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 20 Feb 2004 14:42:07 -0500 |
Can anyone please help me? O have the following problem I cannot solve:
I am trying to transform a table structure which is, simplified, like this:
<TABLE> <TITLE>...</TITLE> <TROW> <TH> ... </TH> </TROW> <TROW> <CELL> ... </CELL> </TROW> ... </TABLE>
The availability and number of <TROW> elements with a nested <TH> or, respectively, with a nested <TB> varies.
The objective is to drop the <TH>'s and <TB>'s, and to wrap all <TROW>'s that before contained a <TH> into a single <THEAD> element, and similarly to wrap all <TROW>'s that before contained a <TB> into a single <TBODY> element.
<xsl:template match="TABLE"> <TABLE> <TTITLE> <xsl:value-of select="TITLE"/> </TTITLE> <xsl:if test="TROW/TH"> <THEAD> <xsl:apply-templates select="TROW[TH]"/> </THEAD> </xsl:if> <TBODY> <xsl:apply-templates select="TROW[TB]"/> </TBODY> </TABLE> </xsl:template>
<xsl:template match="TROW"> <xsl:copy><xsl:apply-templates/></xsl:copy> </xsl:template>
<xsl:template match="TH|TB"> <TDATA><xsl:apply-templates/></TDATA> </xsl:template>
The XSL approach I have worked out so far is this:
<xsl:template match="TABLE"> <TABLE> <TTITLE> <xsl:value-of select="Table-TITLE"/> </TTITLE> <xsl:text disable-output-escaping="yes"> <TGROUP></xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes"> </TGROUP></xsl:text>
</TABLE> </xsl:template>
<xsl:template match="ROW"> <xsl:choose> <xsl:when test="element-available('TH')">
However, this approach does not work. What am I doing wrong?
-- Public courses: upcoming world tour of hands-on XSL training events Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong: 2004-05-17 Germany: 2004-05-24 England: 2004-06-07 World-wide on-site corporate, government & user group XML training!
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] #Please Help: Nested conditio, Matthias Fischer | Thread | RE: [xsl] #Please Help: Nested cond, Matthias Fischer |
Re: [xsl] Request for design tips: , Wendell Piez | Date | Re: [xsl] XSL Transformation Questi, J.Pietschmann |
Month |