xf:model/@schema referring to schema inside that model causes link-exception

Project:formsPlayer
Version:1.5.3
Component:Code
Category:bug
Priority:normal
Assigned:Unassigned
Status:closed
Attachment:error.gif (8.65 KB)
Description

When a form has an model with a reference to an XML-Schema (inline or external), and the XML-Schema is non-empty, the form is not loaded and an error message appears (see attachment).

Below is an extremely simple form (one element only in the instance, no bindings, no widgets) with an extremely simple XML-schema, causing the error to occur.

If I make the XML-schema empty, i.e.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="my-schema" elementFormDefault="qualified" attributeFormDefault="unqualified"></xsd:schema>

then the form loads, but when clicking the submit button, the system correctly complains that "the element 'CRF' is used but not declared in the DTD/Schema". This at least proves that the application tries to read the XML-Schema.

Here is the very simple form:
<?xml version="1.0" encoding="iso-8859-1"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<object width="0" height="0" id="FormsPlayer" classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58">
<b>FormsPlayer has failed to load! Please check your installation</b>
</object>
<?import namespace="xforms" implementation="#FormsPlayer"?>
<head>
<title xmlns="http://www.w3.org/1999/xhtml">XForm automatically generated from ODM Study Definition</title>
<link xmlns="http://www.w3.org/1999/xhtml" rel="stylesheet" href="main.css" type="text/css"/>
<xforms:model id="F_LAB" schema="#my-schema">
<xforms:submission action="http://localhost:8080/XML4PharmaServer/ecrf2odm.do" method="post" id="submit" replace="all" omit-xml-declaration="false"/>
<xforms:instance>
<!--CRF xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"-->
<CRF xmlns="">hallo</CRF>
</xforms:instance>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" id="my-schema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!--xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/-->
<xsd:simpleType name="mytext">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<!--xsd:element name="test"/-->
</xsd:schema>
</xforms:model>
</head>
<body>
<h3>
<center>
<font color="red">eCRF XForms example <br/>Courtesy of<br/>
<a href="http://www.XML4Pharma.com/">XML4Pharma</a>
</font>
<p>
<font color="blue">Form: Laboratory</font>
</p>
</center>
</h3>
<xforms:group>
<xforms:submit id="submit">
<xforms:label>Submit Data</xforms:label>
</xforms:submit>
</xforms:group>
<h4>
<center>Copyright XML4Pharma 2004-2007</center>
</h4>
</body>
</html>

Updates

#1 submitted by JozefAerts on Sat, 2007-06-16 11:58

Sorry, the XML in the text seems to get lost. Here it comes in the attachment.

Best regards,

Jozef

#2 submitted by Mark Birbeck on Sat, 2007-06-16 12:37
Priority:critical» normal

To get your embedded mark-up to show, you need to set the 'input format' to 'Embedded HTML'. Now we can see the mark-up...are you really using the font tag? :)

Also, if you get a chance have you tested with the latest preview version (1.5.4.1003)?

#3 submitted by JozefAerts on Mon, 2007-06-18 16:50

The problem persists with FP version 1.5.4.1003.

#4 submitted by Paul Butcher on Fri, 2007-07-13 17:56

The schema is being applied twice to that model, once by being inside the model element, and once by being referred to in the schema attribute. This leads to a conflict. This is a bug.

A workaround can be achieved by removing "#my-schema" from the schema attribute, or moving the schema element out of the model element (either to a separate file, or to somewhere else in the form.

#5 submitted by JozefAerts on Sun, 2007-07-15 17:05

Thanks Paul !

A few remarks / questions

- Will this be fixed in 1.5 final ? Or is this due to the use of MSXML 6 ?

- the first solution worked well (removing "#my-schema" from the schema attribute), so I am changing my samples now. Need also to check whether after the change, the forms still work in older versions of FP.

- the second proposed solution does not seem to work (moving the schema outside the xf:model element). After having done so, FP does not crash anymore, but the widgets and input fields are not aware of the schema anymore. For example, the Calendar widget is not present anymore when I have an element for which in the schema it is declared to be of base type xsd:date, and I can fill in anything. Or should I do something more ?

#6 submitted by Paul Butcher on Mon, 2007-07-23 14:59
Title:form with schema causes FP to crash» xf:model/@schema referring to schema inside that model causes link-exception
Status:new» applied


- Will this be fixed in 1.5 final ? Or is this due to the use of MSXML 6 ?

Yes, it will be fixed in a forthcoming release.


- the first solution worked well (removing "#my-schema" from the schema attribute), so I am changing my samples now. Need also to check whether after the change, the forms still work in older versions of FP.

This should be the case, schemata specified within a model have been applied by default to instances in that model for a long time now.


- the second proposed solution does not seem to work (moving the schema outside the xf:model element). After having done so, FP does not crash anymore, but the widgets and input fields are not aware of the schema anymore. For example, the Calendar widget is not present anymore when I have an element for which in the schema it is declared to be of base type xsd:date, and I can fill in anything. Or should I do something more ?

Sorry, I failed to mention that the new location for schema would have to be before any model that references it.

#7 submitted by Anonymous on Tue, 2007-08-07 14:00
Status:applied» closed