当我申请到 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