|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Problems with xs:redefine
Thanks to Dan for help he gave me behind the scenes. I am now running Xerces from the command line (http://xerces.apache.org/xerces2-j/samples-sax.html#Counter) as well as in Oxygen. I've also downloaded the trial version of Saxon-SA and am testing with that as well. If someone can point me to instructions on how to install and do validation with MSXML, great, but for now I think I'm OK. I realize I can't use the xs:choice elements I wanted because of the Unique Particle Attribution rule. I agree with Michael Kay that it is a "bug in the spec" but I'm going to go with what the spec says for now. So I am just going to require a Name, and let an ID remain optional. But I've run into another problem. I'm working on doing a redefine of a complexType (EventListingContactType) that includes an xs:group of elements. In the redefined complexType it seems I can't change anything about the group (e.g. changing it from minOccurs=0 to minOccurs=1) or the validators all complain (which baffles me, but that's not really what I need to do anyway). I would think, however, that you could *directly substitute the elements contained in the group, for the group element itself* (since that's what comes out in the XML instance), in the redefined element definition instead. Saxon-SA allows this, but Xerces complains that the element is then not a valid restriction of the content model of the base. Any idea what the correct interpretation of the spec is? And if that error is correct, I think I could redefine the complexType (EventListingContactType) first as a restriction to remove the group (and add a couple other constraints) and then as an extension to put the elements it contains back in, but if I'm not mistaken that would take two separate files to accomplish both types of restrictions. However, that sounds like a very round-about way to do this--anyone have any better ideas? Showing substituting the elements directly for the group in the redefine: Events_1.7.xml (original file): <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:ev="urn:cde.berkeley.edu:babl:events:1.00" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:cde.berkeley.edu:babl:events:1.00" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="EventListingContactType"> <xs:sequence> <xs:element ref="ev:EventListingContactID" minOccurs="0"/> <xs:group ref="ev:ContactInfo" minOccurs="0"/> <xs:element ref="ev:EventListingContactTypes" minOccurs="0"/> <xs:element ref="ev:EventListingContactParentID" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:group name="ContactInfo"> <xs:sequence> <xs:element ref="ev:ContactName" minOccurs="0"/> <xs:element ref="ev:ProfessionalAffiliations" minOccurs="0"/> </xs:sequence> </xs:group> </xs:schema> UCBEvents.xsd (redefining file): <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="urn:cde.berkeley.edu:babl:events:1.00" targetNamespace="urn:cde.berkeley.edu:babl:events:1.00" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:redefine schemaLocation="Events_1.7.xsd"> <xs:complexType name="EventListingContactType"> <xs:complexContent> <xs:restriction base="ev:EventListingContactType"> <xs:sequence> <xs:element ref="ev:EventListingContactID" minOccurs="0"/> <xs:element ref="ev:ContactName"/> <-- ONLY SAXON ALLOWS THIS SUBSTITUTION FOR THE XS:GROUP, I WANT TO CHANGE THIS TO BE MINOCCURS=1 <xs:element ref="ev:ProfessionalAffiliations" minOccurs="0"/> <-- ONLY SAXON ALLOWS THIS SUBSTITUTION FOR THE XS:GROUP <xs:element ref="ev:EventListingContactTypes" minOccurs="0"/> <xs:element ref="ev:EventListingContactParentID" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:redefine> </xs:schema> My other idea of how to fix this problem: PreUCBEvents.xsd (Redefine #1): <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="urn:cde.berkeley.edu:babl:events:1.00" targetNamespace="urn:cde.berkeley.edu:babl:events:1.00" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:redefine schemaLocation="Events_1.7.xsd"> <xs:complexType name="EventListingContactType"> <xs:complexContent> <xs:restriction base="ev:EventListingContactType"> <xs:sequence> <xs:element ref="ev:EventListingContactID" minOccurs="0"/> <xs:element ref="ev:EventListingContactTypes" minOccurs="0"/> <xs:element ref="ev:EventListingContactParentID" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:redefine> </xs:schema> PostUCBEvents.xsd (Redefine #2): <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="urn:cde.berkeley.edu:babl:events:1.00" targetNamespace="urn:cde.berkeley.edu:babl:events:1.00" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:redefine schemaLocation="PreUCBEvents.xsd"> <xs:complexType name="EventListingContactType"> <xs:complexContent> <xs:extension base="ev:EventListingContactType"> <xs:sequence> <xs:element ref="ev:ContactName"/> <-- NOW THIS IS REQUIRED <xs:element ref="ev:ProfessionalAffiliations" minOccurs="0"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> </xs:redefine> </xs:schema> NOTE: <xs:group name="ContactInfo"> actually contains more elements, but I removed them for readability in this example. -----Original Message----- From: Allison Bloodworth [mailto:abloodworth@b...] Sent: Monday, November 28, 2005 2:18 PM To: 'Dan Vint' Cc: xml-dev@l... Subject: RE: Problems with xs:redefine Hi Dan, Thanks much for your advice. I downloaded Xerces-j 2.7.1 but unfortunately can't find instructions on how to invoke the validator on the command line (which is I assume what you are talking about). Though I know a bit about java, I'm not a developer so I don't think I can sift through the API documentation to find the right command. Do you know what the command is, or have some other advice for me? I looked in their forums and sent a request for help to their list, but the only response I got was "try an IDE like XML Spy or Eclipse". Also, both the original and redefining schema have the same targetNamespace, so it doesn't sound like that is the problem. From UCBEvents.xsd: xmlns:ev="urn:cde.berkeley.edu:babl:events:1.00" targetNamespace="urn:cde.berkeley.edu:babl:events:1.00" from Events_1.6.xsd: targetNamespace="urn:cde.berkeley.edu:babl:events:1.00" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:ev="urn:cde.berkeley.edu:babl:events:1.00" Thanks again, Allison -----Original Message----- From: Dan Vint [mailto:dvint@d...] Sent: Wednesday, November 23, 2005 8:18 PM To: Allison Bloodworth Subject: Re: Problems with xs:redefine First I would recommend that you setup Xerces-J and use it to test your schemas. XML Spy is full of bugs and problems as you try to use different schema features. If nothing else it will give you different error messages that might make more sense than Spy;s - than again they might be more cryptic but they will be different. I also will double check my schemas with the MS com XML parser as well. Both of these seem to be better implementations and if I pass them I feel pretty confident in my schema design. below for more At 07:23 PM 11/23/2005, you wrote: >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> <drv>Usually the redefin requireise the two type nemase to be the same, so where you have xs:string, replace it with RecurrenceIDRangeType. >(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> <drv>Both of these samples look suspicious like your redefine schema may have applied a prefix to the targetNamespace and you used the default in the base schema. Anyway I've seen Spy recently with 2005 track elements by the prefix value when I did something similar. <drv>Notice that if this is the situation, that my first statement then is correct, because both references to the data type really are the same once you track down the namespace definitions. ..dan >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> --------------------------------------------------------------------------- Danny Vint Specializing in Panoramic Images of California and the West http://www.dvint.com voice: 510-522-4703 When H.H. Bennett was asked why he preferred to be out shooting landscapes rather than spending time in his portrait studio: "It is easier to pose nature and less trouble to please." http://www.portalwisconsin.org/bennett_feature.cfm ----------------------------------------------------------------- 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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








