Re: Validation issues
Michael Pigott <[email protected]> Sun, 20 Jul 2014 21:01:15 -0400
| Newsgroups | gmane.text.xml.xmlbeans.user |
|---|---|
| Message-ID | <CAKNYV3=MnpYWKX=AzU_cAyCz3wkbYprugb4HvF8pV3yi9=Wm7A@mail.gmail.com> |
--047d7b86e8bad32cef04fea9a4f8 Content-Type: text/plain; charset=UTF-8 Hi, Perhaps you are using the wrong prefix for the "type" element? In my (valid) XML Schema, I do not define a prefix for the type attribute, and instead have the default namespace as http://www.w3.org/2001/XMLSchema. Perhaps that's the difference? Eclipse also seems to come bundled with an XML Schema validator. That gave me a lot of (painfully cryptic, but correct) error messages when I tried to define my own schema. Good luck! Mike On Wed, Jul 16, 2014 at 1:15 PM, jgagnon <[email protected]> wrote: > I have written an application that generates XML files that represent test > cases for a collection of types defined by an XML schema. Some of these > types contain elements that are abstract. The logic locates all concrete > implementers of the abstract type and when an instance is generated, > processes one of the concrete types in place of the abstract type. > > It's my understanding that the element must have a type reference attribute > that indicates the concrete type name. So, as an example: > > ... > <SomeElement xsi:type="ConcreteType"> > ... content ... > </SomeElement> > ... > > The schema defines the SomeElement field as being defined by an abstract > type. ConcreteType is one of many possible concrete implementers of that > abstract type. > > To take this a little further, a namespace entry is made in the document > that defines a prefix for the schema types. So, in the root element there > would be entry like: > > <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:myPrefix="http://my-schema-site"/> > > The prefix is applied to all elements that are defined by the schema. E.g. > <myPrefix:SomeElement>. I would also assume that the prefix needs to be > used in the concrete type reference. So, what I have above now becomes: > > ... > <SomeElement xsi:type="myPrefix:ConcreteType"> > ... content ... > </SomeElement> > ... > > My application does all of this. > > I have also added the option to validate the instance once it's been > generated. *Here is where the problem enters the story.* For some reason, > it fails validation with the complaint: > > error: cvc-elt.4.2: Invalid xsi:type qname: 'myPrefix:ConcreteType' in > element SomeElement@my-schema-site > > Oddly, if I validate the instance externally using XMLBeans validate > utility > (.../xmlbeans-2.6.0/bin/validate), there is no complaint. > > Am I doing something wrong? > > > > > -- > View this message in context: > http://xmlbeans.996285.n3.nabble.com/Validation-issues-tp7520.html > Sent from the XMLBeans User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --047d7b86e8bad32cef04fea9a4f8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi,<div>=C2=A0 =C2=A0Perhaps you are using the wrong prefi= x for the "type" element? =C2=A0In my (valid) XML Schema, I do no= t define a prefix for the type attribute, and instead have the default name= space as=C2=A0<a href=3D"http://www.w3.org/2001/XMLSchema">http://www.w3.or= g/2001/XMLSchema</a>. =C2=A0Perhaps that's the difference?</div> <div>=C2=A0 =C2=A0Eclipse also seems to come bundled with an XML Schema val= idator. =C2=A0That gave me a lot of (painfully cryptic, but correct) error = messages when I tried to define my own schema.</div><div><br></div><div>Goo= d luck!</div> <div>Mike</div></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail= _quote">On Wed, Jul 16, 2014 at 1:15 PM, jgagnon <span dir=3D"ltr"><<a h= ref=3D"mailto:[email protected]" target=3D"_blank">Joseph.Gagnon@ll.= mit.edu</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex">I have written an application that generates= XML files that represent test<br> cases for a collection of types defined by an XML schema. =C2=A0Some of the= se<br> types contain elements that are abstract. =C2=A0The logic locates all concr= ete<br> implementers of the abstract type and when an instance is generated,<br> processes one of the concrete types in place of the abstract type.<br> <br> It's my understanding that the element must have a type reference attri= bute<br> that indicates the concrete type name. =C2=A0So, as an example:<br> <br> ...<br> =C2=A0 <SomeElement xsi:type=3D"ConcreteType"><br> =C2=A0 =C2=A0 ... content ...<br> =C2=A0 </SomeElement><br> ...<br> <br> The schema defines the SomeElement field as being defined by an abstract<br= > type. =C2=A0ConcreteType is one of many possible concrete implementers of t= hat<br> abstract type.<br> <br> To take this a little further, a namespace entry is made in the document<br= > that defines a prefix for the schema types. =C2=A0So, in the root element t= here<br> would be entry like:<br> <br> <Root xmlns:xsi=3D"<a href=3D"http://www.w3.org/2001/XMLSchema-inst= ance" target=3D"_blank">http://www.w3.org/2001/XMLSchema-instance</a>"= <br> xmlns:myPrefix=3D"<a href=3D"http://my-schema-site" target=3D"_blank">= http://my-schema-site</a>"/><br> <br> The prefix is applied to all elements that are defined by the schema. =C2= =A0E.g.<br> <myPrefix:SomeElement>. =C2=A0I would also assume that the prefix nee= ds to be<br> used in the concrete type reference. So, what I have above now becomes:<br> <br> ...<br> =C2=A0 <SomeElement xsi:type=3D"myPrefix:ConcreteType"><br> =C2=A0 =C2=A0 ... content ...<br> =C2=A0 </SomeElement><br> ...<br> <br> My application does all of this.<br> <br> I have also added the option to validate the instance once it's been<br= > generated. =C2=A0*Here is where the problem enters the story.* =C2=A0For so= me reason,<br> it fails validation with the complaint:<br> <br> error: cvc-elt.4.2: Invalid xsi:type qname: 'myPrefix:ConcreteType'= in<br> element SomeElement@my-schema-site<br> <br> Oddly, if I validate the instance externally using XMLBeans validate utilit= y<br> (.../xmlbeans-2.6.0/bin/validate), there is no complaint.<br> <br> Am I doing something wrong?<br> <br> <br> <br> <br> --<br> View this message in context: <a href=3D"http://xmlbeans.996285.n3.nabble.c= om/Validation-issues-tp7520.html" target=3D"_blank">http://xmlbeans.996285.= n3.nabble.com/Validation-issues-tp7520.html</a><br> Sent from the XMLBeans User mailing list archive at Nabble.com.<br> <br> ---------------------------------------------------------------------<br> To unsubscribe, e-mail: <a href=3D"mailto:[email protected].= org">[email protected]</a><br> For additional commands, e-mail: <a href=3D"mailto:[email protected]= e.org">[email protected]</a><br> <br> </blockquote></div><br></div> --047d7b86e8bad32cef04fea9a4f8--