当我在internet explore中打开xslt 2.0 in xml文件时,我遇到了一个错误



当我应用到xml文件时,我有xsl文件。当我在Internet explorer中查看它时。我得到一个错误为.

Expected token ']' found 'NAME'. threshold[substring-before(normalize-space(), ' ')-->castable <--as xs:integer]

这是我的xsl文件。

<xsl:template match="threshold[substring-before(normalize-space(), ' ')castable as xs:integer]">
<xsl:variable name="vNorm" select = "translate(normalize-space(), '%', '')"/>
<xsl:variable name="vAtUnit" select = "substring-after($vNorm, ' ')"/>
<xsl:variable name="vUnit" select ="replace($vAtUnit, '([^0123456789]+)(d*)', '$1')"/>
<xsl:variable name="vLastPart" as="xs:string" select ="substring-after($vAtUnit, $vUnit)"/>
<xsl:variable name="vNum" select="concat($vLastPart, '100'[not($vLastPart)])"/>
    <threshold>
        <t-r-value><xsl:value-of select="substring-before(., ' ')"/></t-r-value>
        <unit><xsl:value-of select="normalize-space($vUnit)"/></unit>
        <samplepct><xsl:value-of select="$vNum"/></samplepct>
    </threshold>
    <xsl:call-template name="tested"></xsl:call-template>
</xsl:template>
<xsl:template name="tested">
<xsl:for-each select="../following-sibling::interval-repeats[1]/ repeat[ count(current()/preceding-sibling::threshold) + 1]" >
<xsl:variable name="vNormrep" select = "translate(normalize-space(), '%', '')"/>
<xsl:variable name="vAtUnitrep" select = "substring-after($vNormrep, ' ')"/>
<xsl:variable name="vUnitrep" select ="replace($vAtUnitrep, '([^0123456789]+)(d*)', '$1')"/>
<xsl:variable name="vLastPart" as="xs:string" select ="substring-after($vAtUnitrep, $vUnitrep)"/>
<xsl:variable name="vNumrep" select="concat($vLastPart, '100'[not($vLastPart)])"/>
    <repeat>
        <t-r-value><xsl:value-of select="substring-before(., ' ')"/></t-r-value>
        <unit><xsl:value-of select="normalize-space($vUnitrep)"/></unit>
        <samplepct><xsl:value-of select="$vNumrep"/></samplepct>
    </repeat>
</xsl:for-each>

有人能在这里帮我吗。

提前感谢Karthic

浏览器只支持XSLT1.0和一些EXSLT扩展,如果要使用XSLT2.0,则需要使用XSLT2.0处理器,如Saxon 9、AltovaXML或XmlPrime。如果要使用XSLT2.0客户端,可以检查Saxon CEhttp://www.saxonica.com/ce/download.xml是一个选项。

[编辑]至于尝试在XSLT1.0中实现整数检查,您可以尝试

<xsl:template match="threshold[not(translate(substring-before(normalize-space(), ' '), '0123456789', ''))]">

该检查删除任何数字,然后检查结果是否为空字符串,该字符串可能足以检查整数

验证字符串是否可转换为整数的一个短XPath表达式是:

$x = floor($x)

正如在另一个答案中已经指出的,五大浏览器中没有一个支持XSLT2.0。目前在浏览器中使用XSLT2.0的方法是由Saxon CE提供的。

最新更新