Re: [patch] removal of chiuldElement attributes in dispspec files
Boris Goldowsky <[email protected]>
| Newsgroups | gmane.editors.conglomerate.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2004-10-13 at 22:11 -0400, Douglas Burke wrote:
> Some thoughts I have about the use of an XPath expression to "personalise"
> the title section of tags (i.e. the xpath element of the header-info tag
> in an element):
>
> 1) How ofter should they be updated?
>
> At present I don't think they are, which means you have to reload the file
> if you add/change the item the Xpath expression points to. However,the
> only safe way I can think of doing it would be to update all values after
> any document change (or at least re-evaluate them all to see if the value
> has changed). Which seems nasty.
In general of course you are right -- xpath is a little too powerful --
but I imagine most real-world xpath expressions that would be used would
confine themselves to the children and possibly siblings of the element
they are attached to.
Perhaps one could write an XPath analysis function that would check for
references to "ancestors" or "siblings" or other possible ways of
looking "up" the tree, and thus determine whether re-evaluation is
necessary at each document change, or only after changes within a
smaller region.
Would it be possible to only re-evaluate these xpaths when they are
actually visible (or when you scroll to make them visible)?
>
> 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.
>
> 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.
Bng
--
Boris Goldowsky <[email protected]>