Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在XSLT模板参数中选择元素?_Xslt - Fatal编程技术网

如何在XSLT模板参数中选择元素?

如何在XSLT模板参数中选择元素?,xslt,Xslt,我有以下XSLT模板: <xsl:template name="foo"> <xsl:param name="arg1">0</xsl:param> <xsl:param name="arg2" /> <xsl:param name="arg3" /> <xsl:call-template name="bar"> <xsl:with-param name="arg

我有以下XSLT模板:

    <xsl:template name="foo">
    <xsl:param name="arg1">0</xsl:param>
    <xsl:param name="arg2" />
    <xsl:param name="arg3" />
    <xsl:call-template name="bar">
        <xsl:with-param name="arg1"><xsl:value-of select="$arg1" /></xsl:with-param>
        <xsl:with-param name="arg2"><xsl:copy-of select="$arg2" /></xsl:with-param>
        <xsl:with-param name="arg3"><!-- what do I put here? --></xsl:with-param>
    </xsl:call-template>
</xsl:template>

0
现在arg3是一个xml snippit。我只想在arg3中选择一个元素作为arg3传递给bar。如何从参数中选择单个节点?我试过了,但没有成功


请不要建议发送arg3/qux的值而不是arg3。这有一个很好的理由,但这超出了这个问题的重点。

这取决于XML片段的外观,但您可以这样做:

<xsl:value-of select="$arg3/first_name" />

编辑

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
    xmlns:ext="http://exslt.org/common" exclude-result-prefixes="ext msxsl">

    <xsl:template match="/">               
        <xsl:value-of select="ext:node-set($arg3)/first_name" />
    </xsl:template>

</xsl:stylesheet>

只要把$arg3当作一个节点,对我来说就行了

<xsl:call-template name="bar">
    <xsl:with-param name="arg1"><xsl:value-of select="$arg1" /></xsl:with-param>
    <xsl:with-param name="arg2"><xsl:copy-of select="$arg2" /></xsl:with-param>
    <xsl:with-param name="arg3" select="$arg3/sub-node"/>
</xsl:call-template>


您使用什么来处理XSLT?Java似乎不喜欢这样(
这里有点超出我的深度,但是试着使用一个节点集。我现在要玩彩票;)你能详细说明一下吗,但它不起作用?是否给出了任何错误消息@James Johnson经过编辑的解决方案可能是您想要的,但如果没有任何错误消息,则很难提供帮助。