简体   繁体   English

在XSL中访问参数值

[英]Accessing value of param in xsl

I am trying to get the value of the parameter of template named as is Round from the following code but it returns me the blank, can anybody tell me that how to get value of parameter in template 我正在尝试从以下代码中获取名为Round的模板的参数值,但是它返回空白,有人可以告诉我如何在模板中获取参数的值

<xsl:apply-templates select="//solution">
            <xsl:with-param name="isRound">N</xsl:with-param>
</xsl:apply-templates>

  <xsl:template match="solution">
    <xsl:param name="isRound" />
    <test>
      <xsl:value-of select="$isRound"/>
    </test>
  </xsl:template>

The Output of this is: 输出为:

<test></test>

Actually this works. 实际上,这可行。 I try it as following. 我尝试如下。 Adding other necessary things such as stylesheet root element. 添加其他必要的内容,例如样式表根元素。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/root">
        <xsl:apply-templates select="//solution">
            <xsl:with-param name="isRound">N</xsl:with-param>
        </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="solution">
        <xsl:param name="isRound" />
            <test>
                <xsl:value-of select="$isRound"/>
            </test>
    </xsl:template>
</xsl:stylesheet>

Input for example. 例如输入。

<root>
    <solution/>
</root>

Result 结果

<?xml version="1.0"?>
<test>N</test>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM