i m having a variable declaration in XSL file as
我在XSL文件中有一个变量声明
<xsl:variable name="check" >
<xsl:value-of select="normalize-space(substring-before(substring-after(@style,'FONT-SIZE:'),'pt'))"/>
</xsl:variable>
which give me font size as in my XML whatever it is 12,14,16
它给我字体大小,如我的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>
i make a template to select the size which i need from the choose query
我做一个模板,从选择查询中选择我需要的大小
and i want to get the selected size to set in the size attribute
我想获得在size属性中设置的选定大小
<font size="$check"
face="{normalize-space(substring-before(substring-after(@style,'FONT-FAMILY:'),';'))}">
is m going correct or is there any other way to do this.
是正确的还是有其他方法可以做到这一点。
1 个解决方案
#1
1
First, replace this:
首先,替换这个:
<xsl:variable name="check" >
<xsl:value-of select="xxxxx"/>
</xsl:variable>
by this:
这样:
<xsl:variable name="check" select="xxxxx"/>
which is not only much more concise, it is also likely to be much more efficient. (This mistake seems to be very widespread.)
这不仅更简洁,而且可能更有效率。 (这个错误似乎非常普遍。)
Second, I don't know whether this makes sense in the context of your overall project, but rather than generating font elements, the modern way is to use CSS. Output
其次,我不知道这在整个项目的上下文中是否有意义,而不是生成字体元素,现代的方法是使用CSS。产量
<span class="c{$check}"><xsl:value-of select="."/></span>
and then define CSS classes to control the detailed rendition.
然后定义CSS类来控制详细的再现。
#1
1
First, replace this:
首先,替换这个:
<xsl:variable name="check" >
<xsl:value-of select="xxxxx"/>
</xsl:variable>
by this:
这样:
<xsl:variable name="check" select="xxxxx"/>
which is not only much more concise, it is also likely to be much more efficient. (This mistake seems to be very widespread.)
这不仅更简洁,而且可能更有效率。 (这个错误似乎非常普遍。)
Second, I don't know whether this makes sense in the context of your overall project, but rather than generating font elements, the modern way is to use CSS. Output
其次,我不知道这在整个项目的上下文中是否有意义,而不是生成字体元素,现代的方法是使用CSS。产量
<span class="c{$check}"><xsl:value-of select="."/></span>
and then define CSS classes to control the detailed rendition.
然后定义CSS类来控制详细的再现。