The entity “nbsp” was referenced, but not declared

£可爱£侵袭症+ 提交于 2019-12-08 04:12:51

问题


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>


回答1:


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.




回答2:


You can escape the nbsp like this:

UPDATE try this:

<xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;

So you final code will look like:

<test>The Spanish word for "Spain" is "Espa<xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;a" Dagon his Name, Sea Monster</test>

If all else fails use this which is sure to work:

&#160;

Cheers



来源:https://stackoverflow.com/questions/44254653/the-entity-nbsp-was-referenced-but-not-declared

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!