Re: [patch] removal of chiuldElement attributes in dispspec files

Doug Burke <[email protected]>
Newsgroups gmane.editors.conglomerate.devel
Message-ID <[email protected]>
On Oct 14, 2004, at 8:50 AM, Boris Goldowsky wrote:

>
>>
>> 2) Examples where I find the use of XPath limiting
>>
>> For a document containing something like
>>
>>   <examples><example>...</example><example>...</example></examples>
>>
>> I have xpath="concat('Number of examples = ',count(example))" for the
>> examples tag. I would like each example tag to have an XPath 
>> expression
>> which results in the text "Example <n> of <m>". It's easy to get the 
>> <m>,
>> but not the <n>, via XPath. Or perhaps I should say I can't work out 
>> how
>> to get the <n>.
>
> <n> = count(preceding-sibling::example)+1
>
> or, depending on what context is given to the XPath engine, simply
>  position()
> could be made to work.

Yahay. The use of preceding-sibling does what I want. Thanks for that. 
I never got position() to work when I last tried it a while back.

>
>>
>> Another case is that of conditionals; e.g. if there is a child element
>> called title then use its contents, but if not then act as if there 
>> is no
>> XPath expression.
>
> I don't see an easy solution for that.  Perhaps there should be a
> fallback display for any case where the xpath results in a null or an
> empty string.

One idea is to allow the user to supply a XSL template which, when run, 
gives the text to use. I think there are more urgent things to 
implement first though :-)

Doug
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.