简体   繁体   中英

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

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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