RE: referencing a schema fails

[copied to list]

On Tue, 2003-08-05 at 15:26, John Haber wrote:
> I appreciate the kind help.  Here you go.  I've no doubt there are plenty of
> problems with my drafts here, and no doubt you needn't be burdened with
> in-depth analysis of them.  I just won't find them until I get past an error
> at the root element.

OK, the problem is that there are many errors in the schema.  I suspect
that what is happening is that you schema validator is hiding the
problems it is having whilst performing schema validation, and then
complaining that it can't find the schema because it has failed to parse
it.

If you submit the file to the validator at:

   http://tools.decisionsoft.com/cgi-bin/schemaValidate.cgi

you will see a bunch of errors that start with -1 (I admit that it's not
the most intuitive description), these are errors with the schema
itself.  Unfortunately, the errors returned by the parser about the
schema are typically very cryptic, so here's a few pointers about what
you're doing wrong:

1. Element "theme".  You're trying to add an attribute ("applied") and
apply a restriction to the complex content.  XML Schema does not allow
you to do this in one step (as it constitutes both an extension and a
restriction).  Instead, you need to go via an intermediate type:

   <xsd:simpleType name="themeType">
      <xsd:restriction base="xsd:string">
         <xsd:enumeration value="post">
         [ ... ]
      </xsd:restriction>
   </xsd:restriction>

Then you can define your complexType based on this:

   <xsd:element name="theme">
     <xsd:complexType>
        <xsd:simpleContent>
           <xsd:extension base="themeType" >
              <xsd:attribute name="applied" base="xsd:string" />
           </xsd:extension>
        </xsd:simpleContent>
      </xsd:complexType>
    </xsd:element>

2. Elements "theme", "place", "lname", "intro", "para", "image".  These
have both a named base type ("xsd:string") and an in-line type
definition.  If you are adding attributes to a element that you want to
have xsd:string content, use a construct similar to the above
(complexType/simpleContent/extension base="xsd:string"/attribute).  If
you want the element to contain a mixture of other elements and text
then you need to use mixed content (add a mixed="true" attribute to the
complexType definition).

That should keep you going.  Once you have *all* the reported schema
errors fixed, then you should start worrying about why the instance
doesn't validate.

You might like to take a look at IBM's Schema Quality Checker.  This
tool reports errors in the schema itself and usually does so with decent
error reports.

HTH

Paul   
-- 
Paul Warren, Client Services           DecisionSoft Limited
+44-1865-203192                        http://www.decisionsoft.com

Received on Tuesday, 5 August 2003 11:07:43 UTC