[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

  • From: "Stout, Joel R" <Stout.Joel@e...>
  • To: 'Jeff Rafter' <jeffrafter@e...>,"Stout, Joel R" <Stout.Joel@e...>
  • Date: Tue, 24 Jul 2001 18:16:47 +0000

joel stout
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. 

Joel

------------------------addrbk.xml
<?xml version="1.0"?>
<addressBook xmlns="http://mymachine/schema"
	       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	       xsi:schemaLocation="http://mymachine/schema 
        	                   http://mymachine/schema.xsd">
<owner>
   <cname>Joel Stout</cname>
   <email>Stout.Joel@e...</email>
</owner>
<person>
   <cname>Harrison Ford</cname>
   <email>hford@f...</email>
</person>
<person>
  <cname>Julia Roberts</cname>
  <email>jr@p...</email>
</person>
</addressBook>

------------------------schema.vsd
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
               xmlns:xsi="http://mwa40cj601/schema.xsd"
	       targetNamespace:my="http://mwa40cj601/schema.xsd"
	       elementFormDefault="qualified"
	       attributeFormDefault="unqualified">
<complexType name="record">
   <sequence>
      <element name="cname" type="string"/>
      <element name="email" type="string"/>
   </sequence>
</complexType>
<element name="addressBook">
   <complexType>
      <sequence>
         <element name="owner" type="my:record"/>
         <element name="person" type="my:record" 
                     minOccurs="8" maxOccurs="unbounded"/>
      </sequence>		
   </complexType>
</element> 
</schema>

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


Joel,

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
http://www.defined.net
XML Development and Developer Web Hosting

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.