[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: data vs. xml

Subject: RE: data vs. xml
From: "bix xslt" <bix_xslt@xxxxxxxxxxx>
Date: Thu, 03 Apr 2003 17:57:20 +0000
translate.lt
Lars,

You are correct, the data would not be considered valid xml data and the processor dies immediately. The data contained within the node is CDATA. I think I have my answer though, I need to ensure that the nodes have a set of <![CDATA[ ...data here... ]]> tags in them.

Thanks,
bix

From: "Lars Huttar" <lars_huttar@xxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE:  data vs. xml
Date: Thu, 3 Apr 2003 11:45:25 -0600

bix xslt wrote:

> All,
>
> Is there a way to identify a node as containing cdata?
>
> eg.
> <node>
> <dataNotNewXMLTag1, dataVala, dataValb, moreData, ...>
> <dataNotNewXMLTag2, dataVala, dataValb, moreData, ...>
> <dataNotNewXMLTag3, dataVala, dataValb, moreData, ...>
> <dataNotNewXMLTag4, dataVala, dataValb, moreData, ...>
> <dataNotNewXMLTag5, dataVala, dataValb, moreData, ...>
> </node>

I'm assuming that your actual XML source document did not look like the
above; instead it has CDATA sections, as you were implying.
Otherwise, you would immediately get an error from the XSL processor
saying that the source document is not well-formed XML.

> I want to write a simple xsl script that would translate the
> above into
> something more manageable for XSLT processing:
>
> eg.
> <node>
> &lt;dataNotNewXMLTag1, dataVala, dataValb, moreData, ...&gt;
> &lt;dataNotNewXMLTag2, dataVala, dataValb, moreData, ...&gt;
> &lt;dataNotNewXMLTag3, dataVala, dataValb, moreData, ...&gt;
> &lt;dataNotNewXMLTag4, dataVala, dataValb, moreData, ...&gt;
> &lt;dataNotNewXMLTag5, dataVala, dataValb, moreData, ...&gt;
> </node>
>
> I had tried something like this:
> <x:template match="node">
>   <x:element name="node">
>      <x:variable
>          name="start"
>          select="translate(exslt:node-set(.),"<","&lt;")">
>      <x:variable
>          name="end"
>          select="translate(exslt:node-set($start),"<","&lt;")">
>      <x:copy-of select="exslt:node-set($end)"/>
>   </x:element>
> </x:template>
>
> But that really didn't work well, producing an error.

What was the error?

One thing that jumps out is that the quotes inside the select=""
string need to be apostrophes instead of double quotes.

I don't understand why you're using node-set inside of translate()
either; you just want the string-value of the current node (<node>),
i.e. the value of its text child.  Right?

As for whether it's necessary to do the translation at all --
I wouldn't think so.  If you use <xsl:output method="xml">,
XSL should escape anything that needs escaping in the output,
including <.  So an ordinary identity transformation
(see http://www.dpawson.co.uk/xsl/sect2/identity.html)
should do what you want, taking in CDATA sections and outputing
escaped data.

Somebody please correct if I'm mistaken...

Lars


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.