I have an XML export from Access 2003, and I tried to insert a CDATA tag in a text field (latin ...) with XSLT, but I am very poorly versed in XSLT ...
Here is the XML source:
<?xml version="1.0" encoding="UTF-8"?> <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MESSAGES%20old.xsd" generated="2012-07-31T13:25:46"> <export_x005F_xml_message> <libelle>h euismod tincidu </libelle> <price>300</price> <libelle2>h euirci tation ullamc</libelle2> </export_x005F_xml_message> <export_x005F_xml_message> <libelle>h euismod tincidunt ut lao</libelle> <price>200</price> <libelle2>h euirci tation ullamcorper</libelle2> </export_x005F_xml_message> </dataroot>
Here is my start of XSLT ...:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match='*[name() = "MESSAGES"]'> <xsl:text disable-output-escaping="yes"> <![CDATA[ </xsl:text> <xsl:copy-of select="./node()"/> <xsl:text disable-output-escaping="yes"> ]]> </xsl:text> </xsl:template> </xsl:stylesheet>
I would like to get something like this:
<?xml version="1.0" encoding="UTF-8"?> <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MESSAGES%20old.xsd" generated="2012-07-31T13:25:46"> <export_x005F_xml_message> <libelle><![CDATA[h euismod tincidu ]]></libelle> <price>300</price> <libelle2><![CDATA[h euirci tation ullamc ]]></libelle> </export_x005F_xml_message> <export_x005F_xml_message> <libelle><![CDATA[h euismod tincidunt ut lao ]]></libelle2> <price>200</price> <libelle2><![CDATA[h euirci tation ullamcorper ]]></libelle2> </export_x005F_xml_message> </dataroot>
Can you help me create the right XSLT? This XML comes from Access 2003, which does not provide a CDATA option for the text field ... I am sure that a common model can help another developer like me :-)
source share