Search code examples
xmlpdfxsltpdf-generationapache-fop

problem with xsl apply-templates


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

It prints "test" exactly the number of times the "car" node exists but "doStuff" doesn't seem to be accessed and "test2" is never outputted. 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()....

Solution

  • That's because you're trying to apply a nested car...

    The for-each already changes the context, so that you have to apply the template on the current node:

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