Enviroment:
VS2003, Win XP, SQL Server 2000 SP2, .Net Framework 1.1,Data Access App Block 2.0, All current SP & Hotfixes
I am trying to retrieve XML from a Stored Procedure and transform the output using XSLT. The problem is that the XPath statemnents are not working correctly. If I load the data directly from a file into the XPathDocument, it works. Sorry for the log post, but thought it better to get it out front.
Any ideas why this would not work correctly?
Here is sample XML:
------------------------
<rows count="44">
<row id="2380"/>
<row id="2921"/>
.
.
</rows>
XSLT
------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<div> # Rows : <xsl:value-of select="count(rows/row)"/> </div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Code:
---------------------------
(simplified)
Dim SQLXML As XmlReader
Dim xml As XmlTextReader
Dim xslt As XslTransform = New XslTransform
Dim xDoc As XPathDocument
' Conn and arParams are created and valid
SQLXML = SqlHelper.ExecuteXmlReader(conn, CommandType.StoredProcedure, Query, arParams)
SQLXML.MoveToContent()
' The following does not produce a "# Rows"
xDoc = New XPathDocument(SQLXML, XmlSpace.Preserve)
'Yet this does with exact same XML, cut and paste from the above XPathDocument.OuterXML() (# Rows=44)
xDoc = New XPathDocument("dailyxml.xml")
xslt.Load("XSLTParamTest.xslt")
Dim fs As StreamWriter = File.CreateText("test.htm")
xslt.Transform(xDoc, xsltParam, fs)
-------------------------------------------