Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question: apply-templates

 
lydia westland
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused with the following question
=================================================
What does "xsl:apply-templates" signify?
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match="SERIES">
<xsl:apply-templates select="Match"/>
</xsl:template>

<xsl:template match="Match">
<xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>
A. It applies the template to the matched node.
B. It applies the template to the child node.
C. It tells the formatting engine to process the children of the matched node.
D. None of the above.
=================================================
The answer given is C.
But I think the <xsl:apply-templates> tell the engine to apply certain rules to the matched nodeset, rather than the children of the nodeset. C is not very accurate. A is closer?
Thank you for your help
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lydia, where this question come from? The problem with it is that there are two <xsl:apply-templates> elements:
<xsl:apply-templates/>
and
<xsl:apply-templates select="Match"/>
the first one tells to process "the children of the matched node" as the answer C says, and the second tells to process nodes that match the expression in "select" attribute, as you said. So there is no single answer.
 
Danl Thompson
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And don't forget mode= too! Anyway, what M said is right. Remeber, you can also call-templates with arguments, but that's something else, although they are still templates.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic