Friday, January 27, 2012

CDATA doesn't seem to be working

I have this bit of SQL
NULL as [license_Overflow!3!!cdata]
unioned to another query that populates it
cr.licenseOverflow
However my output doesn't include CDATA.
<resLicense>
<license_Overflow><P>I am in a P
tag</P></license_Overflow>
</resLicense>
Am I doing something wrong?john.wilker@.gmail.com wrote:
> I have this bit of SQL
> NULL as [license_Overflow!3!!cdata]
> unioned to another query that populates it
> cr.licenseOverflow
> However my output doesn't include CDATA.
> <resLicense>
> <license_Overflow><P>I am in a P
> tag</P></license_Overflow>
> </resLicense>
> Am I doing something wrong?
FAQ. See http://xml.silmaril.ie/authors/cdata/ and
the following question http://xml.silmaril.ie/authors/html/
///Peter|||Thanks Peter. I actually need cdata to handle markup from an older
system that allowed markup in fields.
Is there an option aside of making the XSL handle all the possible
markup tags we're likely to see. We have no control over what gets put
in, so it's be a royal pain to try to handle it all in XSL, no?
Shouldn't !!cdata do what I want? Or am I not understanding how it
works?|||FOR XML EXPLICIT is supposed to produce a CDATA section given a !cdata
directive.
However, if you use SQL Server 2005 and FOR XML produces XML type (has
"TYPE" directive) or assigned to XML-typed variable/parameter/column then it
is expected. XML data type does not preserve CDATA sections. If it's not
your case please post a repro.
Thanks,
Eugene
--
This posting is provided "AS IS" with no warranties, and confers no rights.
<john.wilker@.gmail.com> wrote in message
news:1144970072.177577.118700@.e56g2000cwe.googlegroups.com...
>I have this bit of SQL
> NULL as [license_Overflow!3!!cdata]
> unioned to another query that populates it
> cr.licenseOverflow
> However my output doesn't include CDATA.
> <resLicense>
> <license_Overflow><P>I am in a P
> tag</P></license_Overflow>
> </resLicense>
> Am I doing something wrong?
>|||John wrote:
> Thanks Peter. I actually need cdata to handle markup from an older
> system that allowed markup in fields.
That can be a pain all right.

> Is there an option aside of making the XSL handle all the possible
> markup tags we're likely to see. We have no control over what gets put
> in, so it's be a royal pain to try to handle it all in XSL, no?
Once you have template matching everything *else*, add
<xsl:template match="*">
<xsl:copy>
<xsl:for-each select="@.*">
<xsl:copy-of select="."/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
This will recursively copy everything otherwise unmatched,
preserving both the element and attribute markup.

> Shouldn't !!cdata do what I want? Or am I not understanding how it
> works?
CDATA sections should be avoided unless *absolutely* necessary.
///Peter

No comments:

Post a Comment