Re: [xsl] xpath predicate help

Subject: Re: [xsl] xpath predicate help
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 17 Feb 2005 20:45:54 GMT
> This however does work.  If I hard-code the id in below it works, If I use a variable as in above it does not work. 
> Any help would be appreciated.

since teh code is the same  with teh exception that you'd replaced the
variable by '456' then I can only assume the variable doesn't have the
value think it should have (eg it has an extra space or two?)
try
<xsl:message>
  [[<xsl:value-of select="$link-target"/>]]
</xsl:message>
and see what comes out.

A few unrelated observations

		<xsl:variable name="link-target"
			<xsl:value-of select="substring-after(./@linkends,' ')"/>
		</xsl:variable>

don't do that here it's just ineffecient but as often comes up you can
get the wrong answer, a result tree fragment isn't needed here you can
just go

		<xsl:variable name="link-target"select="substring-after(./@linkends,' ')"/>

			<xsl:when
			test="name(//*[@id=$link-target])='grphprim'">
better to do //*[@id=$link-target]/self::grphrim
although // is very slow this is crying out to be done bia a key, see
other threads this week.

				<xsl:variable name="parent_graphic" select="//graphic[grphprim/@id=$link-target]"/>
				<xsl:value-of select="$parent_graphic/@id">

The variable isn't needed, you could just inline the expression (and
again using a key may make orders of magnitude speedup

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