The <any>
element in an XML Schema definition allows a schema to be extended by another schema.
I tried to follow the example given at https://www.w3schools.com/xml/schema_complex_any.asp.
However, as long as the children
element is not namespace qualified IntelliJ will give me the validation error message "The matching wildcard is strict, but no declaration can be found for element 'children'". I can remove this error by adding 'xmlns="https://www.w3schools.com"' to the children element. While this makes a lot of sense I would really like the possibility of "drop-in" extensions without the need to specify the namespace. Is there some hidden feature I am missing? Or is the example flawed and you always need to specify the namespace explicitly?
I am using IntelliJ to edit and validate the XML Schema and XML file with XML Schema 1.1 activated.
I complemented the family.xsd
fragment from the example as follows:
<?xml version="1.0" encoding="UTF-8" ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.microsoft.com" targetNamespace="http://www.microsoft.com" elementFormDefault="qualified"><xs:element name="persons"><xs:complexType><xs:sequence><xs:element name="person" maxOccurs="unbounded"><xs:complexType><xs:sequence><xs:element name="firstname" type="xs:string"/><xs:element name="lastname" type="xs:string"/><xs:any minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element></xs:schema>
The question is: Is the W3Schools example flawed or should it work without specifying the namespace for the 'children' element?
Thank you for hints and ideas!