Re: [xsl] [SOLVED] RE: [xsl] grouping - XSLT 1.0

Subject: Re: [xsl] [SOLVED] RE: [xsl] grouping - XSLT 1.0
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 14 Apr 2005 09:59:56 +0100
<xsl:template match="Help"

so here your current node is Help

<xsl:for-each select="./Help[@Category

and here you are selecting all the Help children of the current node,
which is the empty set as your Help elements are emoty.

> This blows up.
"blows up" isn't a very helpful description, gies an error? does the
wrong thing? runs out of memory? I'd expect it to work but just produce
nothing from the for-each loop.



tried this but didn't yield the result I wanted

		<xsl:if test="./Help[@Category='Clerical:']">
			<xsl:call-template name="clerical"/>
		</xsl:if>
		<xsl:if test="./Help[@Category='Technical:']">
			<xsl:call-template name="technical"/>
		</xsl:if>
		<xsl:if test="./Help[@Category='Professional:']">
			<xsl:call-template name="professional"/>
		</xsl:if>
		<xsl:if test="./Help[@Category='Supervisor:']">
			<xsl:call-template name="supervisor"/>
		</xsl:if>
		<xsl:if test="./Help[@Category='Leader:']">
			<xsl:call-template name="leader"/>
		</xsl:if>



If you wanted a list of if's it would be better to use an xsl:choose
as then the testing can stop as soon as a match is found, but this block
of code just looks like it is implementing a slow version of
apply-templates.

Just replace it all by
<xsl:apply-templates select="@Category"/>

and replace

xsl:template name="supervisor"

by

xsl:template match="@Category[.='Supervisor:']"

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread