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

RE: cdata-section-elements - not wrapping real xml in

Subject: RE: cdata-section-elements - not wrapping real xml in cdata markers
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Wed, 12 Nov 2003 16:36:22 -0600
xsl cdata section elements
Wendell Piez wrote:
> Sent: Monday, November 10, 2003 3:43 PM

> I think what you need is to write out the "elements" inside 
> the string you 
> want to preserve in escaped form. You can do this with 
> templates easily 
> enough. This means they won't look like elements in your 
> stylesheet -- 
> because you don't want elements in your output. For example 
> (here are a 
> couple of templates I have lying around that will do this):

Thank you for these. They were just what I needed for something
I'm doing.

(Caveat to anyone who might use this: a greater-than sign
is missing in the "write-endtag" template as it appeared
in the email.)

> <xsl:template name="write-starttag">
>    <xsl:text>&lt;</xsl:text>
>    <xsl:value-of select="local-name()"/>
>    <xsl:for-each select="@*">
>      <xsl:call-template name="write-attribute"/>
>    </xsl:for-each>
>    <xsl:text>></xsl:text>
> </xsl:template>
> 
> <xsl:template name="write-endtag">
>    <xsl:text>&lt;/</xsl:text>
>    <xsl:value-of select="local-name()"/>
>    <xsl:text></xsl:text>

A greater-than sign is missing here (lost in the mail?)

> </xsl:template>
> 
> <xsl:template name="write-attribute">
>    <xsl:text> </xsl:text>
>    <xsl:value-of select="local-name()"/>
>    <xsl:text>="</xsl:text>
>    <xsl:value-of select="."/>
>    <xsl:text>"</xsl:text>
> </xsl:template>
> 
> <xsl:template match="*" mode="escape-xml">
>    <xsl:call-template name="write-starttag"/>
>    <xsl:apply-templates/>

Btw some will want to add mode="escape-xml" to the above
line for recursive escaping.

>    <xsl:call-template name="write-endtag"/>
> </xsl:template>
> 
> <xsl:template match="warning">
>    <xsl:apply-templates mode="escape-xml"/>
> </xsl:template>

Lars


 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.