XSLT removes CDATA Tags

Hi

I have an output file of XML which looks like

<CR><CR_NAME><![CDATA["INT-Afghanistan"]]></CR_NAME><CR_SRC><![CDATA[" 98289383"]]></CR_SRC><CR_SRCLEN><![CDATA[" "]]></CR_SRCLEN><CR_SRCPREFIX><![CDATA[" "]]></CR_SRCPREFIX><CR_DEST><![CDATA["93"]]></CR_DEST><CR_DESTLEN><![CDATA[" "]]></CR_DESTLEN><CR_PREFIX><![CDATA["93"]]></CR_PREFIX><CR_FLAGS><![CDATA["32"]]></CR_FLAGS><CR_CPNAME><![CDATA[" "]]></CR_CPNAME><CR_TRNAME><![CDATA[" "]]></CR_TRNAME><MTIME><![CDATA["2222222222"]]></MTIME></CR>

Using the XSLT pasted at the bottom script it formats the file to look like
      <CR>
            <CR_NAME> "INT-Afghanistan" </CR_NAME>
            <CR_SRC> "98289383" </CR_SRC>
            <CR_SRCLEN> "0" </CR_SRCLEN>
            <CR_SRCPREFIX> "98289383" </CR_SRCPREFIX>
            <CR_DEST> "" </CR_DEST>
            <CR_DESTLEN> "0" </CR_DESTLEN>
            <CR_PREFIX> "" </CR_PREFIX>
            <CR_FLAGS> "16" </CR_FLAGS>
            <CR_CPNAME> "" </CR_CPNAME>
            <CR_TRNAME> "" </CR_TRNAME>
      </CR>

What I need is for it to output like

<CR>
            <CR_NAME><![CDATA["INT-Afghanistan"]]></CR_NAME>
            <CR_SRC><![CDATA[" "]]></CR_SRC>
            <CR_SRCLEN><![CDATA[" "]]></CR_SRCLEN>
            <CR_SRCPREFIX><![CDATA[" "]]></CR_SRCPREFIX>
            <CR_DEST><![CDATA["93"]]></CR_DEST>
            <CR_DESTLEN><![CDATA[" "]]></CR_DESTLEN>
            <CR_PREFIX><![CDATA["93"]]></CR_PREFIX>
            <CR_FLAGS><![CDATA["32"]]></CR_FLAGS>
            <CR_CPNAME><![CDATA[" "]]></CR_CPNAME>
            <CR_TRNAME><![CDATA[" "]]></CR_TRNAME>
            <MTIME><![CDATA["2222222222"]]></MTIME>
      </CR>

What needs to change in the XSLT file to do this????
Cheers
Matt


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:sql="urn:schemas-microsoft-com:xml-sql"
     exclude-result-prefixes="sql"
     >
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>

<xsl:template match="/ | node()">
     <xsl:copy>
          <xsl:apply-templates select="@*"/>
          <xsl:apply-templates select="node()"/>
     </xsl:copy>
</xsl:template>

<xsl:template match="@*">
     <xsl:copy>
     </xsl:copy>
</xsl:template>

<xsl:template match="*">
     <xsl:element name="{local-name()}">
          <xsl:apply-templates select="@*"/>
          <xsl:apply-templates select="node()"/>
     </xsl:element>
</xsl:template>

</xsl:stylesheet>
pclarkinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

metalmickeyCommented:
Creating CDATA sections with XSLT

http://www.azureus.com/xml/art_creating_cdata_sections_in_xslt.htm


See examples 5 and 6


Hope this helps

MM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pclarkinAuthor Commented:
OK that makes sense. Now I need to work out how to get the <cdata> tags into my <cr>
so it needs to look like
<CR>
          <CR_NAME>
                            <cdata>
                                        <![CDATA["INT-Afghanistan"]]>
                             </cdata>
          </CR_NAME>
etc.

At the moment it's generated from SQL Server using the for xml explicit command like

SELECT 1                  as Tag,
       NULL                 as Parent,
      '<![CDATA[' + CR_NAME + ']]>' as [CR!1!CR_NAME!XML],
etc
FROM CR
FOR XML EXPLICIT

How do I nest this cdata tag in?
0
pclarkinAuthor Commented:
Don't worry - I see you can put multiple entrys in the cdata-section-elements declaration.

Cheers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.