On 19 Nov, 14:41, "Christian Rühl" <ch...@cruehl.comwrote:
On 19 Nov., 14:57, Pavel Lepin <p.le...@ctncorp.comwrote:
Christian Rühl <ch...@cruehl.comwrote in
<72cc99e1-7a7b-4ac3-a346-7f850aa64...@p69g2000hsa.googlegroups.com>:
the xml files i want to validate look like this:
-- component
--- sub-component
--- sub-component
---- sub-component
-- component
--- sub-component
---- sub-component
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sub">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="sub"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Another option might be:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sub">
<xs:complexType>
<xs:sequence>
<!-- You might want some extra stuff here. -->
<xs:element ref="sub" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Or (tweak of Pavel's):
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sub">
<xs:complexType>
<xs:choice>
<xs:element ref="subdetails" type="subdetails"/>
<xs:element ref="sub" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
The difference between the two depends on whether a sub-component with
sub-components _only_ have sub-components, or has other data plus sub-
components. (Wow - that's a lot of sub-components!)
HTH,
Pete Cordell
Codalogic
Visit
http://www.codalogic.com/lmx/
for XML Schema to C++ data binding