XSLT Xpath wildcard

coolszf5

New Member
I've just started learning XML & XSLT and have a quick question regarding Xpath.Here's the XML code:\[code\]<root><shop> <person> <employee> <name> Alexis </name> <role> Manager </role> <task> Sales </task> </employee> </person></shop><person> <employee> <role> Supervisor </role> <name> Blake </name> <task> Control </task> </employee> </person></root>\[/code\]and here's the XSLT code:\[code\]<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="root"> <html><head></head> <body><xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="shop"> <xsl:apply-templates select="/root/*/*"/> </xsl:template> <xsl:template match="employee"> <u> <xsl:apply-templates select="name"/> </u> (Task: <xsl:apply-templates select="task"/>) <br></br> </xsl:template> <xsl:template match="person2"> <xsl:apply-templates /> </xsl:template> </xsl:stylesheet>\[/code\]The output is:\[code\]Alexis (Task: Sales )Blake (Task: Control )Blake (Task: Control ) \[/code\]What I don't understand is why the last part is duplicated? I know that it's due to this part of the XSLT code:\[code\]<xsl:apply-templates select="/root/*/*"/> \[/code\]but that's only because I was fiddling around with the code and displaying it in Firefox. I don't understand why though.From what I understand, it's selecting all the grandchildren elements of "root", like so:root/shop/personbut why isn't Alexis repeated as well? Only Blake is repeated...
 
Back
Top