Re: [xsl] Converting a string to a node set

Subject: Re: [xsl] Converting a string to a node set
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 23 Feb 2001 12:55:05 GMT

   I have a dataset containing CDATA blocks which actualy contains XML
   data.

grr. what's XML doing scrunched up in a CDATA block:-)
The "correct" solution is to fix the source not to quote the XML
(not always possible due to politics, I accept).

   I would like to be able to take the CDATA node and convert it to a node set
   within a XSL processor, is there anyway of doing this in the XSL standard?

Short answer, no.


Longer answer,

depends what you want to do, if you don't really need a node set but
just want to copy the markup to your result tree, then using
<xsl:vlaue-of disable-output-encoding="yes" select="whatever"/>
might work if your processor looks favourably on you and decides to
honour disable-output-encoding.

If you really want to get a node set then you'll have to parse the
string as XML. How to do this depends on what processor you are using
(you'll need an extension of some sort).

Most processors will let you write to an external file (xt:document
saxon:output xsl 1.1 xsl:document etc) in which case you can write
to an external file (as text) and read it back as XML using document()

Or you may be able to write an extension function that takes the string
as argument, parses it as XML and returns a node set (This should be
doable in MSXML3, for example)

David


_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp

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


Current Thread