load a string with XslTransform

  • Thread starter Thread starter manlio
  • Start date Start date
M

manlio

how can I load a XSL string (not an xsl file!!) with XslTransform ???

If I use the code:

// Create a new XslTransform class and load the stylesheet
XslTransform myXslTransform = new XslTransform();
myXslTransform.Load("myFile.xsl");

it run, but I need load an XSL string:

XslTransform myXslTransform = new XslTransform();

xslString='<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="urn:var"
xmlns:userVBScript="urn:userVBScript"
xmlns:userJScript="urn:userJScript" exclude-result-prefixes="msxsl var
userVBScript userJScript" version="1.0"><xsl:output method="xml"
omit-xml-declaration="yes"/><xsl:template
match="/"><xsl:apply-templates
select="parameters"/>..........etc.etc.';

myXslTransform.Load(xslString);

and it doesn't run.


thanks,
manlio
 
manilo,

In .NET 1.1, you would take a StringReader, and pass that to an
XmlTextReader, and then pass that XmlTextReader to the XslTransform class
instance.

In .NET 2.0, that method is marked as obsolete, but there is an overload
which takes an XmlReader, an XmlResolver and Evidence (it's a more secure
method).

Hope this helps.
 

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

Back
Top