I'm using Xerces 1.4.2 and I have a question about Schema design etc...I'm
sure this is a newbie question...

I have a schema that validates an instance of an XML doc...what I don't
understand is that if I remove the xsd: qualifiers and let the namespace be
defaulted to the 2001/schema etc..it complains about my request
element...If I specifically say no namespaces then why is it complaining?
I suppose it's not a big deal to leave the xsd: in there but shouldn't it
allow me to not have it in there if I tell it to process with
xsi:noNamespaceSchemaLocation?

<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="simple.xsd" server="myserver" database
="mydatabase">
 <mmm_facility_code>ht</mmm_facility_code>
 <qc_status_code>Qtx</qc_status_code>
</request>

Here is an example of a schema that works...
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
     <xsd:element name="mmm_facility_code" type="xsd:string"/>
     <xsd:element name="qc_status_code" type="xsd:string"/>
     <xsd:element name="request">
          <xsd:complexType>
               <xsd:sequence>
                    <xsd:element ref="mmm_facility_code"/>
                    <xsd:element ref="qc_status_code"/>
               </xsd:sequence>
               <xsd:attribute name="server" type="xsd:string"
                                        use="required"/>
               <xsd:attribute name="database" type="xsd:string" use
="required"/>
          </xsd:complexType>
 </xsd:element>
</xsd:schema>

..Now this schema does not...
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema";>
 <element name="mmm_facility_code" type="string"/>
 <element name="qc_status_code" type="string"/>
 <element name="request">
      <complexType>
           <sequence>
                <element ref="mmm_facility_code"/>
                <element ref="qc_status_code"/>
           </sequence>
           <attribute name="server" type="string" use="required"/>
           <attribute name="database" type="string" use="required"/>
      </complexType>
 </element>
</schema>

This generates the following SAX exception...
Generated fault:SAXException
Error msg:The content of element type "request" must match
"(mmm_facility_code,qc_status_code)".

Thanks
Doug

Reply via email to