Xml 获取XSLT变量的选定值并在字体中设置
我在XSL文件中有一个变量声明Xml 获取XSLT变量的选定值并在字体中设置,xml,xslt,Xml,Xslt,我在XSL文件中有一个变量声明 <xsl:variable name="check" > <xsl:value-of select="normalize-space(substring-before(substring-after(@style,'FONT-SIZE:'),'pt'))"/> </xsl:variable> 这让我的字体大小和XML中的一样,不管是12,14,16 <xsl:template name
<xsl:variable name="check" >
<xsl:value-of select="normalize-space(substring-before(substring-after(@style,'FONT-SIZE:'),'pt'))"/>
</xsl:variable>
这让我的字体大小和XML中的一样,不管是12,14,16
<xsl:template name="fontSize">
<xsl:choose>
<xsl:when test="round($check=8) or round($check=7) or round($check=6)">
<font size="1" face="$Fface">
<xsl:value-of select="."/>
</font>
</xsl:when>
<xsl:when test="round($check=10) or round($check=9)">
<font size="2" face="$Fface">
<xsl:value-of select="."/>
</font>
</xsl:when>
<xsl:otherwise>
<font size="3" face="$Fface">
<xsl:value-of select="."/>
</font>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
我制作了一个模板,从choose查询中选择所需的大小
我想获得要在“大小”属性中设置的选定大小
<font size="$check"
face="{normalize-space(substring-before(substring-after(@style,'FONT-FAMILY:'),';'))}">
是否正确,或者是否有其他方法来执行此操作。首先,替换此:
<xsl:variable name="check" >
<xsl:value-of select="xxxxx"/>
</xsl:variable>
据此:
<xsl:variable name="check" select="xxxxx"/>
这不仅更加简洁,而且可能更加高效。(这个错误似乎非常普遍。)
其次,我不知道这在整个项目的上下文中是否有意义,但现代的方法是使用CSS,而不是生成字体元素。输出
<span class="c{$check}"><xsl:value-of select="."/></span>
然后定义CSS类来控制详细的格式副本。能否显示当前的输入XML和预期的输出,因为这样可以更容易地帮助您?谢谢