i need to insert values of several elements into one cdata... here is my code:
first, i made output:
<xsl:output method="xml" encoding="UTF-8" intend="yes" cdata-section-elements="embassy" />
and here is element definition:
<xsl:element name="embassy">
<xsl:value-of select="Visa/visa_velv/visa_velv_name" />
<xsl:element name="br" />
<xsl:value-of select="Visa/visa_velv/visa_velv_address" />
<xsl:element name="br" />
<xsl:value-of select="Visa/visa_velv/visa_velv_city" />
</xsl:element>
and here is bad output for my need:
<embassy><![CDATA[Ambasada e Republikes se Cekise]]>
<br/><![CDATA[Rruga Skënderbej 10]]>
<br/><![CDATA[Tirana]]>
</embassy>
i need this output:
<embassy>
<![CDATA[Ambasada e Republikes se Cekise<br/>Rruga Skënderbej 10<br/>Tirana]]>
</embassy>
i was reading documentation but i can't find solution. thanks for helping :)
This complete and simple transformation:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" cdata-section-elements="Embassy"/>
<xsl:strip-space elements="*"/>
<xsl:template match="visa_velv">
<Embassy>
<xsl:value-of select=
"concat(visa_velv_name,'<br/>',visa_velv_address,'<br/>',visa_velv_city)"/>
</Embassy>
</xsl:template>
</xsl:stylesheet>
when applied on the folowing XML document:
<Visa>
<visa_velv>
<visa_velv_name>Ambasada e Republikes se Cekise</visa_velv_name>
<visa_velv_address>Rruga Skënderbej 10</visa_velv_address>
<visa_velv_city>Tirana</visa_velv_city>
</visa_velv>
</Visa>
produces the wanted result:
<Embassy><![CDATA[Ambasada e Republikes se Cekise<br/>Rruga Skënderbej 10<br/>Tirana]]></Embassy>