2

我已经在 XML 上创建了 XSLT,它在文本编辑器或浏览器中看起来很漂亮,但是当我将它发送到公司的恐龙点阵打印机时,它会打印成带有重音 a 的大 T,所以像“Ta ”。

我可以简单地在静态部分替换它,但我有几个模板:

<xsl:template name="lpad"><!-- recursive template to right justify and prepend-->
<!-- the value with whatever padChar is passed in   -->
<xsl:param name="padChar"> </xsl:param>
<xsl:param name="padVar"/>
<xsl:param name="length"/>
<xsl:choose>
  <xsl:when test="string-length($padVar) &lt; $length">
    <xsl:call-template name="lpad">
      <xsl:with-param name="padChar" select="$padChar"/>
      <xsl:with-param name="padVar" select="concat($padChar,$padVar)"/>
      <xsl:with-param name="length" select="$length"/>
    </xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="substring($padVar,string-length($padVar) - $length + 1)"/>
  </xsl:otherwise>
</xsl:choose>

因此,当我尝试这样称呼他们时,我遇到了麻烦:

<xsl:call-template name="rpad">
<xsl:with-param name="padChar"> </xsl:with-param>
<xsl:with-param name="padVar" select="SequenceValue"/><!--  <xsl:with-param name="length" select="9"/>

以前 padChar 参数是

&#160;

并且引擎能够处理模板。

任何想法都非常感谢!

干杯!

4

2 回答 2

0

我花了将近一整天的时间试图破解它,但解决方案太简单了。最终起作用的是以稍微不同的方式调用模板:

<xsl:call-template name="rpad">
<xsl:with-param name="padChar" select="' '" />
<xsl:with-param name="padVar" select="SequenceValue"/>

我希望这可以帮助别人。

干杯!

于 2015-09-19T20:21:29.137 回答
0

&#160;现在是一个不间断的空间并且非常标准,但是点阵打印机是旧技术,可能不支持现代字符集。如果您可以识别出您的打印机无法处理的字符,那么您可以尝试使用 XSLT 2.0 的xsl:character-map声明将它们替换为其他内容;或者,您可以使用某种后处理(例如在 sed 或 awk 中)重新映射字符。

于 2015-09-09T20:05:04.110 回答