Passing Node as an XSL Template Parameter

In an existing XSL stylesheet, I passed a string to a named template. Due to changing requirements, I now need to display four lines, the line that I showed, and her three siblings. Instead of passing four separate lines to a named template, I'm trying to pass their parent element (PETrailingFund in the code below),

 <xsl:call-template name="row">
  <xsl:with-param name="label">Price/Earnings Trailing</xsl:with-param>
  <xsl:with-param name="formatMarker">x</xsl:with-param>
  <xsl:with-param name="fund" select="PETrailingFund" />
  <xsl:with-param name="benchmark">
    <xsl:value-of select="benchmark/PETrailingBenchmark"/>
  </xsl:with-param>
  <xsl:with-param name="benchmark2">
    <xsl:value-of select="benchmark2/PETrailingBenchmark"/>
  </xsl:with-param>
</xsl:call-template>

but the transformation explodes when I try to work with the "fund" parameter in the named template:

<xsl:template name="row">
  <xsl:param name="label" />
  <xsl:param name="fund" />
  <xsl:param name="benchmark">NOT PROVIDED</xsl:param>
  <xsl:param name="benchmark2">NOT PROVIDED</xsl:param>
  <xsl:param name="formatMarker">&#160;</xsl:param>
  <xsl:param name="useDecimalFormatter">yes</xsl:param>
  <tr>
    <td class="first popup">
      <xsl:value-of select="$label" disable-output-escaping="yes"/>
    </td>
    <td>
      <xsl:if test="$benchmark = 'NOT PROVIDED'">
        <xsl:attribute name="class">last</xsl:attribute>
      </xsl:if>
      <xsl:value-of select="$fund/child::*" />
      <xsl:value-of select="$formatMarker"/>
    </td>
  </tr>
</xsl:template>

From what I read, I really do not pass node, but a fragment of the result tree, and I need to return it back to node (or node-set). Is this accurate or am I doing something else wrong? How would I convert it (I work in a rather stock environment of PHP5, which I cannot change).

N.B., .

+3
3

XSLT 1.0. 2.0 . 1.0 , blah: node -set. XSLT ( PHP). EXSLT, . : http://www.xml.com/pub/a/2003/07/16/nodeset.html

+2

<xsl:call-template..>

<xsl:apply-templates..> 

node node?

+1

= "x" , .

, , , , - , , .

+1

Source: https://habr.com/ru/post/1718906/


All Articles