...">

How to convert to XSLT

I have the following xslt:

<span><xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;Some text]]></xsl:text></span>

After the conversion, I get:

<span>&amp;nbsp;Some text</span>

which displays as: and nbsp; Some text

I want to do and nbsp; like a cosmic character. I also tried changing disable-output-escaping to no, but that didn't help.

thanks for the help.

+5
source share
3 answers

I think you should use &#xa0;it because the object &nbsp;will most likely not be defined. And no CDATA.

Another possibility is to define an object nbspfor your xsl file:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
 <!ENTITY nbsp "&#xa0;">
]>
<xsl:stylesheet version="1.0"
+4
source

The other two answers are correct, but I decided to take a little look at this topic.

What Everyone Should Know About CDATA Partitions

CDATA - XML. , <span><![CDATA[ a & b < 2 ]]></span> <span> a &amp; b &lt; 2 </span>. XML- , XML- .

: CDATA .

<span><xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;Some text]]></xsl:text></span>

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

, & &amp; .

, disable-output-escaping

disable-output-escaping - , .. XML, XSLT- & < (, , ), . &amp; &lt;. , XML . XSLT <xsl:value-of> <xsl:text> disable-output-escaping, . :

  • XSLT- , . escaping , XSLT- .
  • disable-output-escaping XSLT-. ( ), .
  • XSLT , , . disable-output-escaping , .
  • XML, , XML.
  • disable-output-escaping , , . <xsl:element>.

<span><xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;Some text]]></xsl:text></span>

<span>&nbsp;Some text</span>

& , , , .

XML- , , , . XML 5 . :

  • &amp; &
  • &lt; <
  • &gt; >
  • &quot; "
  • &apos; '

DTD , DTD, ( ). XML . (X) HTML DOCTYPE (, &nbsp;), DTD XHTML DTD, . DTD: http://www.w3.org/TR/html4/HTMLlat1.ent, http://www.w3.org/TR/html4/HTMLsymbol.ent http://www.w3.org/TR/html4/HTMLspecial.ent.

. , , DTD. , . , , "". , , XML - . , . : - .

&nbsp; &#160; ( , &#xA0; ). , &nbsp;, , @phihag. &nbsp;, , @Michael Krelin, DTD. XSLT-.

, XSLT- , &nbsp; &#160;. XSLT 1.0 disable-output-escaping, , .

+6

CDATA . :

<span><xsl:text>&#160;Some text</xsl:text></span>
+1

All Articles