【发布时间】:2013-12-17 15:40:05
【问题描述】:
这是我的 xml:
<SECTION_CONTENT_LIST_ITEM>
<NTC_LIGHTLISTPRODUCT>
<IMMUTABLE_ID>9849</IMMUTABLE_ID>
<LIGHT_STRUCTURE>
<STRUCTURE_DESCRIPTION>Boa \A a fuso \B segnale \C speciale \D</STRUCTURE_DESCRIPTION>
</LIGHT_STRUCTURE>
</NTC_LIGHTLISTPRODUCT>
</SECTION_CONTENT_LIST_ITEM>
将注意力集中在“结构描述”字段上: 你可以看到:“Boa \A a fuso \B segnale \C speciale \D”
根据值 \A,\B,\C,\D,我的 xslt 代码打开一个 true type 字体文件,并将此 \a 或 \b 或 \c 或 \d 转换为特殊的不同字符。
我的 xslt 代码:
<xsl:template name="simboli">
<xsl:param name="testo"/>
<xsl:param name="separatore"/>
<xsl:choose>
<xsl:when test="contains($testo, $separatore)">
<xsl:value-of select="substring-before($testo, $separatore)"/>
<span style="font-family:lol;font-size:9pt;">
<xsl:value-of select= "substring(., string-length(substring-before($testo, $separatore)) +2, 1)"/>
</span>
<xsl:call-template name="simboli">
<xsl:with-param name="testo" select="substring(substring-after($testo, $separatore), 2, string-length(substring-after($testo, $separatore)))"/>
<xsl:with-param name="separatore" select="$separatore"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$testo"/>
</xsl:otherwise>
</xsl:choose>
你可以看到我使用 font-family=lol
<span style="font-family:lol;font-size:9pt;">
<xsl:value-of select= "substring(., string-length(substring-before($testo, $separatore)) +2, 1)"/>
</span>
我用 Microsoft Word 打开这个 XML 文件,我选择 Xslt 文件,然后在输出中得到:
Boa A a fuso f segnale u speciale s
字母 f ,u 和 s 应该是 LOL 的特殊字符。
我的问题是:为什么只转换第一个字符?
N.B:我控制 XSLT 并且运行正确,唯一的问题是只转换第一个 \A 并跳转 \B \C \D。
【问题讨论】: