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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Problems with xs:redefine

[ Lists Home | Date Index | Thread Index ]

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@berkeley.edu]
> Sent: 24 November 2005 03:23
> To: xml-dev@lists.xml.org
> Subject: [xml-dev] 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@berkeley.edu
>
>
>
>
> -----------------------------------------------------------------
> 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>
>





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS