user127377
user127377

Reputation: 151

Don't want to escape the characters while transforming XML

I am transforming one XML into another form of XML using XSL.

While transforming, the non-english characters are escaped. say 'Ã' is escaped as "Atilde;".

While parsing the transformed xml, I am seeing the following error :

org.xml.sax.SAXParseException: The entity "Atilde" was referenced, but not declared.

My requirement is, I don't want to allow the non-english characters to be escaped. I want to retain the characters as they are.

In the XSL that I am using to transform the XML, I have coded the below statement :

<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no"/>

should I change any of these attributes to achieve my requirement

Upvotes: 3

Views: 3961

Answers (2)

Anthony
Anthony

Reputation: 599

you need to provide a doctype

<xsl:output method="xml" indent="yes" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" omit-xml-declaration="no"/>

Upvotes: 4

rsp
rsp

Reputation: 23373

You cannot handle this in the <output> tag, but you can chose not to escape output when you generate text elements in the transform. To do this use:

<xsl:text disable-output-escaping="yes">

Upvotes: 4

Related Questions