473,324 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Dynamic XSL transformation

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
Phil
Nov 19 '05 #1
5 1167
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.

"PHILIPPE" <Ph************@voila.fr> wrote in message
news:43**************************@posting.google.c om...
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
Phil

Nov 19 '05 #2
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.
"PHILIPPE" <Ph************@voila.fr> wrote in message
news:43**************************@posting.google.c om...
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
Phil

Nov 19 '05 #3
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
--
Nov 19 '05 #4
Anders Borum wrote:
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? Yes, it does.
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!

They cache both XML and XSL, but they cache them in the internal cache.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 19 '05 #5
"SQL Server Development Team" <sq****@microsoft.com> wrote in message news:<#9*************@tk2msftngp13.phx.gbl>...
If your XSLT stylesheet is in a string then you can do

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

Thx Both, I'm going to give it a try.
Ciao
Phil
Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
5
by: PHILIPPE | last post by:
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...
1
by: krs | last post by:
I am using XML/XSL to build a dynamic asp.net control at runtime. So the result of the XML/XSL transformation may result in a string such as: <asp:TextBox id="TextBox1" runat="server">...
4
by: PengYu.UT | last post by:
Hi, Some dynamic polymorphism programs can be converted to the equavalent static polymorphism programs. I'm wondering if there are any generall procedures that I can use to do this conversion. ...
2
by: Alan Searle | last post by:
I find that I can display structured data very nicely using XML with an XSL template. As an extra 'goodie', I would like to give users the ability to sort that data (for example with a button...
0
by: Hugo Ferreira | last post by:
Hi all, I'm having a problem here, to which I hope someone to be able to help me :) I need to apply a XSLT transformation to the output of all my ASPX webpages. I've recently found the tag...
60
by: Peter Olcott | last post by:
I need to know how to get the solution mentioned below to work. The solution is from gbayles Jan 29 2001, 12:50 pm, link is provided below: >...
0
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab,...
1
by: sai krishna | last post by:
I am having a static xml document and would like to extract a portion of the xml and display it using xsl, but the condition on which to filter the xml document is dynamic in nature, Is there a way...
0
by: miamikk | last post by:
I am XML newbie. I have question about inserting dynamic text in the header of HTML table. This is the site I have created (Only Report Type 1 is working)...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.