XSL transform Using XSL.Transform

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>
 
H

Herfried K. Wagner [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top