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.LoadX ml(DataFormat); //DataFormat xsl string
XmlUrlResolver resolver = new XmlUrlResolver( );
XslTransform xslTran = new XslTransform();
xslTran.Load(tr ansform,resolve r,null);
XmlReader reader =
xslTran.Transfo rm(XmlData,null ,resolver);
reader.MoveToCo ntent();
string readerOutput = reader.ReadOute rXml();
//XSL
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="DataSour ce">
<B>Report</B><BR/>
<TABLE CELLPADDING="1" CELLSPACING="1" Border="1">
<TR><TH>Agreeme nt Number</TH>
<TH>Name</TH>
<TH>Period</TH>
<TH>Due Date</TH>
<TH>Type</TH>
</TR>
<xsl:for-each select="tblRepo rt[code='XYZ']">
<TR>
<TD><xsl:valu e-of select="Agreeme ntNumber"/></TD>
<TD><xsl:valu e-of select="Name"/></TD>
<TD><xsl:valu e-of select="Period"/></TD>
<TD><xsl:valu e-of select="DueDate "/></TD>
<TD><xsl:valu e-of select="Type"/></TD>
</TR>
</xsl:for-each>
<</xsl:template>
</xsl:stylesheet>