XSLT:使用提供参数的模板中的参数调用模板
我想从 template1 内部调用 template2,并为其提供 template1 中的参数。
现在,我有这样的事情:
<xsl:template name="template1" match="home/sentences/sentence">
<xsl:if test="something...">
<new_sentence>
<!-- ...other unrelated stuff... -->
<xsl:apply-templates select="key('get_sentence_attribute', tokenRef/@tokID)"/>
<!--Here I point to the template I made for tokens.
But I also wish to provide it with the value returned by get_sentence_attribute -->
<xsl:apply-templates select="../../tokens"/>
</new_sentence>
</xsl:if>
</xsl:template>
<xsl:template name="template2" match="home/tokens">
<!-- ... -->
</xsl:template>
基本上我需要确保我的标记模板选择的值与我在句子模板中获得的句子属性相匹配。我用谷歌搜索并找到了
元素;但这让我很困惑,我什至不确定这是否是我所需要的。
感谢您的帮助!
I would like to call template2 from inside template1, and provide it with a parameter from template1.
Right now, I have something like this:
<xsl:template name="template1" match="home/sentences/sentence">
<xsl:if test="something...">
<new_sentence>
<!-- ...other unrelated stuff... -->
<xsl:apply-templates select="key('get_sentence_attribute', tokenRef/@tokID)"/>
<!--Here I point to the template I made for tokens.
But I also wish to provide it with the value returned by get_sentence_attribute -->
<xsl:apply-templates select="../../tokens"/>
</new_sentence>
</xsl:if>
</xsl:template>
<xsl:template name="template2" match="home/tokens">
<!-- ... -->
</xsl:template>
Basically I need to make sure that the values selected by my tokens template, match the sentence_attribute I get in my sentence template. I've googled around and found the <xsl:with-param>
element; but it's pretty confusing to me and I'm not even sure if it's what I need.
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)