| Author |
Schema Confusion?
|
Vivek Saxena
Ranch Hand
Joined: Apr 24, 2002
Posts: 58
|
|
Hi, I have been trying to validate following XML file with the following XML Schema file using �xerces-2_2_0� API. I am getting following error message. � C:\xml\xml-schemas\examples\example01>validate -x fifth.xml [Error] test.xsd:6:28: cos-all-limited.1.2: An ''all'' model group must appear i n a particle with '{'min occurs'}'='{'max occurs'}'=1, and that particle must be part of a pair which constitutes the '{'content type'}' of a complex type defin ition. [Error] fifth.xml:3:9: cvc-complex-type.2.4.a: Invalid content starting with ele ment 'title'. The content must match '(("test.com":abc))'. fifth.xml: 391 ms (3 elems, 1 attrs, 0 spaces, 15 chars) Done. � XML File XML Schema File Then I did a change in schema file. I Changed the �<xs:all>� with �<xs:sequence>� in group declaration as follows Now if I validate my same xml file against changed Schema file, it is validated with no error messages. I am confused here. [B] Does that mean that I can not use �all� while I am declaring a group definition? Because I also tried �<s:choice>� and it is working fine. I was looking into specification and I found following: [/B] Please help me with my confusion. thanks [ February 06, 2003: Message edited by: Vivek Saxena ]
|
 |
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
Your orginal XML file is valid (wrt your orginal Schema) according to XML Spy, v5. Not sure what was wrong... - madhav
|
Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
|
 |
Vivek Saxena
Ranch Hand
Joined: Apr 24, 2002
Posts: 58
|
|
Madhav, I really don�t use/trust XMLSpy to validate my XML file against DTD or Schema. I have found so many bugs in XMLSpy related to DTD and Schema that I hate to use it. If you are preparing for certification then XMLSpy is really not good. This is my opinion! Yes you are correct! If I try to validate in XMLSpy it is a valid file. I Don�t know why am I getting this error message in �xerces-2_2_0�? Any help from our other friends would be appreciated! Note: If you want you can move both of my posts in �XML Certification� forum. From now on I would do my posting over there. Thanks
|
 |
Kenneth Tsuei
Greenhorn
Joined: Jan 26, 2003
Posts: 9
|
|
This is becoz when u declare an "all" as the model group, then it has to be the one and only one group declaration. In simple words, "all" cannot be nested in a "sequence" or "choice". Pls refer to XML Schema Spec Part 1: Structures 3.9.6 Constraints on Particle Schema Components The table under Schema Component Constraint: Particle Valid (Restriction) Cheers
|
-----------------------------------<br />-- Learning is a never-ending story: the more u learn, the less u found u've known
|
 |
Vivek Saxena
Ranch Hand
Joined: Apr 24, 2002
Posts: 58
|
|
Thanks Kenneth, I really appreciate your help. Thanks
|
 |
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
This is becoz when u declare an "all" as the model group, then it has to be the one and only one group declaration. In simple words, "all" cannot be nested in a "sequence" or "choice". That said, in the original schema, we never nested all, sequence, choice. The original schema is given below, Vivek ? Am I totally missing something here........... - m [ February 07, 2003: Message edited by: Madhav Lakkapragada ]
|
 |
Vivek Saxena
Ranch Hand
Joined: Apr 24, 2002
Posts: 58
|
|
Madhav, The group declaration "<xs:group ref="cmplx"/>"itself is within a "<xs:sequence>" statement. This is the problem here. Please feel free to coreect me. Thanks
|
 |
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
Wow!.... There is always so much more to it than it appears to be. I don't know when I will read all of this for the exam. - m
|
 |
Vivek Saxena
Ranch Hand
Joined: Apr 24, 2002
Posts: 58
|
|
Madhav, I did some changes to my XML files and Schema file as follows. New XML File New Schema File Now we can clearly see that where the problem was. Now �xs:group ref="cmplx"/>� declaration is not within �<xs:sequence>�. This way �<xs:all>� is not nested. I tried to validate with my �xerces-2_2_0� API (which I trust more) and t is fine. XMLSpy validate this version also as usual. I hope it is helpful. Thanks
|
 |
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
Thanks, Vivek. Learned something new today. - madhav
|
 |
 |
|
|
subject: Schema Confusion?
|
|
|