Register  Login       Search  
Forum  
 
  
 
Forum  Forum     
 
SearchForum Home
  XML Lab Products  nxslt  XInclude and pr...
 XInclude and preserving CDATA markup
 
vzakon
3 posts
Joined
4/16/2007

XInclude and preserving CDATA markup
Posted: 16 Apr 07 7:32 AM (United States) Modified By vzakon  on 4/16/2007 7:33:42 AM)
I am using nxslt to process XInclude.

Source fragment:
<HTML><![CDATA[<img src="/_layouts/images/]]></HTML>

Included fragment:
<HTML>&lt;img src="/_layouts/images/</HTML>

Is there a way to preserve CDATA markup of the source fragment?

Thanks.
Vladimir
olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: XInclude and preserving CDATA markup
Posted: 17 Apr 07 6:14 AM (Israel)

In nxslt even if you don't provide XSLT stylesheet, default (identity) stylesheet is used.

It's XSLT where you lose CDATA, because there is no CDATA in XPath/XSLT data model.

So instead of using nxslt then you should be using XIncludingReader from Mvp.Xml directly to avoid applying XSLT. XIncludnigReader preserves CDATA just fine.


Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
vzakon
3 posts
Joined
4/16/2007

Re: XInclude and preserving CDATA markup
Posted: 18 Apr 07 6:32 AM (United States)

I tryed below with no success in preserving CDATA.
How it can be done?

public static void XmlInclude(string inputUri, string outputUri)
{
   
using (XIncludingReader xir = new XIncludingReader(inputUri))
   {
      xir.ExposeTextInclusionsAsCDATA =
true;
      
if (xir.Read())
      {
         string s = xir.ReadOuterXml();
         File.WriteAllText(outputUri, s);
      }
   }
}

olegt
85 posts
www.xmllab.net
Joined
2/25/2005

Re: XInclude and preserving CDATA markup
Posted: 20 Jun 07 5:53 AM (Israel)
Works for me. Make sure you are using very latest Mvp.Xml library. Currently it's v2.2 Get it here: http://www.codeplex.com/MVPXML/Release/ProjectReleases.aspx?ReleaseId=931
Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net | http://blog.tkachenko.com
  XML Lab Products  nxslt  XInclude and pr...
Forum Home  Search