I have an XML form with an element 0, which is well-formed but not valid. When I try to validate it XMLSpy I get a following error: Nothing is allowed inside empty element ‘hidden’. Below is my schema:
<xs:element name='hidden'> <xs:complexType> <xs:attribute name='datatype' type='xs:string' use='optional'/> <xs:attribute name='alias' type='xs:string' use='optional'/> <xs:attribute name='source' type='xs:string' use='optional'/> <xs:attribute name='name' type='xs:string' use='required'/> <xs:attribute name='lookup' type='xs:string' use='optional'/> </xs:complexType> </xs:element>
What do I need to add to the above schema to fix this error? Thanx ml
As welbog noted, you defined a complex empty element. Assuming you want only text within the hidden tag, you could write a schema along theses lines :
This way, you can have a piece of XML like this one:
What is going on here is that I defined ‘hidden’ to be an extension of
xs:integer(by the way, you can make it extends any type you want), which means that ‘hidden’ elements are like integers element, but with additional constraints, or in this case with additional attributes.