[xsl] .Net compiledTransform

Subject: [xsl] .Net compiledTransform
From: "Rick Roen" <Rick@xxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Nov 2006 07:03:29 -0600
I'm confused by the results I am getting from VB.Net 2005
XslCompiledTransform.

I have the complete XSLT documents below, but it boils down to this:

Source doc:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Report>
	<ReportInfo>
		<CompanyName>Renee's Garden LLC</CompanyName>
		<ReportName>Cookbook sales report</ReportName>
		<OtherInfo>10/01/2006 to 10/31/2006</OtherInfo>
		<OtherInfo>Report date 11/20/2006 6:29:11 AM</OtherInfo>
	</ReportInfo>
	<Columns>
		<column align="left">Invoice no</column>
		<column align="left">Invoice date</column>
		<column align="left">Item no</column>
		<column align="left">Description</column>
		<column align="right">Total shipped</column>
		<column align="right">Order count</column>
		<column align="right">Cost</column>
	</Columns>
... other tags left out for brevity

Transformed by:

	<xsl:template match="Columns" mode="colgroup">
		<colgroup>
			<xsl:for-each select="column">
				<col>
					<xsl:attribute name="align"
select="@align"/>
				</col>
			</xsl:for-each>
		</colgroup>
	</xsl:template>

When I run the transformation using XMLSpy, I get the results I expect in
the colgroup tags:

				<colgroup>
					<col align="left"/>
					<col align="left"/>
					<col align="left"/>
					<col align="left"/>
					<col align="right"/>
					<col align="right"/>
					<col align="right"/>
				</colgroup>

When I run using .net I get: (it does not read the @align attribute)

        <colgroup>
          <col align="">
          <col align="">
          <col align="">
          <col align="">
          <col align="">
          <col align="">
          <col align="">
        </colgroup>

What am I doing wrong in .Net?


XSLT doc:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:fn="http://www.w3.org/2005/xpath-functions"; >
	<xsl:output method="xhtml" media-type="application/xhtml+xml"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
exclude-result-prefixes="xs fn" omit-xml-declaration="yes"
encoding="iso-8859-1"/>
	<xsl:template match="Report">
		<html>
			<head>
				<xsl:apply-templates select="ReportInfo"
mode="title"/>
			</head>
			<body>
				<xsl:apply-templates select="ReportInfo"
mode="headline"/>
				<table border="2px">
					<thead>
						<xsl:apply-templates
select="Columns" mode="colgroup"/>
						<xsl:apply-templates
select="Columns" mode="header"/>
					</thead>
					<tbody>
						<xsl:apply-templates
select="ReportTable"/>
						<xsl:apply-templates
select="Footer"/>
					</tbody>
				</table>
			</body>
		</html>
	</xsl:template>
	<!-- ==================================== -->
	<xsl:template match="Footer">
	<tr>
	<xsl:for-each select="./*">
	<td  class="footer"><xsl:value-of select="."/> </td>
	</xsl:for-each>
		
	</tr>
	</xsl:template>
	<!-- ==================================== -->
	<xsl:template match="ReportInfo" mode="title">
		<title>
			<xsl:value-of select="ReportName"/> <xsl:value-of
select="OtherInfo[1]"/>
		</title>
		<style type="text/css">
					* { font-family: arial, sans-serif;}
					table {font-size:10pt;}
					.header {background-color: navy;
color: white; font-weight: bold;}
					td {font-weight: normal; }
					.footer {
background-color:navajowhite; font-weight: bold; }
				</style>
	</xsl:template>
	<!-- ==================================== -->
	<xsl:template match="ReportInfo" mode="headline">
		<h3>
			<xsl:value-of select="CompanyName"/>
		</h3>
		<h4>
			<xsl:value-of select="ReportName"/>
		</h4>
		<xsl:for-each select="OtherInfo">
			<h5>
				<xsl:value-of select="."/>
			</h5>
		</xsl:for-each>
	</xsl:template>
	<!-- ==================================== -->
	<xsl:template match="Columns" mode="colgroup">
		<colgroup>
			<xsl:for-each select="column">
				<col>
					<xsl:attribute name="align"
select="@align"/>
				</col>
			</xsl:for-each>
		</colgroup>
	</xsl:template>
	<!-- =================================== -->
	<xsl:template match="Columns" mode="header">
		<tr>
			<xsl:for-each select="./*">
				<td class="header">
					<xsl:value-of select="."/>
				</td>
			</xsl:for-each>
		</tr>
	</xsl:template>
	<!-- =================================== -->
	<xsl:template match="ReportTable">
		<tr>
			<xsl:for-each select="./*">
				<td>
					<!--<xsl:apply-templates
mode="td"/>-->
					<xsl:choose>
						<xsl:when test=". = ''
"><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text> </xsl:when>
						<xsl:otherwise><xsl:value-of
select="."/></xsl:otherwise>
					</xsl:choose>
				</td>
			</xsl:for-each>
		</tr>
	</xsl:template>
	<!-- =================================== -->
	<xsl:template match="/" mode="td">
		<xsl:value-of select="."/>
	</xsl:template>
	<!--<xsl:template match="*"></xsl:template>-->
</xsl:stylesheet>

Current Thread