Reputation: 263
I have a Xml-Schema file to validate xml-Files.
Xml-Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Person">
<xs:complexType>
<xs:sequence>
<xs:element name="Firstname"/>
<xs:element name="Surename"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I want to be able to succesfully validate xml-Files, that have additional elements like this:
<?xml version="1.0" encoding="UTF-8"?>
<Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Test.xsd">
<Firstname>Jane</Firstname>
<Surename>Doe</Surename>
<City>Berlin</City>
</Person>
In this example I added the Element 'City'.
The Validation fails, because it didn´t expect more Elements.
What I have to add in my Schema, that it accepts additional Elements?
I want to do that, because sometimes new Elements added in the xml-Files. But I don´t want to define them in the schema, because I don´t want to distribute a newer schema even though only one Element is added.
What I search for, is something like a 'Placeholder' for an infinite number of additional elements.
Upvotes: 1
Views: 1250
Reputation: 2998
add xs:any
in your sequence, possibly with a unbounded maxOccurs. For more information : http://www.w3.org/TR/xmlschema-1/#element-any .
Upvotes: 2