Timothy Larson wrote:
--- Marc Portier <[EMAIL PROTECTED]> wrote:
Timothy,
the rudimentary dox (see wiki) on the simple-repeater-binding are explaining this:
It is currently only supporting binding back to XML (so I suspect that you were testing versus a java beans backend model here?)
I was attempting and failing to bind to an XML document. The load worked, but the save gave the exception.
Sylvain?
I know Sylvain created this:
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/java/org/apache/cocoon/util/jxpath/DOMFactory.java
exactly to cater for the automatic creation (factory) of DOMNodes triggered from jxpath createPath statements...
But I have to admit I can't find where that thingy gets registered on the jxpath context (too much relying on the advanced search of eclipse?)
Sorry, I'm very late on all this.
Actually, there's currently no use of this class in Cocoon samples, but I use it on my projects. Here's how: in the flow, I don't load/save the DOM directly, but through a JXPathContext as follows;
var doc = readDocument(url);
var bindingCtx = createBindingContext(doc);
form.load(bindingCtx);
form.showForm("pipeline");
form.save(bindingCtx);And here's the createBindingContext function:
function createBindingContext(document) {
// Create a JXPath context on the document.
var xpathContext = Packages.org.apache.commons.jxpath.JXPathContext.newContext(document);
// Set it to lenient
xpathContext.setLenient(true);
// Add the necessary factory create elements and attributes as needed on non-existing paths
xpathContext.setFactory(new Packages.org.apache.cocoon.util.jxpath.DOMFactory());
return xpathContext;
}
Having to explain how this work yesterday during a training, I felt that it should be better hidden in the binding machinery, since this is somehow needed every time we bind a form do a DOM (unless the DOM already contains the whole XML structure).
So what about adding this into the AbstractJXPathBinding: if the object passed to load/save is a Node, then add the DOMFactory automatically.
Sylvain
-- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects } Orixo, the opensource XML business alliance - http://www.orixo.com
