--- Eric van der Vlist <[EMAIL PROTECTED]> wrote:
> Hi,
>
> When I attach a schema to my XForms form, I get this ugly excpetion when
> the instance isn"t valid:
>
> 2005-01-19 13:10:42,312 ERROR org.orbeon.oxf.pipeline.InitUtils null -
Exception at
>oxf:/apiculteurs/apiculteur-view.xsl, line 0, column 0
> java.lang.ClassCastException:
org.orbeon.oxf.processor.xforms.output.InstanceData
> at
>org.orbeon.oxf.processor.xforms.XFormsUtils.setInitialDecorationWorker(XFormsUtils.java:108)
> at
>org.orbeon.oxf.processor.xforms.XFormsUtils.setInitialDecorationWorker(XFormsUtils.java:113)
> at
>org.orbeon.oxf.processor.xforms.XFormsUtils.setInitialDecorationWorker(XFormsUtils.java:113)
> at
org.orbeon.oxf.processor.xforms.XFormsUtils.setInitialDecoration(XFormsUtils.java:88)
> at
org.orbeon.oxf.processor.xforms.input.XFormsInput$1.readImpl(XFormsInput.java:153)
> at org.orbeon.oxf.processor.ProcessorImpl$6.read(ProcessorImpl.java:945)
> at
>org.orbeon.oxf.processor.ProcessorImpl$ProcessorOutputImpl.read(ProcessorImpl.java:1106)
> at
org.orbeon.oxf.processor.ProcessorImpl.readInputAsSAX(ProcessorImpl.java:340)
> at
org.orbeon.oxf.processor.pipeline.TeeProcessor.access$100(TeeProcessor.java:27)
> at
org.orbeon.oxf.processor.pipeline.TeeProcessor$1.readImpl(TeeProcessor.java:48)
> at org.orbeon.oxf.processor.ProcessorImpl$6.read(ProcessorImpl.java:945)
> at
>org.orbeon.oxf.processor.ProcessorImpl$ProcessorOutputImpl.read(ProcessorImpl.java:1106)
> ...
>
> What can be the reason for that and is it possible to perform a schema
> validation using the same decoration mechanism that is used with
> xforms:bind constraints?
>
> Thanks,
>
> Eric
>
I believe this is still a problem, just the reasons are different. I also
have a schema attached, but I don't think that's all there is to it. It
appears to be related to handling attributes in XForms.
Like this:
<xforms:instance>
<form>
<A attr1="">
</A>
</form>
</xforms:instance>
And then, in the view:
<xforms:group ref="form/A">
<xforms:input ref="@attr1"/>
</xforms:group>
This will load fine the first time, but if the form is reloaded subsequent
times, it will fail with a ClassCastException very similar to the one in
the original post.
If attr1 is an element nested within A, everything is fine.
I've tracked this down to the way attributes are handled in
XFormsUtils.setInitialDecorationWorker - apparently it is different from
the way elements are handled in the same method.
For attributes, the first time around, the attribute.getData() returns
null, so no problem - a new InstanceData is constructed and passed to
setData. Subsequent times, though, getData() returns the previously
inserted InstanceData, which is then cast to LocalData causing a
ClassCastException.
For elements, there are the instanceof checks that handle this.
Here is a patch that seems to work for me:
------------------------- Patch start - Cut here -------------------------
--- XFormsUtils-1.7.java 2005-01-27 19:22:05.546875300 +1300
+++ XFormsUtils.java 2005-01-27 18:38:44.623979500 +1300
@@ -105,7 +105,13 @@
if
(!Constants.XXFORMS_NAMESPACE_URI.equals(attribute.getNamespaceURI())) {
int attributeId = ++currentId[0];
idToNodeMap.put(new Integer(attributeId), attribute);
- attribute.setData(new InstanceData((LocationData)
attribute.getData(), attributeId));
+ Object attributeData = attribute.getData();
+ if (attributeData == null || attributeData instanceof
LocationData)
+ attribute.setData(new InstanceData((LocationData)
attributeData, attributeId));
+ else if (attributeData instanceof InstanceData)
+ attribute.setData(new InstanceData(((InstanceData)
attributeData).getLocationData(), attributeId));
+ else
+ throw new OXFException("No Location data found in
instance");
}
}
for (Iterator i = element.elements().iterator(); i.hasNext();) {
------------------------- Patch end - Cut here -------------------------
Disclaimer: I don't really understand what is going on here, so I might be
completely off the mark. Someone from the Orbeon team needs to have a look
at this.
Regards,
Tomislav
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
orbeon-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/orbeon-user