cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ulrich Mayring <u...@denic.de>
Subject Re: XPath with FP Taglib
Date Thu, 26 Oct 2000 15:04:09 GMT
Jeremy Quinn wrote:
> 
> I select the node I want to insert-before (or after) as the context :
> 
>                 <fp:resource id="external-item">
>                         <fp:resource-file>../index.xml</fp:resource-file>
>                         <fp:resource-node>item[position()=<request:get-parameter
> name="item"/>]</fp:resource-node>
>                         <fp:default-mode>insert-before</fp:default-mode>
>                 </fp:resource>
> 
> this says: "make a new node called 'item' inserting it before the node that
> matches the XPath"

Sorry to be such a pest, Jeremy, in my case this doesn't work. Here's
what I have in my Resource as XPATH:

<fp:resource-node>/root/item[id=count(//item)]</fp:resource-node>
<fp:default-mode>insert-after</fp:default-mode>

This selects the last item, the ids are numbered from 1 to 18 (which is
currently the last item). Now I do, as you suggested:

<fp:write to="resource" select="item">
...
</fp:write>

This inserts an empty <item/> tag into the last item, not after it. It
looks like this:

<item>
<id>18</id>
...
<item/><!-- this was inserted -->
</item>

But of course I want the item to go after item #18. If I just set the
XPATH in the resource to /root, then it doesn't work either. I get an
error message that says fp cannot write to multiple selected nodes. This
is sensible, as there are 18 item nodes. But selecting one of those 18
items will insert the new item INTO it, instead of AFTER it.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

Mime
View raw message