[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Schema Extension and validation of an instance
Hi, I have found my problem, but haven't come up with a solution!! I didn't post the full example in previous posts, therefore it was hard to see what was wrong(sorry about that). My problem is with multiple instances of the one namespace specified in the schemaLocation attribute!! My instance document ******** <ipdr:IPDRDoc xmlns="http://www.mySchema.com/ccf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ipdr="http://www.ipdr.org/namespaces/IPDR" xsi:schemaLocation="http://www.mySchema.com/ccf ccf.xsd http://www.ipdr.org/namespaces/IPDR http://www.ipdr.org/public/IPDRDoc3.5.xsd http://www.ipdr.org/namespaces/IPDR newComplexType.xsd"> <iprd:IPDR xsi:type="ipdr:IPDRTypeExtended"> ............... </ipdr:IPDR> </ipdr:IPDRDoc> ******** I needed to wrap the IPDR element in the IPDRDoc element(defined in IPDRDoc3.5xsd). Looks like; once the processor gets a schema that satisfies a namespace, it doesn't try to load a second schema of the same namespace!! When I switched the order(of the IPDR namespace) in the schemaLocation, I got different errors. OK, but where does one go from here? In general how is this problem solved? Best Regards, Chris. On 7/25/06, Michael Kay <mike@s...> wrote: > I can't immediately see anything wrong with it. What do other validators > say? > > Michael Kay > http://www.saxonica.com/ > > > -----Original Message----- > > From: Christopher Foley [mailto:ccfoley@g...] > > Sent: 25 July 2006 11:19 > > To: xml-dev@l...; Michael Kay > > Subject: Re: Schema Extension and validation of an instance > > > > Hi, > > > > Thanks to all for the info. The redefinition of the IPDR > > element works fine. > > > > But I am getting some difficulty when using the xsi:type alternative; > > > > My new complex type is as follows(newComplexType.xsd); > > ************* > > <?xml version = "1.0" encoding = "UTF-8"?> <schema > > xmlns="http://www.w3.org/2001/XMLSchema" > > targetNamespace="http://www.ipdr.org/namespaces/IPDR" > > xmlns:ccf="http://www.mySchema.com/ccf" > > xmlns:ipdr="http://www.ipdr.org/namespaces/IPDR"> > > > > <import namespace="http://www.mySchema.com/ccf" > > schemaLocation="ccf.xsd"/> > > > > <complexType name="IPDRTypeExtended"> > > <complexContent> > > <extension base="ipdr:IPDRType"> > > <sequence> > > <element name="ccf:transactionID" type="string" minOccurs="0"/> > > <element name="ccf:serviceID" type="string" minOccurs="0" /> > > <element name="ccf:serviceName" type="string" minOccurs="0" /> > > <element name="ccf:customerID" type="string" minOccurs="0" /> > > <element name="ccf:sessionID" type="string" minOccurs="0" /> > > <element name="ccf:timeZoneOffset" type="string" > > minOccurs="0" /> </sequence> </extension> </complexContent> > > </complexType> > > > > I don't redefine the IPDR element, I just use the xsi:type > > method in the instance document as follows; > > ***************************** > > <?xml version="1.0"?> > > <ipdr:IPDR xmlns="http://www.mySchema.com/ccf" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xmlns:ipdr="http://www.ipdr.org/namespaces/IPDR" > > xsi:schemaLocation="http://www.mySchema.com/ccf > > ccf.xsd http://www.ipdr.org/namespaces/IPDR newComplexType.xsd" > > xsi:type="ipdr:IPDRTypeExtended"> > > > > > > <ipdr:IPDRCreationTime>2001-05-31T13:20:00.561Z</ipdr:IPDRCrea > > tionTime> > > <ipdr:seqNum>1</ipdr:seqNum> > > <transactionID>1</transactionID> > > <serviceID>1</serviceID> > > <serviceName>New</serviceName> > > <customerID>Chris</customerID> > > <sessionID>1</sessionID> > > <timeZoneOffset>12</timeZoneOffset> > > </ipdr:IPDR> > > > > On validating this instance, it tells me that > > > > 'Type {http://www.ipdr.org/namespaces/IPDR}IPDRTypeExtended > > is not found in schema.' > > > > This is coming from -> xsi:type="ipdr:IPDRTypeExtended" > > > > But it is defined in the schema(newComplexType.xsd). And it > > is also part of the http://www.ipdr.org/namespaces/IPDR > > namespace. I have looked at the specs for sample uses of > > xsi:type and what I'm doing looks correct, I think!!! > > > > I am somewhat confused as to why it is not validating(using > > Xselerator to do the validation). > > > > Any pointers?? > > > > Best Regards, > > Chris. > > On 7/18/06, Michael Kay <mike@s...> wrote: > > > > Do I need to redefine the IPDR element itself to be of type > > > > 'IPDRTypeExtended'?? > > > > > > Yes. You've defined an extended type, but the element declaration > > > still refers to the original type. You can create an instance that > > > conforms to the extended type by giving it an xsi:type attribute. > > > > > > Michael Kay > > > http://www.saxonica.com/ > > > > > > > >
|
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
|