5

I have written one XSLT to transform xml to xml.

Input XML:

<test>The Spanish word for "Spain" is "Espa&nbsp;a" Dagon his Name, Sea Monster</test>

OutputXML:

<test>The Spanish word for "Spain" is "Espa a" Dagon his Name, Sea Monster</test>

XSL FILE: i have added the code for entity nbsp declaration under doctype at and replace with   entity but still are same error The entity "nbsp" was referenced, but not declared.

<xsl:template match="test">
<test>
  <xsl:apply-templates/>
</test>

Umaima
  • 137
  • 1
  • 1
  • 9
  • If you want to parse the input with an XML parser (and any XSLT processor normally uses an XML parser to parse the input document(s)) then the input itself needs to declare that entity in a DTD. – Martin Honnen May 30 '17 at 10:06

3 Answers3

4

You need to have the input declare the entities it uses, as done in http://xsltransform.net/gVhD8QR with e.g.

<!DOCTYPE test [
  <!ENTITY nbsp "&#160;">
]>
<test>The Spanish word for "Spain" is "Espa&nbsp;a" Dagon his Name, Sea Monster</test>

Note that the Spanish word for "Spain" is "España" however, so the example entity used there does not make sense there anyway.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • Please share your email id because i'm stuck one problem and can't explain on 'stackoverflow' code is lenthy, please help me – Umaima Feb 17 '21 at 13:27
  • @Umaima, no, sorry, if StackOverflow doesn't work for you I can't help. There are certainly people doing freelance or contract work in the area of XSLT, if that is an option look for sides where you can post a work description and find people able and willing to do the work. – Martin Honnen Feb 17 '21 at 14:25
-1

A SOLUTION ... use CDATA as following:

<test><![CDATA[ your text with &acute; &ecute; &icute; &Acute; &ntilde; ]]></test>

<test><![CDATA[The Spanish word for "Spain" is "Espa&ntilde;a" Dagon his Name, Sea Monster]]></test>

I know is late to answer this, but also I know it could help someone else !

Reference to acutes & tildes: https://uniwebsidad.com/libros/xhtml/capitulo-3/codificacion-de-caracteres

-2

A SOLUTION ... use CDATA as following:

<test><![CDATA[ your text with &acute; &ecute; &icute; &Acute; &ntilde; ]]></test>

<test><![CDATA[The Spanish word for "Spain" is "Espa&ntilde;a" Dagon his Name, Sea Monster]]></test>

I know is late to answer this, but also I know it could help someone else !

Reference to acutes & tildes: https://uniwebsidad.com/libros/xhtml/capitulo-3/codificacion-de-caracteres