How to insert   in XSLT

后端 未结 12 805
后悔当初
后悔当初 2020-12-22 16:48

How can I insert

 

Into an XSLT stylesheet, I keep getting this error:

XML Parsing

相关标签:
12条回答
  • 2020-12-22 17:24

    Use the entity code   instead.

      is a HTML "character entity reference". There is no named entity for non-breaking space in XML, so you use the code  .

    Wikipedia includes a list of XML and HTML entities, and you can see that there are only 5 "predefined entities" in XML, but HTML has over 200. I'll also point over to Creating a space ( ) in XSL which has excellent answers.

    0 讨论(0)
  • 2020-12-22 17:25

    One can also do this :

    <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
    
    0 讨论(0)
  • 2020-12-22 17:26

    I was trying to display borders on an empty cell in an HTML table. My old trick of using non-breaking space in empty cells was not working from xslt. I used line break with the same effect. I mention this just in case the reason you were trying to use the non-breaking space was to give some content to an 'empty' table cell in order to turn on the cell borders.

    <br/>
    
    0 讨论(0)
  • 2020-12-22 17:29

    XSLT stylesheets must be well-formed XML. Since "&nbsp;" is not one of the five predefined XML entities, it cannot be directly included in the stylesheet. So coming back to your solution "&#160;" is a perfect replacement of "&nbsp;" you should use.

    Example:

    <xsl:value-of select="$txtFName"/>&#160;<xsl:value-of select="$txtLName"/>
    
    0 讨论(0)
  • 2020-12-22 17:34

    you can also use:

    <xsl:value-of select="'&amp;nbsp'"/>
    

    remember the amp after the & or you will get an error message

    0 讨论(0)
  • 2020-12-22 17:37

    &#160; works really well. However, it will display one of those strange characters in ANSI encoding. <xsl:text> worked best for me.

    <xsl:text> </xsl:text>
    
    0 讨论(0)
提交回复
热议问题