2016-01-21 104 views
0

我想验证一个xsl值与另一个xsl值(使用Javascript存储在XML中的最小/最大值(它必须是JS),并且我不能使用尼斯和简单的HTML 5的验证方法,耶!我无法弄清楚如何做到这一点。Javascript来比较两个XSL值

的XSL如下(此正确拉我的价值)

<xsl:attribute name="test1"> 
     <xsl:value-of select="data/object/object/object/property/property/property/format/@answer"></xsl:value-of> 
    </xsl:attribute> 

这是XSL即拉入最小值,

<!-- Min Value--> 
<input type="hidden" name="minvalue"> 
<xsl:attribute name="value"> 
<xsl:value-of select="/options/@minimum"></xsl:value-of> 
</xsl:attribute> 
</input> 

我希望可以使用输入类型本身或名称值进行比较,但我可以找到的所有HTML 5验证,我需要它这个奇怪这>。 <

任何帮助或指向正确的方向将是真棒(PS首次任何代码的格式问题等很抱歉)

+0

你要在哪里验证?在样式表本身中,使用自定义JavaScript扩展函数?在浏览器中的HTML网页上? –

回答

0

如果你只是想这样做的XSLT,你可以尝试做像这样的东西......假设这些事情都落在同一个模板中。

<xsl:variable name="test1" select="number(data/object/object/object/property/property/property/format/@answer)" /> 

<xsl:variable name="minimum" select="number(/options/@minimum)" /> 

<xsl:choose> 
    <xsl:when test="$test1 > $minimum"> 
    <!-- output whatever you want here because the condition is satisifed --> 
    </xsl:when> 
    <xsl:otherwise> 
    <!-- output for when condition is not satisfied --> 
    </xsl:otherwise> 
</xsl:choose> 

如果您分享完整的XSLT,还有其他方法可以做到这一点 - 也许模板的结构只能匹配这些条件。在HTML页面中,也有使用JavaScript的方法,但我们需要查看最终输出,而不是您的XSLT。