Question : Transform xml address as CDATA

I am using xsl to transform an xml file.  It contains an address.  This address could contain unsuitable characters eg &.  I want to output the address within CDATA.
e.g <![CDATA[Smith & Co]]>
How can Ii code this in the xsl?  Obviously the coding below does not process anything within the CDATA.  
1:
2:
3:
4:
5:
<addr>
                <xsl:text><![CDATA[</xsl:text>
                <xsl:value-of select="AR/AR_Addr1"/>
                <xsl:text>]]></xsl:text>
              </addr>

Answer : Transform xml address as CDATA

> So that I should not have to use CDATA to output addres information, because it will automatically replace unusual characters wuth &lt etc.

Exactly. You can use CDATA - for example when you expect to do hand editing of the output documen - but you really don't have to.

> The alternative would be to set up matches for the adress line.  Since I have a few lines, would this mean individual matches?

Whenever you want to generate CDATA section in XSLT, you have to add desired element is cdata-section-elements. In your case it would be

cdata-section-elements="addr1 addr2 addr3"
(but not cdata-section-elements="addr1" "addr2" "addr3")

The rest is normal XSLT workflow, but the code you posted not correct.

I don't know what data you are transforming and what is the desired output. Probably you ment something like this (see below). However, that's no more matter of generating CDATA sections, so I'd suggest you to post new question if you have further issues regarding XSLT in general.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" cdata-section-elements="addr1 addr2 addr3"/>

<xsl:template match="/">
        <addr1>
                <xsl:value-of select="AR/AR_Addr1"/>
        </addr1>
        <addr2>
                <xsl:value-of select="AR/AR_Addr2"/>
        </addr2>
        <addr3>
                <xsl:value-of select="AR/AR_Addr3"/>
        </addr3>
</xsl:template>

</xsl:stylesheet>
Random Solutions  
 
programming4us programming4us