KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I thought I saw a mistake in an answer to this question , and pointed it out. I was told I was incorrect, and my answer was later deleted. I still don't see how I was wrong. Therefore, I am posting here and hoping someone can explain my misunderstanding to me. The answer I responded to explained the use of apply-templates. It contained the following XML and XSL, describing how the templates would be matched: <!-- sample XML snippet --> <xml> <foo /><bar /><baz /> </xml> <!-- sample XSLT snippet --> <xsl:template match="xml"> <xsl:apply-templates select="*" /> <!-- three nodes selected here --> </xsl:template> <xsl:template match="foo"> <!-- will be called once --> <xsl:text>foo element encountered</xsl:text> </xsl:template> <xsl:template match="xml/*"> <!-- will be called twice --> <xsl:text>other element countered</xsl:text> </xsl:template> My comment was that the last template in should be: <xsl:template match="*"> <!-- will be called twice --> <xsl:text>other element countered</xsl:text> </xsl:template> because the current node is already <xml> I was told: No, xml/* is a pattern that matches child elements of an element with the name xml. Testing the original answer However, with this XML: <xml> <foo /><bar /><baz /> </xml> And this XSL stylesheet (filling out the snippet above): <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method
Tags (comma-separated)
Save Edits
Cancel