XSL transform Using XSL.Transform

  • Thread starter Thread starter John Lehmann
  • Start date Start date
J

John Lehmann

I have an interesting problem. I am performing an XSL
transform using the System.Xml.Xsl.Transform class.
I have a database that contains the XSL style sheet
string. And it seems to work pretty well for simple
transforms. But as soon as I add Xsl variables or For each
loops to the XSL string in the db, it fails to transform
the XML. I can see that it will transform everything until
that point. ALso If I copy the XSL & XML I am trying to
transform from my watch window into a file.. It works
perfectly. Any Ideas?
The following is the C# code I am using to transform & the
XSL I am using to transform.

//Code
XmlDocument transform = new XmlDocument();
transform.LoadXml(DataFormat); //DataFormat xsl string

XmlUrlResolver resolver = new XmlUrlResolver();
XslTransform xslTran = new XslTransform();
xslTran.Load(transform,resolver,null);

XmlReader reader =
xslTran.Transform(XmlData,null,resolver);
reader.MoveToContent();
string readerOutput = reader.ReadOuterXml();

//XSL
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="DataSource">
<B>Report</B><BR/>
<TABLE CELLPADDING="1" CELLSPACING="1" Border="1">
<TR><TH>Agreement Number</TH>
<TH>Name</TH>
<TH>Period</TH>
<TH>Due Date</TH>
<TH>Type</TH>
</TR>
<xsl:for-each select="tblReport
Code:
">
<TR>
<TD><xsl:value-of select="AgreementNumber"/></TD>
<TD><xsl:value-of select="Name"/></TD>
<TD><xsl:value-of select="Period"/></TD>
<TD><xsl:value-of select="DueDate"/></TD>
<TD><xsl:value-of select="Type"/></TD>
</TR>
</xsl:for-each>
<</xsl:template>
</xsl:stylesheet>
 
Hello,

John Lehmann said:
I have an interesting problem. I am performing an XSL
transform using the System.Xml.Xsl.Transform class.

This is a Windows Form group. You will more likely get an answer if you
post this question to this group:

news://news.microsoft.com/microsoft.public.dotnet.xml
 
Back
Top