all groups > dotnet xml > august 2003 >
You're in the

dotnet xml

group:

Dynamic XSL transformation


Dynamic XSL transformation Philippe.graca NO[at]SPAM voila.fr
8/18/2003 10:35:52 AM
dotnet xml:
Hi,
I'm facing a annoying problem.
In the old ASP times, I was able to construct dynamically an XSL file
and then apply it to my XML file to create the HTML output.
Today, with the .NET framework, I can't find how to do this.
Of course, if my XSL file is already existing in my disk, it's easy
as:
/////
XPathDocument doc = new
XPathDocument(Server.MapPath("XML/Customers.xml"));
XslTransform trans = new XslTransform();
trans.Load(Server.MapPath("XSLT/Customers.xslt"));
StringWriter sw = new StringWriter();
trans.Transform(doc,null,sw,null);
this.txtStringBuilder.Text = sw.ToString();
sw.Close();
///
But how can I apply a transformation base on an XSL memory created
file?
Thx & regards


Re: Dynamic XSL transformation Sergey Dubinets
8/18/2003 11:17:25 AM
You can generate XSL in string and load XslTransform from this string.
string xslText = "<foo xsl:version='1.0' xmlns:xsl='...' />";
XslTransform trans = new XslTransform();
trans.Load(StreangReader(xslText));

Note: loading stylesheet is a expensive. So if performance is important in
this case, I'd recommend you to cache loaded stylesheets.

Sergey
--
This posting is provided "AS IS" with no warranties, and confers no rights.

[quoted text, click to view]

Re: Dynamic XSL transformation SQL Server Development Team
8/18/2003 11:20:49 AM
If your XSLT stylesheet is in a string then you can do

trans.Load(new XmlTextReader(new StringReader(xsltString)));

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Re: Dynamic XSL transformation Philippe.graca NO[at]SPAM voila.fr
8/18/2003 11:22:52 PM
[quoted text, click to view]


Thx Both, I'm going to give it a try.
Ciao
Caching XSLT objects? Anders Borum
8/18/2003 11:36:51 PM
Hello!

Now that we're talking about the importance of caching XSLT stylesheets, I
was wondering if any of you know whether the XML control provided by ASP.NET
keeps an internal cache of the loaded XSLT stylesheet?

It seems like they're setting a cachedependency on the physical XSLT
stylesheet (file), but I haven't investigated this. An easy way to check
this could be to display all keys in the Cache .. and see if anything
changes!

Ideas? :-)

--
venlig hilsen / with regards
anders borum
--

Re: Caching XSLT objects? Oleg Tkachenko
8/19/2003 12:58:43 AM
[quoted text, click to view]
Yes, it does.

[quoted text, click to view]
They cache both XML and XSL, but they cache them in the internal cache.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
AddThis Social Bookmark Button