You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by jcplerm <jc...@ameritech.net> on 2003/10/20 16:59:19 UTC
Woody binding on XML subtree
Is there a way of having a Woody form being populated through the binding framework in a way that the form involves just a subtree of the original XML doc?
For instance, given the following complete XML doc:
<root>
<elem id="100">
<name>name100</name>
<address>address100</address>
</elem>
<elem id="101">
<name>name101</name>
<address>address101</address>
</elem>
<elem id="102">
<name>name102</name>
<address>address102</address>
</elem>
</root>
I would like a form to edit the just the subtree located by "/root/elem[@id='101']".
Can the binding definition file somehow be parametrized, or can something along these lines be done?
Thanks,
jlerm
Re: Woody binding on XML subtree
Posted by Bruno Dumon <br...@outerthought.org>.
On Mon, 2003-10-20 at 16:59, jcplerm wrote:
> Is there a way of having a Woody form being populated through the
> binding framework in a way that the form involves just a subtree of
> the original XML doc?
>
> For instance, given the following complete XML doc:
>
> <root>
> <elem id="100">
> <name>name100</name>
> <address>address100</address>
> </elem>
> <elem id="101">
> <name>name101</name>
> <address>address101</address>
> </elem>
> <elem id="102">
> <name>name102</name>
> <address>address102</address>
> </elem>
> </root>
>
> I would like a form to edit the just the subtree located by
> "/root/elem[@id='101']".
You could extract just that element from the document and pass that to
the binding.
>
> Can the binding definition file somehow be parametrized, or can
> something along these lines be done?
Nope, there's currently no such feature.
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org bruno@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Woody binding on XML subtree
Posted by Gianluca Morello <mo...@S1.my-tv.it>.
Hi,
my approach is:
create a document fragment from the original document and bind it to the
woody form.
after form submission reappend the fragment to the original document and
save it.
this is my code:
try to adapt to your xml files, i'm using the position of the element i want
to edit but you can use also an unique attribute.
function form2xml() {
var pos = cocoon.request.getParameter("pos");
document=loadDocument(documentURI);
var nl =
document.getFirstChild().getChildNodes().item(1).getChildNodes();
for ( i = 0; i < nl.getLength (); i++) {
var cur_node=nl.item(i);
if (cur_node.getNodeType()==1) {
counter++;
if (counter==pos) {
var newdoc=document.createDocumentFragment();
newdoc.appendChild(cur_node);
form.load(newdoc);
form.show("display-edit", formHandler);
form.save(newdoc);
nl.item(1).getParentNode().appendChild(
newdoc.getFirstChild());
saveDocument(document, documentURI);
return;
}
}
}
}
Hope this help.
----- Original Message -----
From: "Kamal Dalal" <ka...@banoora.net>
To: <us...@cocoon.apache.org>
Sent: Friday, January 16, 2004 10:41 AM
Subject: Re: Woody binding on XML subtree
> On Mon, 20 Oct 2003 09:59:19 -0500, jcplerm wrote:
>
> > Is there a way of having a Woody form being populated through the
binding
> > framework in a way that the form involves just a subtree of the original
> > XML doc?
> >
> > For instance, given the following complete XML doc:
> >
> > <root>
> > <elem id="100">
> > <name>name100</name>
> > <address>address100</address>
> > </elem>
> > <elem id="101">
> > <name>name101</name>
> > <address>address101</address>
> > </elem>
> > <elem id="102">
> > <name>name102</name>
> > <address>address102</address>
> > </elem>
> > </root>
> >
> > I would like a form to edit the just the subtree located by
> > "/root/elem[@id='101']".
> >
> > Can the binding definition file somehow be parametrized, or can
something
> > along these lines be done?
>
> It is possible to parametrize the binding file by filtering it through a
> JXTemplateGenerator for example. Here is an outline of the solution :
>
> In your sitemap, pass a form binding uri with value="cocoon:/bind_with"
> The matcher for bind_with generates:
>
> <map:generate type="jx" src="form_bind.jx">
> <map:parameter name="parentpath"
> value="elem[@id={myparameter}]"/>
>
> and in your form_bind.jx repeater, you will have :
>
> parent-path="${parameters.getParameter('parentpath')}"
>
> -Kamal
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Woody binding on XML subtree
Posted by Kamal Dalal <ka...@banoora.net>.
On Mon, 20 Oct 2003 09:59:19 -0500, jcplerm wrote:
> Is there a way of having a Woody form being populated through the binding
> framework in a way that the form involves just a subtree of the original
> XML doc?
>
> For instance, given the following complete XML doc:
>
> <root>
> <elem id="100">
> <name>name100</name>
> <address>address100</address>
> </elem>
> <elem id="101">
> <name>name101</name>
> <address>address101</address>
> </elem>
> <elem id="102">
> <name>name102</name>
> <address>address102</address>
> </elem>
> </root>
>
> I would like a form to edit the just the subtree located by
> "/root/elem[@id='101']".
>
> Can the binding definition file somehow be parametrized, or can something
> along these lines be done?
It is possible to parametrize the binding file by filtering it through a
JXTemplateGenerator for example. Here is an outline of the solution :
In your sitemap, pass a form binding uri with value="cocoon:/bind_with"
The matcher for bind_with generates:
<map:generate type="jx" src="form_bind.jx">
<map:parameter name="parentpath"
value="elem[@id={myparameter}]"/>
and in your form_bind.jx repeater, you will have :
parent-path="${parameters.getParameter('parentpath')}"
-Kamal
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org