Hi, I still don't seem to be able to get the binding to work, or understand how it is supposed to work. My data now looks like this:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns:xi="http://www.w3.org/2001/XInclude"> <people> <person id="0"> <name>Me</name> </person> <person id="1"> <name>You</name> </person> <person id="2"> <name>Him</name> </person> </people> <rooms> <room id="0"> <name>Lounge</name> <xi:include href="#xpointer(/project/people/[EMAIL PROTECTED])"/> <xi:include href="#xpointer(/project/people/[EMAIL PROTECTED])"/> </room> <room id="1"> <name>Kitchen</name> <xi:include href="#xpointer(/project/people/[EMAIL PROTECTED])"/> </room> </rooms> </project> I've modified the XPath in the XPointers so that it points to the id attribute, rather than the position, which should be more robust! When you say "Use xinclude (or cinclude) transformer:" I'm not sure if you mean I should actually parse the above data with it... If so, then the rest of the example doesn't seem to make sense as I lose the xi:include elements. E.g., the repeater row-path"xi:include" would fail, so I'll have to assume that I'm leaving the data as it is, not transforming it. Right, now, binding: <fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:xi="http://www.w3.org/2001/XInclude" path="/project"> <fb:value id="roomName" path="rooms/[EMAIL PROTECTED]/name"/> <fb:repeater id="people" parent-path="rooms/[EMAIL PROTECTED]" row-path="xi:include"> <fb:identity> <fb:value id="id" path="@id"> <!-- so I can change it easy for now --> <fd:convertor datatype="long"/> </fb:value> </fb:identity> <fb:on-bind> <fb:value id="href" path="@href"/> <fb:value id="personName" path="/project/people/[EMAIL PROTECTED]/name"/> </fb:on-bind> <fb:on-insert-row> <fb:insert-node> <xi:include id="" href=""/> </fb:insert-node> </fb:on-insert-row> <fb:on-delete-row> <fb:delete-node/> </fb:on-delete-row> </fb:repeater> </fb:context> The identity won't work, 'cos <xi:include> elements don't have an id attribute. Of course... I could give it an idref, but that would seem to be going back to the way I had it. My personName doesn't work either, there is obviously no variable named id, I don't know how to locate the correct element to bind to. I think this is the crux of the problem. My form model looks like this: <?xml version="1.0"?> <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"> <fd:widgets> <fd:field id="roomName" required="false"> <fd:label>Room</fd:label> <fd:datatype base="string"/> </fd:field> <fd:repeater id="people"> <fd:widgets> <fd:field id="id"> <fd:label>ID</fd:label> <fd:datatype base="long"/> </fd:field> <fd:output id="href"> <fd:label>href</fd:label> <fd:datatype base="string"/> </fd:output> <fd:field id="personName"> <fd:label>Name</fd:label> <fd:datatype base="string"/> </fd:field> <fd:booleanfield id="select"> <fd:label>Select</fd:label> </fd:booleanfield> </fd:widgets> </fd:repeater> <fd:repeater-action id="addPerson" repeater="people" action-command="add-row"> <fd:label>Add Person</fd:label> </fd:repeater-action> <fd:repeater-action id="removePeople" repeater="people" action-command="delete-rows" select="select"> <fd:label>Remove Selected People</fd:label> </fd:repeater-action> </fd:widgets> </fd:form> I'm still really confused as to how this should work. If I am supposed to XInclude transform the data, then I can easily modify the binding to manipulate each room/person, but how do I then create the xi:include tags, and map the new data back onto the old data? It would seem to be much better to modify the data "in situ", but I'm not that fussed as long as it works. I feel pretty close, but am unsure how to correctly bind the person name in both directions. Thanks for all help so far. Ben -----Original Message----- From: Timur Izhbulatov [mailto:[EMAIL PROTECTED] Sent: 29 July 2004 12:30 To: [EMAIL PROTECTED] Subject: Re: Cforms, Binding & Cross-Referenced data Ben Pope писал(а): > Hi, > > I don't seem to be able to get my head around binding cross-referenced > data I purpose you to try this approach. Use xinclude (or cinclude) transformer: <rooms> <room id="0"> <name>Lounge</name> <xi:include href="#xpointer(/project/people/person[2])"/> <xi:include href="#xpointer(/project/people/person[3])"/> </room> <room id="1"> <name>Kitchen</name> <xi:include href="#xpointer(/project/people/person[1])"/> </room> </rooms> In this case form model may looks like this (don't know if this works): <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:i18n="http://apache.org/cocoon/i18n/2.1"> <fd:repeater id="people"> <fd:widgets> <fd:output id="id"> <fd:datatype base="long"/> </fd:output> <fd:output id="href"> <fd:datatype base="string"/> </fd:output> <fd:booleanfield id="select"> <fd:label>Select</fd:label> </fd:booleanfield> </fd:widgets> </fd:repeater> <fd:repeater-action id="addperson" action-command="add-row" repeater="contacts"> <fd:label>Add</fd:label> </fd:repeater-action> <fd:repeater-action id="removeperson" action-command="delete-rows" repeater="contacts" select="select"> <fd:label>Remove</fd:label> </fd:repeater-action> </fd:widgets> </fd:form> And binding (check if this works): <fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:xi="http://www.w3.org/2001/XInclude" path="/project/rooms/room[1]" > <fb:repeater id="people" parent-path="people" row-path="xi:include"> <fb:identity> <fb:value id="id" path="@id"> <fd:convertor datatype="long" /> </fb:value> </fb:identity> <fb:on-bind> <fb:value id="href" path="@href" /> </fb:on-bind> <fb:on-delete-row> <fb:delete-node /> </fb:on-delete-row> <fb:on-insert-row> <fb:insert-node> <xi:xinclude id="" href=""/> </contact> </fb:insert-node> </fb:on-insert-row> </fb:repeater> </fb:context> Timur --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
