Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using functions and element attributes inside an if statement

Status
Not open for further replies.

abienz

Programmer
Aug 13, 2001
53
0
0
GB
Hi there,

I've a problem with some XSL I'm writing, I'm wondering if there's an escape character in XSL or something that can solve this problem, here's what I've got for my XSL...

Code:
<xsl:when test="name(../*[position()=$pos * 2])='xf:select1'">
  <xsl:apply-templates select="../*[position()=$pos * 2]" mode="s1evens"/>
</xsl:when>

So I've got a couple of elements in my XML called 'xf:select1' they all have an attribute called appearance, this can be one of three values, one for example is 'full'.

the problem is I can't test for this in my if statement because I would be writing it like this (I think)...

Code:
<xsl:when test="name(../*[position()=$pos * 2])='xf:select1[@appearance='full']'">

Here you can see I've got (') inside ('), and there's already a (") around the pair of them.

Is there a way around this?

Cheers,

Alex.
 
Obviously, the attribute is not part of the name, you are trying to match a name and an x-path-expression.
You'll need something like:
<xsl:when test="../xf:select1[position()=$pos * 2]/@appearance='full">
 
Yep, I've found a work around using an 'AND'

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top