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

RE: String to XML inside an XSLT

Subject: RE: String to XML inside an XSLT
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 1 May 2002 17:05:10 +0100
string to xml
Saxon 7.1 has a new extension function saxon:parse() which allows you to
turn this into a proper tree, if you know which text nodes need to be
parsed. (You can do it with d-o-e, but only by serializing the tree and then
re-parsing it.)

<xsl:variable name="proper-tree">
  <xsl:apply-templates mode="tidy-up"/>
</xsl:variable>

<xsl:template match="*" mode="tidy-up">
  (identity template)
</xsl:template>

<xsl:template match="node/text()" mode="tidy-up">
  <xsl:copy-of select="saxon:parse(normalize-space(.))"/>
</xsl:template>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Josh Twist
> Sent: 01 May 2002 16:34
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  String to XML inside an XSLT
>
>
> This is a bit of a funny one...
> I have, for example, the following XML (muchos simplified)
>
> <nodes>
> 	<node>
> 		&lt;childnode&gt;value&lt;/childnode&gt;
> 	</node>
> </nodes>
>
> This is a little unfortunate but unavoidable as the data is a
> string and the
> xml object builder can't tell the difference between a normal
> string and one
> that should be real XML. Only the XSLT knows this (long story).
>
> What I need to do is parse this in XSLT as normal and access
> the XML and
> it's values, children, attributes etc stored in the string.
> For example the
> Xpath might read "/nodes/node/childnode" I've tried putting
> it in variables
> with and without output-escaping disabled and so on without success:
>
> XSLT
>
> <xsl:variable name="myStringXML">
> 	<xsl:value-of select="/nodes/node"/>
> </xsl:variable>
>
> <xsl:for-each select="$myStringXML/childnode"> <!-- Errors here - says
> $myStringXML does not evaluate to a node set -->
> 	<xsl:value-of select="."/>
> </xsl:for-each>
>
> Anybody know of a way to do this? Even thought the <xsl:value-of
> select="/nodes/node"/> returns the value without the &lt;s
> etc it's still a
> string. What I need is somekind of xml() function that turns
> a string into a
> real nodeset.
>
> We're using MSXML3. Any help would be greatly appreciated.
>
> Josh
>
> The information in this e-mail and any attachment(s) is
> confidential and may be legally privileged. This e-mail is
> intended solely for the addressee. If you are not the
> addressee, dissemination, copying or other use of this e-mail
> or any of its content is strictly prohibited and may be
> unlawful. If you are not the intended recipient please inform
> the sender immediately and destroy the e-mail and any copies.
> E-mails and unencrypted attachments are scanned for all known
> viruses. Always scan e-mail attachments for viruses before
> opening them. All liability for viruses is excluded to the
> fullest extent permitted by law. Any views expressed in this
> message are those of the individual sender.
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 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.