[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Problem with xsl:copy
Subject: [xsl] Problem with xsl:copy From: "Schwartz, Rechell R, ALCAS" <rrschwartz@xxxxxxx> Date: Fri, 8 Nov 2002 09:16:02 -0500 |
All, I am trying to use the identity transformation to copy an HTML file and apply styling attributes to the <td> tags nested inside <tr> tags that meet certain criteria. The problem is the styling attributes are being applied to the <tr> tags instead of to the <td> tags (I want them applied to the td tags because of issues with Netscape). I think the problem has to do with the fact that xsl:copy doesn't make a deep copy, and I tried to use xsl:copy-of but without success. Following is my XSLT file: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:template match="node()|@*"> <!--identity transform--> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="tr[td[count(a) = 0 and text() != 'Data not available' and count(@*) = 0]]"> <xsl:copy> <xsl:choose> <xsl:when test="position() mod 2 = 0"> <xsl:for-each select="td"> <xsl:attribute name="class">evenRowStyle</xsl:attribute> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:for-each select="td"> <xsl:attribute name="class">oddRowStyle</xsl:attribute> </xsl:for-each> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet> The resulting xml file I am getting is: <tr class = "oddRowStyle"> <td>Name:</td><td>Susan</td> </tr> <tr class="evenRowStyle"> <td>Address:</td> <td>1 Maple Leaf Lane</td> </tr> What I want is: <tr> <td class="oddRowStyle">Name:</td><td class="oddRowStyle">Susan</td> </tr> <tr> <td class="evenRowStyle">Address:</td> <td class="evenRowStyle">1 Maple Leaf Lane</td> </tr> Any help would be greatly appreciated. Thanks, Rechell XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Formatting date, Ben Robb | Thread | Re: [xsl] Problem with xsl:copy, David Carlisle |
[xsl] Formatting date, Felix Garcia | Date | [xsl] Finiding nodes filtered by at, Schwartz, Rechell R, |
Month |