Mariusz Idzikowski wrote:
> 
>> [2] Then use another XPath expression to obtain the ID of the book
>> having the title chosen by the user. Something like:
>>
>> <get expression="//bo...@title='%_']/@id"/>
> 
> Your solution rests on the assumption that all titles in the document should 
> be unique, which may not necessarily be the case...
> 
> If the pick command could (optionally, of course) return the *index* of the 
> selected item (like e.g. JList's getSelectedIndex method or similar methods 
> of ListBox-like controls in other languages), perhaps this problem could be 
> solved in a way similar to this:
> 
> <set variable="ids" expression="//book/@id"/>
> <set variable="titles" expression="concat('&quot;', join(//book/@title, 
> '&quot; &quot;'), '&quot;')" plainString="false" />
> <command name="pick" parameter="'Select a title' 
> some-new-get-index-instead-of-value-parameter  $titles"/>
> <get expression="$ids[%_]"/>       <!-- is it possible to index into a user 
> variable? -->
> 
> I suspect that there may be other scenarios when the pick command returning 
> the index rather than value of the selected item could prove helpful.

I don't think so. I do not remember any such scenario.



> 
> Is there any hope that such a functionality could be implemented in the 
> future?
> 

I'm sorry but the answer is no. If you want something more elaborate
that what I have suggested, I'm afraid you'll have to implement it
yourself in Java.




Reply via email to