Re: Apply-templates - how to omit top level element ta
At 06:06 PM 9/8/2005, David wrote:
<h1> <!-- THIS IS WHAT I NEEDED --> <xsl:apply-templates select="Name/node()"/> </h1>
... and it would implicitly override your identity template (the one matching "@*|node()", which would get rid of that problem -- so your stylesheet would "just work" had you had this template.
OTOH, you couldn't have known this. Another vital detail in the XSLT processing model: how the processor decides among templates when more than one template (oops: "template rule"; see below) matches a given node. In this case, a template that matches "node()" (any node) and one that matches "Guide/Name" (a name element child of a Guide element) both would match your Name. The processor sees this and chooses the latter as a "better match". (The reason: the rules for template matching assign it a priority of 1, while the template matching "node()" has a priority of -0.5....)
BTW, a "template rule" is that construct we generally call a "template". No one knows this or bothers to observe it, but "templates" are the *content* of template rules ... templates also appear inside xsl:for-each instructions.
I'm a secularist too, but I'm willing to be just as persnickety as any religionist if it helps get the job done. Not persnickety for its own sake, mind you. :-)
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format