I'm sure the answer is obvious, but I can't seem to find it.
I have the following XML:
<?xml version="1.0" encoding="UTF-8" ?>
<switches>
<finishes>
<finish>
Almond Decorative
<hold>no</hold>
</finish>
<finish>
Commercial
<hold>no</hold>
<hold>yes</hold>
</finish>
<finish>
Ivory Decorative
<hold>no</hold>
<hold>yes</hold>
</finish>
<finish>
White Decorative
<hold>no</hold>
</finish>
</finishes>
</switches>
And this stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" />
<xsl:template match="/">
<table border="1" cellspacing="0" cellpadding="0"
cols="{count(//hold)+1}">
<tr class="finish">
<th rowspan="2">Time Cycle</th>
<xsl:apply-templates select="/switches/finishes" />
</tr>
<tr class="hold">
<xsl:apply-templates select="/switches/finishes/finish"
mode="hold" />
</tr>
</table>
</xsl:template>
<xsl:template match="finishes">
<xsl:for-each select="finish">
<th colspan="{count(descendant::hold)}">
<xsl:value-of select="." />
</th>
</xsl:for-each>
</xsl:template>
<xsl:template match="finish" mode="hold">
<xsl:for-each select="hold">
<th>
<xsl:value-of select="current()" />
</th>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Which produces the following output:
<table border="1" cellspacing="0" cellpadding="0" cols="7">
<tr class="finish">
<th rowspan="2">Time Cycle</th>
<th colspan="1">Almond Decorativeno</th>
<th colspan="2">Commercialnoyes</th>
<th colspan="2">Ivory Decorativenoyes</th>
<th colspan="1">White Decorativeno</th>
</tr>
<tr class="hold">
<th>no</th>
<th>no</th>
<th>yes</th>
<th>no</th>
<th>yes</th>
<th>no</th>
</tr>
</table>
That's the correct output (according to Michael Kay's 2nd edition the string
value of an element is the string value of the element and all it's children
concatenated). But I need to get the string value WITHOUT the concatenation. IE
I want my output to look like:
<table border="1" cellspacing="0" cellpadding="0" cols="7">
<tr class="finish">
<th rowspan="2">Time Cycle</th>
<th colspan="1">Almond Decorative</th>
<th colspan="2">Commercial</th>
<th colspan="2">Ivory Decorative</th>
<th colspan="1">White Decorative</th>
</tr>
<tr class="hold">
<th>no</th>
<th>no</th>
<th>yes</th>
<th>no</th>
<th>yes</th>
<th>no</th>
</tr>
</table>
I'm having exactly zero luck on this one though. Using MSXML 4.0 SP 1 for this.
Craig
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list