my environment:
C++, Xerces C++ 3.1.1 using xercesc::DOMLSParser for Xml validation with
cached grammar - works fine like it should BUT...
my scenario:
i've got an "old" applikation database containing many different xml
files (without schemas) and i want to use the data validated in my
applikation, but sometimes the namespace is miss-used (empty,
non-existent) so xerces can't validate the xml correctly
is there any way to teach xerces to ignore these empty or non-existen
namespaces in the xml-files like some sort of - if there is nothing or
some empty namespace use this one instead?
(schema/xml cn be online tested with
http://www.freeformatter.com/xml-validator-xsd.html)
my current schema
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://foo.xsd" xmlns:tns="http://foo.xsd" >
<xs:simpleType name="hex-integer">
<xs:restriction base="xs:string">
<xs:pattern value="0x[0-9a-fA-F]+"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="TheElements">
<xs:complexType>
<xs:sequence>
<xs:element name="MyElement">
<xs:complexType>
<xs:attribute type="tns:hex-integer"
name="TheValue" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
sample #1 - is valid
<?xml version="1.0" encoding="utf-8"?>
<TheElements xmlns="http://foo.xsd">
<MyElement TheValue="0x20" />
</TheElements>
sample #2 - is invalid due to namespace miss-use
<?xml version="1.0" encoding="utf-8"?>
<TheElements xmlns="">
<MyElement TheValue="0x20" />
</TheElements>
sample #3 - is invalid due to namespace miss-use
<?xml version="1.0" encoding="utf-8"?>
<TheElements xmlns="http://foo.xsd">
<MyElement xmlns="" TheValue="0x20" />
</TheElements>