473,761 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

load a string with XslTransform

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.xs l");

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="ur n:schemas-microsoft-com:xslt" xmlns:var="urn: var"
xmlns:userVBScr ipt="urn:userVB Script"
xmlns:userJScri pt="urn:userJSc ript" exclude-result-prefixes="msxsl var
userVBScript userJScript" version="1.0">< xsl:output method="xml"
omit-xml-declaration="ye s"/><xsl:templat e
match="/"><xsl:appl y-templates
select="paramet ers"/>..........etc. etc.';

myXslTransform. Load(xslString) ;

and it doesn't run.
thanks,
manlio
Nov 16 '05 #1
1 2794
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"manlio" <m.*********@of fnet.it> wrote in message
news:58******** *************** **@posting.goog le.com...
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.xs l");

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="ur n:schemas-microsoft-com:xslt" xmlns:var="urn: var"
xmlns:userVBScr ipt="urn:userVB Script"
xmlns:userJScri pt="urn:userJSc ript" exclude-result-prefixes="msxsl var
userVBScript userJScript" version="1.0">< xsl:output method="xml"
omit-xml-declaration="ye s"/><xsl:templat e
match="/"><xsl:appl y-templates
select="paramet ers"/>..........etc. etc.';

myXslTransform. Load(xslString) ;

and it doesn't run.
thanks,
manlio

Nov 16 '05 #2

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

Similar topics

3
17708
by: Christopher Ambler | last post by:
This has to be a FAQ, but I can't seem to find the answer anywhere! I have an application that consumes a web service that returns me a string full of XML. I also have an XSLT for outputting the XML. I need to take that string, apply the XSLT to it, and get the output into a string suitable for writing out to a tcp port. Essentially, an XML string, transformed into another string.
2
2667
by: Matt Frame | last post by:
I am building dynamic XSL using a string varible in VB.Net with information in code and from a database field. I am having a difficult time finding the correct object to load the string into to then have the object passed to the XslTransform.Load method. I want to avoid writing the information to a file and then using that if at all possible. Your help is greatly appreciated. Matt
3
5238
by: Torrent | last post by:
When Trying to Load an XSLT File with the XslTransform i got a rather annoying Exception being thrown "System.Xml.XPath.XPathException: XsltContext is needed for this query because of an unknown function." It was annoying because I had checked created the whole document and tested it in Internet Explorer 6.0 and everything worked perfectly; no errors or warnings. After doing research i found out that most often times the error that i was...
5
1845
by: Kevin Westhead | last post by:
I'm using XslTransform to apply a transform to an XML document, however I get validation problems when parsing the resulting XML document due to invalid whitespace. I'm passing in an XPathNavigator for the input to the Transform method and specifying a Stream for the output. Here is an example of a transform and a document (it's the IconStyle sections that are causing problems): <?xml version="1.0" encoding="UTF-16"?> <!-- Copyright...
0
1354
by: Robert Gaut | last post by:
I have a Windows service that reads messages off a message queue and performs several XSL transforms per message. The XSL documents are embedded resources in the executing assembly and several contain <xsl:include> statements. I'm using the XslTransform.Load() method which accepts an XPathNavigator, an XmlResolver, and an Evidence object. I've created a custom XmlResolver that resolves the embedded resource XSL documents and I'm passing...
3
3384
by: Paul Hatcher | last post by:
Hi I have a transform going from XML to HTML, but I can't seem to get the XslTransform class to output &amp; as & even when using disable-output-escaping. I've tried writing the result to a Stream, but it still always converts the values - it works fine if I use the MSXML library. Has anyone an idea how I can get it to obey.
4
2537
by: Mike Schilling | last post by:
In 1.0, there was a method call: XslTransform.Load(IXPathNavigable, XmlResolver) In 1.1, compiling a call to it gives a warning that this signature is obsolete and evidence should be suppied, that it, that a call to XslTransform.Load(IXPathNavigable, XmlResolver, Evidence) is preferred.
1
1173
by: Baren | last post by:
Hi! I have the following code in VB.NET ******** Dim mydata As New XmlDocument Dim xslt As New XslTransform mydata.Load("C:\Inetpub\wwwroot\VBTestProj\Sample.xml") xslt.Load("C:\Inetpub\wwwroot\VBPDFDemo\Sample.xslt") **************
2
4296
by: Mr Flibble | last post by:
Hi All I've decided to put my stylesheets in a base64 .resource file for deployment and versioning reasons. I dont know if it's a great idea to do this but I couldn't think of another way of doing this other than making them available via www which may or may not be accessible (so this is a no go). Bear with me because I've only been using C# for one day so far (today is day 2! wohoo). // begin code snippet
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.