Search the web
Sign In
New User? Sign Up
tdom · tDOM - fast DOM / XPath for Tcl in C
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
CDATA in tdom   Message List  
Reply | Forward Message #1600 of 1984 |
Re: [tdom] CDATA in tdom



On 15 May, Moriz Wahl wrote:
> I have an XML-Document looking like this:
>
> <Equation ID="Equ1">
> <EquationSource Format="TEX">
> <![CDATA[$$
> P_{i} = \hat k{\left( {D_{1} ,D_{2} , \ldots D_{n} } \right)}\,,
> $$]]></EquationSource></Equation>
>
> --------------------------------------------------------------------------
> I tried this simple script:
>
> [...]
>
> What happened is, that the CDATA sections disappeared and became TEXT_NODEs
> instead. Why?

Because this is, what you normally want.

The probably major technical reason is, that the XPath data model
doesn't know anything about CDATA Sections.

I'm faced with the question the other way around: Why do you insist in
having the CDATA Sections in the serialized output? CDATA Sections are
just a fancy or crude alternative way to write XML Element pcdata
content. If you process your XML data with XML tools, there is no
difference between the two ways of writing.

> I wrote a workaround like this:
> -------------------------------------------------------
> foreach node [$root selectNodes //EquationSource] {
> set mynode [$node selectNodes text()]
> $doc createCDATASection [$mynode data] cdata
> $node appendChild $cdata
> $mynode delete
> }
> ------------------------------------------------------
> and got the output I wanted. Why this workaround. There could be other
> CDATA_SECTION_NODEs which I do not know before.

You seem to insist in getting the serialized XML output in one certain
way. Again: From the XML viewpoint there is no difference between the
serialization, you get by default from tDOM and the one, you force
with your workaround code - both serializations are exactly the same
data.

You don't have much control about the details of serialization with
tDOM (as for most other tools). In case of CDATA Sections, you may
have luck. If you use a half-way recent tDOM cvs head version (which
is, what you should do anyway), then the documentNode method
cdataSectionElements may help you. With that, your work around code
from above gets down to

$doc cdataSectionElements EquationSource 1

rolf





Tue May 15, 2007 5:13 pm

rolf@...
Send Email Send Email

Forward
Message #1600 of 1984 |
Expand Messages Author Sort by Date

Hello, although there is so much spam on the tdom-group, I hope to find some help this way. I have an XML-Document looking like this: <Equation ID="Equ1"> ...
Moriz Wahl
moriz.wahl
Offline Send Email
May 15, 2007
4:12 pm

... Because this is, what you normally want. The probably major technical reason is, that the XPath data model doesn't know anything about CDATA Sections. I'm...
rolf@...
Send Email
May 15, 2007
5:15 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help