oceatoon wrote:
Hi Marc

my Cform is binded to an XML document,
This is the part we are concirned with :
<fb:repeater id="uploads" parent-path="newuploads" row-path="upload">
<rooms>
<room id="1">
<newuploads>
<upload path=""/>
<upload path=""/>..etc <newuploads> </room>
<room id="2">
<newuploads>
<upload path=""/>
<newuploads> </room>
</rooms>


*******************************************
<fb:on-bind>
<fb:javascript id="path" path="@path" direction="save">
<fb:save-form>


if(widget.getValue() != null){
var roomid = jxpathContext.parentContext.getValue("../../@id");
var formValue =
"/room"+roomid+"/"+widget.getValue().getHeaders().get("filename");
jxpathPointer.setValue(formValue); }

</fb:save-form></fb:javascript></fb:on-bind>

As you can see my @path should be relative to the room it is in
So on bind I would like to retreive the id of the room it is in ;)
but I cant go back further than <upload> which is the parentContext on the
JXPathContext, var roomid = jxpathContext.getValue("../../@id") doesn't
work , neither does the one above ???



hm, I'm only assuming that the pathContext used above does the same as an additional ../ in front of the path, so the equivalent should have been:


var roomid = jxpathContext.getValue("../../../@id")

is this possible or do I really have to do a post bind transformation ??
I'm sure there's a way to XPoint at the whole binded document??


there is no immidiate reason I can think off why this shouldn't work, close up testing should yield more hinting messages..


just to make sure I made some tests based on the form2 sample included with the cocoon distro

see:
http://cvs.apache.org/viewcvs.cgi/cocoon/trunk/src/blocks/forms/samples/forms/form2_bind_xml.xml?rev=30942&root=Apache-SVN&view=auto

inserting at line 101 something like this:
var testValue = jxpathContext.getValue("../../../info/email/@boolBindingWorks");
print("xpath-test 1 returns: " + testValue);
testValue = jxpathContext.getValue("//email/@boolBindingWorks");
print("xpath-test 2 returns: " + testValue);
testValue = jxpathContext.getValue("ancestor::context/info/email/@boolBindingWorks");
print("xpath-test 3 returns: " + testValue);


just works for me, I know it's slightly different to what you do, but this shows there is no navigation limitation to the xpath expressions.

a slower xpath search that removes the need to get the number of keading ../ levels correct for testing could be jxpathContext.getValue("anscestor::room/@id")

HTH,
-marc=
--
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
[EMAIL PROTECTED]                              [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to