[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: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Thu, 3 Apr 2003 11:45:25 -0600
RE:  data vs. xml
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


Current Thread
  • data vs. xml
    • bix xslt - Thu, 3 Apr 2003 12:10:44 -0500 (EST)
      • Lars Huttar - Thu, 3 Apr 2003 12:41:58 -0500 (EST) <=
      • <Possible follow-ups>
      • Passin, Tom - Thu, 3 Apr 2003 12:28:56 -0500 (EST)
      • Avula, Raj - Thu, 3 Apr 2003 12:40:07 -0500 (EST)
      • bix xslt - Thu, 3 Apr 2003 12:50:30 -0500 (EST)

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-2011 All Rights Reserved.