cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Klotz <peter.kl...@blue-elephant-systems.com>
Subject Cocoon forms binding and XML namespaces
Date Mon, 06 Mar 2006 16:55:26 GMT
Hi,

we are using Cocoon 2.1.8 and have a form for creating a new object.
That means there is no data loaded into the form but only saved from the
form to a XML document.

The binding using a binding file uses XML namespaces, which seems to be
the only difference to some of the samples, where one (dynamic repeater)
also creates a new document and then only saves the form.

The problem that we get is

Caused by: org.apache.commons.jxpath.JXPathException: Exception trying
to create xpath /ovo:policy; Cannot map non-null prefix when creating a
document element
	at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath(JXPathContextReferenceImpl.java:450)
	at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPath(JXPathContextReferenceImpl.java:427)
	at
org.apache.cocoon.forms.binding.ContextJXPathBinding.doSave(ContextJXPathBinding.java:101)
	at
org.apache.cocoon.forms.binding.JXPathBindingBase.saveFormToModel(JXPathBindingBase.java:250)
	at
org.apache.cocoon.forms.binding.JXPathBindingBase.saveFormToModel(JXPathBindingBase.java:264)
	at sun.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:230)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:1134)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:190)
	at
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:138)
	at
org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at
org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java:1591)
	at
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(FOM_JavaScriptInterpreter.java:853)
	... 61 more

Also the method of previously loading a existing empty or full XML
document and trying to save to this does not work with even worse
exceptions.

I can't but assume that the reason is namespaces because the sample does
 exactly the same as we do and does work.

flow script function:
---
function newPolicy()
{
    var definitionURI = cocoon.parameters["newDefinitionURI"];
    var bindingURI = cocoon.parameters["newBindingURI"];

    var form = new Form(definitionURI);
    form.createBinding(bindingURI);

    form.showForm("newPolicy-display");

    var policy =
Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    var policy = factory.newDocumentBuilder().newDocument();

//policy.appendChild(policy.createElementNS("http://blue-elephant-systems.com/midas/ovo/1.0",
"ovo:policy"));
    // var policy = loadDocument("logfile.xml");
    // get the basic policy from the form
    form.save(policy);

    // just for debugging
    saveDocument(policy, "output.xml");

    // go into edit phase
    form = getPolicyForm(policy);
    cocoon.request.setAttribute("formMode", "edit");

    form.showForm("editPolicy-display");

    form.save(policy);
    saveDocument(policy, "output.xml");
}
---

sample simple binding
---
<?xml version="1.0"?>
<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
  xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
  xmlns:ovo="http://blue-elephant-systems.com/midas/ovo/1.0"
  path="/ovo:policy">

  <fb:value id="type" path="@type"/>
  <fb:value id="name" path="@name"/>

</fb:context>
---

any idea what one could do to get this to work?


Thanks, Peter

Mime
View raw message