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

RE: Problems with xs:redefine


xs redefine
You are correct in saying that XML Spy 2004 does not detect this error, but
2005 does. This (and inadequate testing) has led to at least one set of
invalid schemas being published as a "standard".

When you use redefine, the new definitions must be legitimately derived from
the types you are redefining. Your simple type is derived from an xs:string.
You just need to change this to derive it from the original type.

 	<xs:redefine schemaLocation="Events_1.6.xsd">
 		<xs:simpleType name="RecurrenceIDRangeType">
 			<xs:restriction base="RecurrenceIDRangeType">
 				<xs:enumeration value="ThisAndFuture"/>
 				<xs:enumeration value="ThisAndPrior"/>
 			</xs:restriction>
 		</xs:simpleType>

Your complex type is not a valid restriction, and I don't think you can
create one to do what you want.

I thoroughly recommend Eric van der Vlist's O'Reilly book "XML Schema". It
explains this and a lot more. One of only two books on XML from my rather
large library that I ever actually use.

Paul Spencer

> -----Original Message-----
> From: Allison Bloodworth [mailto:abloodworth@b...]
> Sent: 24 November 2005 03:23
> To: xml-dev@l...
> Subject:  Problems with xs:redefine
>
>
> Hi,
>
> I am having problems with xs:redefine. Schemas that were validated in XML
> Spy 2004 are coming up as invalid in XML Spy 2005. I don't know if perhaps
> XML Spy 2004 wasn't looking back to the original schema to make sure that
> the redefines were valid restrictions of the elements in the original
> schema? However, when I used the "Generate Sample XML file" from schema
> function in 2004, it was coming up with valid instances that matched the
> constraints in my redefining schema it seemed that the schemas must be
> OK...until I ran into errors using 2005.
>
> In the redefining schema I'm trying to a) create enumerated lists for the
> elements that were simpleTypes in the original schema and b) restrict
> certain complexTypes so that some of their sub-elements that were optional
> in the original schema are required.
>
> For instance, in the original schema I have the following types (important
> points indicated by "<-<-"):
>
> 	<xs:simpleType name="RecurrenceIDRangeType">
> 		<xs:restriction base="xs:string"/> <-<-
> 	</xs:simpleType>
>
> 	<xs:complexType name="SponsorType">
> 		<xs:sequence> <-<-
> 			<xs:element ref="ev:SponsorID" minOccurs="0"/>
> 			<xs:element ref="ev:Name" minOccurs="0"/>
> 			....
> 		</xs:sequence>
> 	</xs:complexType>
>
> Which I was able to successfully redefine in XML Spy 2004 like this:
> 	<xs:redefine schemaLocation="Events_1.6.xsd">
> 		<xs:simpleType name="RecurrenceIDRangeType">
> 			<xs:restriction base="xs:string"> <-<-
> 				<xs:enumeration value="ThisAndFuture"/>
> 				<xs:enumeration value="ThisAndPrior"/>
> 			</xs:restriction>
> 		</xs:simpleType>
>
> (RecurrenceIDRangeType even looks like it's correct from this article, but
> is invalid in XML Spy 2005:
> http://www.xml.com/pub/a/2000/11/29/schemas/part1.html?page=7)
>
> 		<xs:complexType name="SponsorType">
> 			<xs:complexContent>
> 				<xs:restriction base="ev:SponsorType">
> 					<xs:sequence>
> 						<xs:choice maxOccurs="2">
> (e.g. must have one or the other or both) <-<-
> 							<xs:element
> ref="ev:SponsorID"/>
> 							<xs:element
> ref="ev:Name"/>
> 						</xs:choice>
> 						...
> 					</xs:sequence>
> 				</xs:restriction>
> 			</xs:complexContent>
> 		</xs:complexType>
>
> However, XML Spy 2005 is requiring this:
>
> 		<xs:simpleType name="RecurrenceIDRangeType">
> 			<xs:restriction base="ev:RecurrenceIDRangeType">
> <-<-
> 				<xs:enumeration value="ThisAndFuture"/>
> 				<xs:enumeration value="ThisAndPrior"/>
> 			</xs:restriction>
> 		</xs:simpleType>
>
> This does seem to result in correct instance documents, but I'm not sure
> what the right way to do this should be. And I can't even figure
> out how to
> fix ev:SponsorType there--using the choice seems to render the schema
> completely invalid. Any ideas? I haven't been able to find many
> examples of
> using xs:redefine on restrictions on-line and didn't find much
> help in this
> document: http://www.w3.org/TR/xmlschema-1/. My latest efforts to
> make this
> work can be found at:
>
> http://eberkeley-dev.vcbf.berkeley.edu/UCBCN/UCBEvents.xsd (redefining
> schema)
> http://eberkeley-dev.vcbf.berkeley.edu/UCBCN/Events_1.6.xsd (original
> schema)
>
> Thanks very much for any help anyone can give,
>
> Allison Bloodworth
> Principal Administrative Analyst
> e-Berkeley Program Office
> University of California, Berkeley
> (415) 377-8243
> abloodworth@b...
>
>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
>


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.