How to check for missing attribute in XSL?

I have the following:

<xsl:variable name="myvar" select=".//spss:category[((not @varName) or @varName=$colVarName) and @text=$series]/spss:cell/@text"/>

What you need to do is select the text of the spss:celltext-Attribute attribute if it is a child spss:categorythat has

  • either a varNameAttribute with a value equal to$colVarName
  • OR no varNameAttribute in general

What happens is the following error message (sorry translating here, so just its gist):

Expected token ')'. Found Token '@'.
.//spss:category[((not → @ <- varName) or @varName = $ colVarName ...

The problem is solved! (see below)

+5
source share
2 answers

Ok, I think I found the error:

not ,

(not @varName) or @varName=$colVarName

not(@varName) or @varName=$colVarName
+9

- not() - , , , parens. - . node false, , @varName node, not(@varName) .

+2

All Articles