cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Pope" <>
Subject Cforms, Binding cross-referenced data
Date Thu, 12 Aug 2004 20:35:00 GMT

I'm trying to bind some data in a form, the data looks like this:

      <person id="0">
      <person id="1">
      <person id="2">
      <room id="0">
         <person idref="0"/>
         <person idref="1"/>
      <room id="1">
         <person idref="2"/>

The idea is that "Me" and "You" are in the "Lounge" and "Him" is in the

Now, I need to be able to bring up a repeater over all the people in a
specific room, and be able to modify the person data using that repeater.
My binding file has taken on various incarnations including this one:

<fb:context xmlns:fb=""
   <fb:value id="roomName"/><!-- @path is dynamic -->
   <fb:repeater id="people"><!--  @parent-path & @row-path are dynamic-->
         <fb:value id="id" path="@idref">
            <fd:convertor datatype="long"/>
         <fb:value id="personName"/><!-- @path is dynamic -->
            <person idref=""/>

Which is transformed as follows to allow the room to be dynamically selected
with a URI like:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"

   <xsl:param name="room"/>
   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

   <xsl:template match="/fb:context/fb:value[@id='roomName']">
      <fb:value id="roomName" path="rooms/room[@id={$room}]/name"/>

   <xsl:template match="/fb:context/fb:repeater[@id='people']">
      <fb:repeater id="people" parent-path="rooms/room[@id={$room}]"

      <fb:value id="personName"

   <xsl:template match="@*|node()">
         <xsl:apply-templates select="@*|node()"/>

Now, I think that's roughly how I want it to work, but:
"org.apache.commons.jxpath.JXPathException: Undefined function: current"

OK, anybody know how I use the XSLT currect() function from here?

An alternative that I toyed with involved replacing the definition of the
repeater with:

<fb:repeater id="people" parent-path="rooms/room[@id={$room}]"

(and adjusting the personName path to just "name")

Which is fine, but then whenever I delete or add a row, I delete the actual
person, rather than the reference to the person in the room, since the
repeater is effectively over the people/person rather than the room/person

Now that could be workable, I guess I'd have to write custom add and remove
row functions, but I would rather not (or is that a bad move?)

Instead of using the "current()" function, I've tried an Xpath for the
person/name binding that looks like this:

<fb:value id="personName"

But that just seems to select the first person/name referenced from the
room/person - I feel like I want to be using the current() function again to
get the correct id/idref.

Anybody know how to get the current() function working, or another solution
to the problem?

Thanks for your time.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message