473,811 Members | 3,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting unescaped XML from a transform

Hello,

I have a stylesheet that contains C# functions to generate XML. When I
apply the stylesheet to my document, everything works perfectly except
the data I get back is escaped like so:

<test>thi s is a test</test>

I need to get <test>this is a test</testrather than the escaped data.
Any input would be appreciated.

Stylesheet

<?xml version='1.0'?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="ur n:schemas-microsoft-com:xslt"
xmlns:user="htt p://mycompany.com/mynamespace">
<xsl:output method="text"/>
<msxsl:script language="C#" implements-prefix="user">

<![CDATA[
string createStatement (XPathNodeItera tor root){
return "<test>this is a test</test>";

}

]]>
</msxsl:script>
<xsl:template match="/" >

<xsl:value-of select="user:cr eateStatement(. )"
disable-output-escaping="yes"/>

</xsl:template>

</xsl:stylesheet>

Code that does the transform:

static void Main(string[] args)
{
string stylesheet = args[0];
string filename = args[1];

//Create the XslTransform and load the stylesheet.
XslTransform xslt = new XslTransform();
xslt.Load(style sheet);

//Load the XML data file.
XPathDocument doc = new XPathDocument(f ilename);

//Create an XmlTextWriter to output to the console.
XmlTextWriter writer = new XmlTextWriter(C onsole.Out);
writer.Formatti ng = Formatting.Inde nted;
//Transform the file.

xslt.Transform( doc, null, writer, null);
writer.Close();

}

Sep 26 '06 #1
1 1756


th***********@y ahoo.com wrote:

string createStatement (XPathNodeItera tor root){
return "<test>this is a test</test>";
Well you pass back a string and not any data types the XSLT engine
recognizes as nodes to be processed (like XPathNavigator,
XPathNodeIterat or).

<xsl:value-of select="user:cr eateStatement(. )"
disable-output-escaping="yes"/>
//Create an XmlTextWriter to output to the console.
XmlTextWriter writer = new XmlTextWriter(C onsole.Out);
writer.Formatti ng = Formatting.Inde nted;
//Transform the file.

xslt.Transform( doc, null, writer, null);
disable-output-escaping is not supported when transforming to an
Xml(Text)Writer .
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 26 '06 #2

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

Similar topics

2
2172
by: Patrik Carlsson | last post by:
I have a problem using Xerces with a template for a generic page-header getting a sub-tree as argument. The same stylesheet is working flawlessly in IE and Mozilla, though it would be nice to have a result-file to work with too. Here is an example (xerces only get a collapsed string through), any suggestions or current bug-reports are welcome. / Patrik
2
1024
by: John Lehmann | last post by:
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...
10
5855
by: juglesh | last post by:
hello, I've put in my time searching, so I'll ask now<G> I need to look at the url, if a variable is present in the query string. so, if my address bar looks like: www.domain.com?THIS=yes&that=yes&something=180&otherthing=154 I need it to look for THIS if THIS is present, and THIS= yes then MyVar = "my string here"
5
2164
by: Don | last post by:
Hi: I have created an xsd from my xml document. I pop this xsd in the following directory: C:\program files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml. That give me intellisense when I specify the name space. But leaving hte namespace in messes up my transforms. Is there any way to get this intellisense functionality without adding the namespace all the time? Thanks,
2
1243
by: darrel | last post by:
On my page right now, I call a function: <%=getMenu()%> in my codebehind, I have the function do an xslt transformation: sub xslt.Transform(doc, xslArg, Response.Output, Nothing) end sub
2
3064
by: PatC | last post by:
I am converting a web deployment system from asp to aspx. The old system used the MSXML2.FreeThreadedDOMDocument and did a .transformNode. The .Net system uses XslTransform() and does a .Transform. My problem is that the resulting HTML page is slightly different in that the does not convert the &lt; and &gt; to < and > in the HTML Is there a switch or parameter in the Transform or the XslTransform that will cause the proper escaping ...
6
4970
by: Vijai Kalyan | last post by:
Hello, I am trying to use std::transform to take in a collection of strings, transform them and insert the result into an output container. So, I wrote something like this: std::wstring doSomething (std::wstring const& str) { // do something to copy of str and return new value }
2
8836
by: Simon Harvey | last post by:
Hi all, I'm having a real problem with getting an XMLWriter as a result of an xsl tranform I'm attempting. My code is: private void btnPerformTransform_Click(object sender, EventArgs e) { // Load the style sheet. XslCompiledTransform xslt = new XslCompiledTransform();
3
6507
by: Fredrik Lundh | last post by:
Ghirai wrote: you can get some info via (undocumented?) attributes on the file handle: <httplib.SSLFile instance at 0x00CE2508> '/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA' '/C=US/ST=California/L=Mountain View/O=Google Inc/CN=mail.google.com'
0
10651
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...
0
10392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10136
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...
1
7671
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
6893
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
5555
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...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
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
2
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.