>I have a XML that looks like the one bellow and an xslt in which I am >trying to select, let's say, the third (absolute) 'call' element. >In xalan 2.0.0 I did it like this: //call[position() = $current_call], >where current_call = 3, and it selected the call element from '<calls >type="D2-CorporateLink" header="Verbindungen aus dem D2-Netz">'. >In xalan 2.3.1 if I do the same I get all the call elements (or if >'current_call=1' I get 3 call elements, the first from each calls >sub-tree). If I change this to "//call[(count(preceding::call) + 1) = > $current_call]" I get the call element I want, but for big XML files >(about 500 call elements) it takes a lot of time (more than 10 times >the time with xalan 2.0.0). Does anybody know a different >approach/solution to this?
This is one of those subtle details in XPath. The change from 2.0.0 to 2.3.1 made Xalan conform more exactly to the XPath spec. Note that parentheses can be applied to form a new node-set, in document order, before applying the predicate, like so: (//call)[position() = $current_call] Does that accomplish what you want? The notion that //call[3] is meaningful from elsewhere in the tree gets me worried about the overall data design. If you need to retrieve designated "call" elements while in an unrelated context, consider giving each "call" an attribute which describes the salient property. (//call)[EMAIL PROTECTED] = $call_I_seek] leads to more readable code when $call_I_seek takes on a value like "begin" instead of just "3". Better yet, it sets you up to use key(), which can boost performance if you retrieve the same "call" more than once. ...............David Marston
