|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using XSL to Translate Repetitive-Node XML to Tabl
Wendell,
Thanks for your input. That "tricky part" that you mention is EXACTLY what
had me hung up.
I'm having a little trouble trying to tie all these pieces together to get
the results (Bear with me please. I'm DEFINITELY an XSL newbie and it just
isn't "clicking" as quickly as I'd hope).
Here's my XSLT document, having applied your changes:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" indent="yes"
omit-xml-declaration="yes"/>
<xsl:variable name="count">
<xsl:apply-templates select="." mode="gimme-count"/>
</xsl:variable>
<xsl:template match="column_header">
<table>
<xsl:for-each select="header">
<tr>
<xsl:for-each select="data">
<xsl:call-template
name="headers"/>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name="headers" match="data">
<xsl:if test="not(@name =
preceding-sibling::data[1]/@name)">
<xsl:variable name="count">
<xsl:apply-templates select="."
mode="gimme-count"/>
</xsl:variable>
<td colspan="{$count}">
<xsl:apply-templates
select="@name"/>
<!-- the built-in default template
for attributes will emit its value -->
</td>
</xsl:if>
</xsl:template>
<xsl:template match="data" mode="gimme-count">
<xsl:parameter name="so-far" select="1"/>
<xsl:choose>
<xsl:when
test="not(following-sibling::data[1]/@name = current()/@name)">
<!-- if our next data sibling
doesn't have the same name, we're done -->
<xsl:value-of select="$so-far"/>
</xsl:when>
<xsl:otherwise>
<!-- if it does, we apply this same
template to it, incrementing our counter -->
<xsl:apply-templates
select="following-sibling::data[1]" mode="gimme-count">
<xsl:with-param
name="so-far" select="$so-far + 1"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Now I'm receiving a validation error:
Keyword xsl:parameter may not be used here.
Any suggestions?
Thanks,
Leo
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








