Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 13th, 2007, 06:29 PM
Registered User
Join Date: Feb 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default problems with escaping characters when transformin

I have xml saved in database that looks like this
<Root><aaa>&amp; &lt; &gt; </aaa></Root>.

I'm trying to transform this into another xml which should looks like this.
<Root><Value><![CDATA[<aaa>&amp; &lt; &gt; </aaa>]]></Value></Root>

Doing the transform in two different places and getting two different results. My xslt does uses <xsl:copy-of> to copy the aaa node.

In altova XmlSpy and it gives me what I want. But in C#, ASP.NET 1.0 I'm getting the following. When I work with whats in the cdata, it is bad xml now.
<Root><Value><![CDATA[<aaa>& < > </aaa>]]></Value></Root>

Xslt Code is something like this:
<xsl:element name="Root">
  <xsl:element name="Value">
    <xsl:value-of select="$StartCDATA" disable-output-escaping="yes"/>
      <xsl:copy-of select="aaa"></xsl:copy-of>
    <xsl:value-of select="$EndCDATA" disable-output-escaping="yes"/>
C# code:
MemoryStream ms = new MemoryStream();

//Load the xslt and do the transform
XmlUrlResolver resolver = new XmlUrlResolver();
XslDoc.Load(XslMasterDoc, resolver, Assembly.GetExecutingAssembly().Evidence);
XslDoc.Transform(XmlSourceData, null, ms, resolver);

StreamReader sr = new StreamReader(ms);
ms.Seek(0, SeekOrigin.Begin);
string returnValue = sr.ReadToEnd();
Help would be greatly appreciated.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with ASP e-mail for non-Latin characters nikosdra Classic ASP Basics 12 October 23rd, 2008 06:19 AM
escaping of characters in xsl:attribute pramod Classic ASP XML 1 September 12th, 2008 09:11 AM
Algorithmic problem transformin table with colspan fmilano XSLT 1 June 18th, 2007 02:29 PM
Escaping < and > barnaclebarnes XSLT 4 October 5th, 2004 08:56 AM

All times are GMT -4. The time now is 08:40 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.