【问题标题】:How to use control characters in XSL如何在 XSL 中使用控制字符
【发布时间】:2013-03-03 20:23:15
【问题描述】:

我正在尝试使用 xsl 来获取以下 html

<input type="button" value="line1&#10;line2">

我尝试了以下

<input type="button">
    <xsl:attribute name="value">
        <xsl:value-of select="'line1&#10;line2'" />
    </xsl:attribute>
</input>

但它不起作用。

编辑:由于我的 IDE (LANSA) xsl 编辑器,它可能无法正常工作。我最终使用了以下 xsl

<input type="button">
<xsl:attribute name="value">  line1
line2</xsl:attribute>
</input>

生成以下html

<input type="button" value="line1
line2"> 

【问题讨论】:

    标签: html xslt button escaping ascii


    【解决方案1】:

    我没有发现任何问题——以下两种转换:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/">
      <input type="button" value="line1&#10;line2"/>
     </xsl:template>
    </xsl:stylesheet>
    

    和

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="/">
      <input type="button">
       <xsl:attribute name="value">line1&#10;line2</xsl:attribute>
      </input>
     </xsl:template>
    </xsl:stylesheet>
    

    使用我正在使用的 11 种不同 XSLT 处理器中的任何一种应用于以下 XML 文档时:

    <t/>
    

    生产:

    <input type="button" value="line1&#xA;line2"/>
    

    【讨论】:

    • 谢谢,我猜是 IDE (LANSA) 不允许我使用控制字符。
    猜你喜欢
    • 1970-01-01
    • 2019-07-25
    • 1970-01-01
    • 2012-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-17
    • 1970-01-01
    相关资源
    最近更新 更多