Subject: Re: [xsl] cdata-section-elements - not wrapping real xml in cdata markers From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 10 Nov 2003 16:43:01 -0500 |
I am trying to certain elements in my output xml wrapped in cdata markers, so I'm trying to use cdata-section-elements="myElement".
well it turns out that when the text in the element is not valid xml, it gets wrapped in the cdata markers just fine. but when the "text" in the element is valid xml, it does not get wrapped up. this is a problem for me, b/c then it means that when in the next stage my output xml is processed, doing an "xsl:value-of" on myElement will not yield the text that I want to be there.
I guess it's happening b/c I only told the processor that the text of myElement itself should be cdata, but once there's valid xml inside (ie. more elements), then it's a new element. (correct me if I'm wrong.)
so the question is, is there a way to wrap *everything* inside of an element in cdata markers, including child xml?
--warning --text()--"This is " --emph --text()--"my" --text()--" string: lay off!"
<xsl:template name="write-starttag"> <xsl:text><</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></</xsl:text> <xsl:value-of select="local-name()"/> <xsl:text></xsl:text> </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/> <xsl:call-template name="write-endtag"/> </xsl:template>
<xsl:template match="warning"> <xsl:apply-templates mode="escape-xml"/> </xsl:template>
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] cdata-section-elements - , Michael Kay | Thread | RE: [xsl] cdata-section-elements - , Lars Huttar |
RE: [xsl] cdata-section-elements - , Michael Kay | Date | RE: [xsl] generating xml from xml, David Carlisle |
Month |