I'm trying to write a xsd to validate the input files for my program.
Maybe it's me, but for this case it seems odd to me, that I need to define all the elements, which might appear in the xml, as I just need a subset of the contained data and the xml might be extended in the future. Given this is my xml:
<?xml version="1.0" encoding="utf-8"?>
<Setup>
<Foo desc="i don't need you">This is some random Element</Foo>
<Bar>This is what i need to process</Bar>
<Bar>And it might appear more than once</Bar>
<Foobar>Some other random element. There might be more</Foobar>
</Setup>
Is there a xsd that is valid as long as <Setup
>-><Bar
> is present, no matter if there are random other elements present anywhere under <Setup
>?
I think the basic structure might be something like
<?xml version="1.0" encoding="utf-8"?>
<xs:schema>
<xs:element name="Setup">
<xs:complexType>
<xs:someting>
<xs:element name="bar" type="xs:string" minOccurence="1" maxOccurence="unbounded"/>
<xsd:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</xs:something>
</xs:complexType>
</xs:element>
</xs:schema>
But <any
> just seems to allow appending elements, and I haven't found a solution with <choice>
, <sequence>
or <all>
or a combination of these to work around this. Is there some trick to do it?
P.S.: XSD1.1 sadly is not an option