Page 1 of 1

Problem Validating XForm Against Schema

Posted: Fri Sep 24, 2004 6:41 pm
by bwinspur
I have an xforms file which is failing validation for no
reason I can see. The first few lines of the file are as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xforms:model
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xs:schemaLocation="http://www.w3.org/2002/xforms
http://www.w3.org/MarkUp/Forms/2002/XForms-Schema.xsd"
> <!-- error diagnosed on this line -->
<xforms:instance>
<credit-card>
<type/>
..... etc.

The document was developed outside Oxygen, but I believe that it
is probably valid, and that the syntax errors are probably invalid.

---------------

The validation failure is diagnosed as follows

Severity 2
Description cvc-elt.1: Cannot find the declaration of element 'xforms:model'.
Resource xforms-credit-card-model.xml
In Folder vendorSite/webRoot/WEB-INF/resources/pagesets/checkout
Location line 7
Creation Time September 24, 2004 8:25:18 AM

------------

If anybody can tell me what am I doing to cause the above error, and
how I can get the document to to validate, I would appreciate it.

Bill.[/code]

Posted: Fri Sep 24, 2004 7:51 pm
by george
Hi Bill,

To associate a schema with a target namespace with an instance document you need to use the xsi:schemaLocation attribute from the http://www.w3.org/2001/XMLSchema-instance namespace like below:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xforms:model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2002/xforms http://www.w3.org/MarkUp/Forms/2002/XForms-Schema.xsd"
xmlns:xforms="http://www.w3.org/2002/xforms">
...
Best Regards,
George

Posted: Sat Sep 25, 2004 10:49 am
by bwinspur
Thanks George, that worked, Bill.

Posted: Sat Sep 25, 2004 11:52 am
by george
Hi Bill,

I remember I wanted to add this to my previous post but I forgot...

If you start with a document like:

<?xml version="1.0" encoding="UTF-8"?>
<xforms:model xmlns:xforms="http://www.w3.org/2002/xforms">
...
</xforms:model>

and use the Associate schema action and provide http://www.w3.org/MarkUp/Forms/2002/XForms-Schema.xsd as the schema you will get the schema instance namespace binding to xsi and xsi:schemaLocation added automatically in your document.

Best Regards,
George

Posted: Sat Sep 25, 2004 10:57 pm
by bwinspur
Thanks again George.

I realize that one has to specify home-grown schemas explicitly, but it would be a major help if the AssociateSchema function offered a list of the w3c standard schemas to choose from.

Bill.

Posted: Mon Sep 27, 2004 11:16 am
by george
Hi Bill,

Yes, that is a nice feature. I added your request on our bugzilla.

Best Regards,
George