When people use the term "recursion" with regard to xml schemas, what they usually mean is elements that (either directly or indirectly) can contain themselves--more properly, cyclicity in the digraph defined by the schema.
How about this: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault=" qualified" attributeFormDefault="unqualified"> <xs:element name="root"> <xs:annotation> <xs:documentation>Comment describing your root element</ xs:documentation> </xs:annotation> <xs:complexType> <xs:choice> <xs:element ref="A"/> <xs:sequence> <xs:sequence maxOccurs="unbounded"> <xs:element ref="A"/> <xs:element ref="B"/> </xs:sequence> <xs:element ref="A" minOccurs="0"/> </xs:sequence> </xs:choice> </xs:complexType> </xs:element> <xs:element name="A"/> <xs:element name="B"/> </xs:schema> -- Eric Schwarzenbach John Utz <[EMAIL PROTECTED] To: [EMAIL PROTECTED] .com> cc: Subject: how does one describe alternating elements in XMLSchema? 02/14/2002 06:53 PM Please respond to xerces-j-user this is a little offtopic, or maybe not. so if i wanted to validate an alternating sequence of elements of unbounded length, how would i describe it? so, A,AB,ABA,ABAB,... etc are legal but B,BA, AA, BB, ABB, etc are not. this was the first implementation, but it violates UPA as far as xerces-j 2.0.0 is concerned: <sequence> <element name="A" type="string"/> <sequence minOccurs="0" maxOccurs="unbounded"> <element name="B" type="string"/> <element name="A" type="string"/> </sequence> <element name="B" type="string" minOccurs="0"/> </sequence> among other things. i was thinking that this was a recursion problem and this was what i came up with after google-mining for recursion and XMLSchema: http://castor.exolab.org/list-archive/msg08774.html this was my distilled contribution, but it's not correct because it would permit AA: <element name="AB-list-ref"> <complexType> <sequence> <element ref="AB-list"/> <sequence> <complexType> <element> <element name="AB-list"> <complexType> <sequence> <element name="A" type="string"/> <choice> <element name="B" type="string"/> <element ref="AB-list-ref" minOccurs="0"/> <choice> <sequence> <complexType> <element> so, mine is wrong. and i have been beating the heck out of this and not getting anywhere. if somebody knows of a canonical example of such a thing, i'd really like to see it. if anybody has implemented something that sorta works, i'd love to see that too! one thing that has occurred to me as a sortof nifty tool: a way to express regexps as XMLSchema: ie, enter a regexp and get back a correct XMLSchema for same. anybody ever seen such a beasty? tnx for any help that anyone can provide! johnu --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
