I'm trying to validate XML according to an XSD. In this XML there are tags with namespaces and without.
<my:person xmlns:my="http://my.namespace.com">
<my:name>John Doe</my:name>
<my:year>1988</my:year>
<namespaceLessElement>some value</namespaceLessElement>
</my:person>
My XSD looks like this. Validation fails because according to the XSD, namespaceLessElement
has a namespace.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:myNamespace="http://my.namespace.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://my.namespace.com"
elementFormDefault="qualified">
<xs:element name="person" type="myNamespace:person"/>
<xs:complexType name="person">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="year" type="xs:int"/>
<xs:element name="namespaceLessElement" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
I can't find any info on how to turn off the namespace for namespaceLessElement
. Is there a way to do that?