You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by David Marston/Cambridge/IBM <da...@us.ibm.com> on 2002/09/05 05:43:05 UTC

testing for a node (was: XSL question)




>Here is a sample XML-
>  <company>
>  <eng> M1</eng>
>  <secr> S1</secr>
>  <mgr> mg1</mgr>
>...
>  <ceo> c0</ceo>
>  </company>
>Here is the psedo [sic] code I am trying to write -
>for each node in <company>
>  if node is NOT equal to <ceo>
>    print STAFF
>  else
>  print OWNER

You already know that you need to use an xsl:choose to get the
two-way branch like then/else. There are a couple possible tests,
but I think test="name(.)='ceo'" best fits what you showed. The
way you phrased the question about whether the node is the <ceo>
node would lead to thoughts of generate-id() equivalence, but
that's overly precise and probably less efficient. The name
test generalizes to situations where you have more than one node
of the particular name.
.................David Marston