OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Newbie - Schemas - Problem with minOccurs? or xmlns?

Thanks, I corrected those errors in the schema (below) but I'm still not
getting an error during validation.  The parse is done with the VB
DOMDocument object.  I have validateOnParse = True but it's not catching it.
This program has worked with DTDs before and the MS documentation says that
it will do schema validation as well.  I'll try to find another app to
validate.  Thanks again. 


<?xml version="1.0"?>
<addressBook xmlns="http://mymachine/schema"
   <cname>Joel Stout</cname>
   <cname>Harrison Ford</cname>
  <cname>Julia Roberts</cname>

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
<complexType name="record">
      <element name="cname" type="string"/>
      <element name="email" type="string"/>
<element name="addressBook">
         <element name="owner" type="my:record"/>
         <element name="person" type="my:record" 
                     minOccurs="8" maxOccurs="unbounded"/>

-----Original Message-----
From: Jeff Rafter [mailto:jeffrafter@earthlink.net]
Sent: Tuesday, July 24, 2001 10:58 AM
To: Stout, Joel R
Cc: xml-dev@lists.xml.org
Subject: Re: Newbie - Schemas - Problem with minOccurs? or xmlns?


There are a couple of problems I noticed in here:

> <?xml version="1.0"?>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
>                xmlns:xsi="http://mymachine/schema.xsd"
>        targetNamespace="http://mymachine/schema.xsd"
>        elementFormDefault="qualified"
>        attributeFormDefault="unqualified">

Becuase you are using the schema namespace as the default, you must prefix
you targetNamespace references: add xmlns:my="http://mymachine/schema.xsd"
in here.

> <complexType name="record">
>    <sequence>

>       <element name="cname" type="xsd:string"/>

Again, the schema namespace is the default-- so these should be "string"
with no prefix.

>       <element name="email" type="xsd:string"/>
>    </sequence>
> </complexType>
> <element name="addressBook">
>    <complexType>
>       <sequence>
>          <element name="owner" type="record"/>

Follwing the same problem, references to your targetNamespace types must be
prefixed so change this to "my:record"

>          <element name="person" type="record"
>                      minOccurs="8" maxOccurs="unbounded"/>
>       </sequence>
>    </complexType>
> </element>
> </schema>

Oftentimes (especially when starting out) it is easier to prefix the schema
namespace with "xs:" or "xsd:".  There are some examples in the schema
primer that do this. This is really personal preference though...  Based on
the errors in the schema I am guessing it was not checked-- this may be
because it couldn't recognize the type "record" and just pursued lax
validation-- but if so, that seems like a bug to me...  I would check your
validation code.

Good Luck,
Jeff Rafter
Defined Systems
XML Development and Developer Web Hosting