XSLT removes CDATA Tags


I have an output file of XML which looks like


Using the XSLT pasted at the bottom script it formats the file to look like
            <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>

What I need is for it to output like

            <CR_SRC><![CDATA[" "]]></CR_SRC>
            <CR_SRCLEN><![CDATA[" "]]></CR_SRCLEN>
            <CR_SRCPREFIX><![CDATA[" "]]></CR_SRCPREFIX>
            <CR_DESTLEN><![CDATA[" "]]></CR_DESTLEN>
            <CR_CPNAME><![CDATA[" "]]></CR_CPNAME>
            <CR_TRNAME><![CDATA[" "]]></CR_TRNAME>

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

<?xml version="1.0" encoding="UTF-8"?>
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>

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

<xsl:template match="@*">

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

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.

Creating CDATA sections with XSLT


See examples 5 and 6

Hope this helps


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

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],

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

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.