XSLT: Can't select attribute

skritos

New Member
I'm writing simple transformation using XSLT 1.0 and getting strange result.. Looks like I don't understand something, but I found I can't select attribute of a node for some reason. Here is my input XML:\[code\] <?xml version="1.0"?><weekreport> <employee name="Emp1"> <day date="25.06.2012"> <entry> <project>Proj1</project> <time>08:00</time> <description>Bla-bla-bla</description> </entry> </day> </employee> <employee name="Emp2"> <day date="25.06.2012"> <entry> <project>Proj2</project> <time>08:00</time> <description></description> </entry> </day> </employee></weekreport>\[/code\]and here is XSLT:\[code\]<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="entry" name="entry_t"> <xsl:param name="name"/> <xsl:param name="date"/> <Row> <Cell><xsl:value-of select="$date"/></Cell> <Cell><xsl:value-of select="$name"/></Cell> <Cell><xsl:value-of select="time"/></Cell> <Cell><xsl:value-of select="project"/></Cell> <Cell><xsl:value-of select="description"/></Cell> </Row> </xsl:template> <xsl:template match="day" name="day_t"> <xsl:param name="name"/> <xsl:for-each select="entry"> <xsl:call-template name="entry_t"> <xsl:with-param name="name"><xsl:value-of select="$name"/></xsl:with-param> <xsl:with-param name="date"><xsl:value-of select="@date"/></xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template match="employee" name="employee_t"> <xsl:for-each select="day"> <xsl:call-template name="day_t"> <xsl:with-param name="name"><xsl:value-of select="@name"/></xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template match="/weekreport"> <xsl:for-each select="employee"> <xsl:call-template name="employee_t"/> </xsl:for-each> </xsl:template></xsl:stylesheet>\[/code\]For some reason calling template day_t is done with parameter "name" set to empty value. Why?..
 
Back
Top