How to parse an xform document with Xerces?

I am a newbie to xforms and xml schema. Just for kicks, I am trying to parse
the xml document in section 2.7 of the xform spec using the Xerces Java
Parser 1.4.4. I have set validating and namespaceAware to true. However I am
not getting too far with this exercise. Can someone help?

1) The first error I got was on line 2, which is the <!DOCTYPE> tag:

01 <?xml version="1.0" encoding="UTF-8"?>
02 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN">
03 <html xmlns="http://www.w3.org/1999/xhtml"
04       xmlns:xform="http://www.w3.org/2001/08/xforms"
05       xmlns:pay="http://commerce.example.com/payment"
06       xml:lang="en">

org.xml.sax.SAXException: Stopping after fatal error: White space is
required between the public identifier and the system identifier.

2) So I changed line 2 as follows (after looking at some other xhtml
documents!):

01 <?xml version="1.0" encoding="UTF-8"?>
02 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
03 <html xmlns="http://www.w3.org/1999/xhtml"
04       xmlns:xform="http://www.w3.org/2001/08/xforms"
05       xmlns:pay="http://commerce.example.com/payment"
06       xml:lang="en">

This allowed me to go a little further, but now I got the following error
when I hit the <xform:xform> tag:

org.xml.sax.SAXParseException: Element type "xform:xform" must be declared.

3) So I added the two lines shown below (#7 & #8) to tell Xerces where to
find the xforms schema?

01 <?xml version="1.0" encoding="UTF-8"?>
02 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
03 <html xmlns="http://www.w3.org/1999/xhtml"
04       xmlns:xform="http://www.w3.org/2001/08/xforms"
05       xmlns:pay="http://commerce.example.com/payment"
06       xml:lang="en"
07       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
08       xsi:schemaLocation="http://www.w3.org/2001/08/xforms xforms.xsd">

Here xforms.xsd is the xforms schema from appendix A of the spec. Anyway now
I am getting the following error when Xerces tries to parse xforms.xsd:

org.xml.sax.SAXParseException: Schema error: prefix : [xml] cannot be
resolved to a URI.

Where do I go from here? Also why did the changes #1 and #2 above fix the
initial errors?

Thanks for your help. 

Naresh Bhatia
Sapient
One Memorial Drive, Cambridge, MA 02142
Tel: 617-761-1771  Fax: 617-621-1300
Email: nbhatia@sapient.com

Received on Monday, 26 November 2001 00:13:10 UTC