Problem with xsl apply-templates

It seems like my template is never called, but the for loop works correctly.

It prints a “test” exactly as many times as a “car” node exists, but “doStuff” does not seem to be available, and “test2” is never output. Any ideas?

<fo:table-body>
      <xsl:for-each select="car">
      test
  <xsl:apply-templates select="car" />
  </xsl:for-each>
</fo:table-body>

....

<xsl:template match="car">
<fo:table-row height="0.40cm">
test2
dostuff()....
+3
source share
2 answers

This is because you are trying to apply a nested car ...

for-each already changing the context, so you should apply the template to the current node:

<xsl:apply-templates select="."/>
+7
source

"" node, select apply-templates , "", .

<xsl:apply-templates select="."/>

.

+4

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


All Articles