Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
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.

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

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