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

XML Schema Problem

  • To: xml-dev@l...
  • Subject: XML Schema Problem
  • From: Rick Taylor <taylor@p...>
  • Date: Tue, 09 Dec 2003 14:17:25 -0700

xml schema nonamespace
I am getting inconsistent results from various validating parsers based on 
importing/including declaring an element as a simpleType that is created 
based on a union in a schema with no namespace.

Is it possible to define a simpleType using a union and specifying 
memberTypes without assigning a namespace?

I start with a schema with nonamespace that defines three simpleTypes the 
third being a union of the first two.  I include this within another schema 
that has a namespace and then access the union type definition 
"usZipOrCanadaPostal" (see below).  Both XSV and Xerces validate schema 
with this arrangement.  XMLSPY also validates with no error.  However, 
MSXML complains that it cannot find the two memberType definitions.

<xsd:schema
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="unqualified"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<xsd:simpleType name="usZip">
   <xsd:restriction base="xsd:string">
     <xsd:pattern value="[0-9]{5}(-[0-9]{4})?"/>
   </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="canadaPostal">
   <xsd:restriction base="xsd:string">
     <xsd:pattern value="([A-Za-z]\d[A-Za-z]( |-)\d[A-Za-z]\d)"/>
   </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="usZipOrCanadaPostal">
   <xsd:union memberTypes="usZip canadaPostal"/>
</xsd:simpleType>

</xsd:schema>

This is the schema that includes the definitions.  It is considered valid 
in XSV, Xerces, and XMLSPY but not MSXML 4.0:

<xsd:schema
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:ns1="http://www.test.MemberTypes"
      xmlns="http://www.test.MemberTypes"
      targetNamespace="http://www.test.MemberTypes"
      version="0.1"
      elementFormDefault="qualified">

<xsd:include schemaLocation="testComponent.xsd"/>

<xsd:element name="Address" type="AddressType"/>
  <xsd:complexType name="AddressType">
   <xsd:sequence>
    <xsd:element name="Name" type="xsd:string"/>
    <xsd:element name="Street" type="xsd:string"/>
    <xsd:element name="City" type="xsd:string"/>
    <xsd:element name="StateProvince" type="xsd:string"/>
    <xsd:element name="Country" type="xsd:string"/>
    <xsd:element name="PostalCode" type="usZipOrCanadaPostal"/>
   </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Also, If I alter the schema structure slightly so that I import (instead of 
include) the same type definitions (via a proxy schema),  MSXML still 
returns an error, XMLSPY now returns an error of an "unidentified value for 
memberTypes" and XSV and Xerces continue to validate without errors.


Thanks,

Rick




Rick Taylor
XML Developer
PPDM Association


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.