Re: [xsl] xsk doubt [ ] vs ( )

Subject: Re: [xsl] xsk doubt [ ] vs ( )
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 25 Apr 2002 10:57:42 +0100
Hi William,

> i have a basic doubt regarding conditions..
> what is the difference between saying
> <xsl:if test = "not[. = mytag/mytext]">

This is testing whether the 'not' child element of the current node
has a value that is equal to the value of (one of) its child 'mytag'
elements's child 'mytext' elements.

> and saying
>
> <xsl:if test = "not(. = mytag/mytext)">

This is testing whether it's not the case that the value of the
current node is equal to the value of (one of) its child 'mytag'
elements's child 'mytext' elements.

> when do we use the [ ] and when do we use ( )??

[]s are predicates -- they are used to filter node sets according to
some condition. So for example:

  book[title = 'Genesis']

locates the book element child of the current node whose title element
child has the value 'Genesis'.

()s are used to wrap around expressions to indicate priority. So for
example:

  (a and b) or c

is different from:

  a and (b or c)

Or, in the case that you've shown above, they're used after the name
of a function to hold the arguments for that function. not(), for
example, is a function that negates the boolean value of whatever's
passed as its argument.

()s are also used as part of node tests, so for example the
expression:

  text()

is a shorthand for:

  child::text()

and collects all the text nodes that are children of the current node.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread