N
Nicolas
Hi everybody,
I'm stuck for a couple of days now to the following issue, concerning
fixed/default attributes and multiple namespaces. Any help would be
greatly appreciated...
I'm using Xerces C++ 2.7.0.
Here are two XML Schemas:
SCHEMA1.XSD
-----------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:sch="http://schema2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schema1"
targetNamespace="http://schema1"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://schema2" schemaLocation="schema2.xsd"/>
<xsd:element name="myelement">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="mysubelement" type="subelementType"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="subelementType">
<xsd:attribute name="type" type="xsd:integer"/>
<xsd:attributeGroup ref="sch:myattGroup"/>
</xsd:complexType>
</xsd:schema>
SCHEMA2.XSD
-----------
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schema2"
elementFormDefault="qualified">
<attributeGroup name="myattGroup">
<attribute name="type" type="string" fixed="simple"
form="qualified"/>
</attributeGroup>
</schema>
And let's consider a simple document:
<?xml version="1.0" encoding="UTF-8"?>
<myelement xmlns="http://schema1"
xmlns:sch="http://schema2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schema1 schema1.xsd">
<mysubelement type="34"/>
</myelement>
I open the document with XercesDOMPArser
DOMXMLparser->setValidationScheme(XercesDOMParser::Val_Auto);
DOMXMLparser->setDoNamespaces(true);
DOMXMLparser->setDoSchema(true);
DOMXMLparser->setValidationSchemaFullChecking(true);
DOMXMLparser->parse(filename);
and, as expected, there are two "type" attributes for element
"mysubelement".
One type="34" with NULL NamespaceURI, which corresponds to schema1,
and one type="simple" with NamespaceURI="http://schema2" which
corresponds
to schema2 (the latter's value is fixed).
Well, now I delete the type="34" attribute with:
DOMNamedNodeMap* atts = parent->getAttributes(); // --> parent =
mysubelement
atts->removeNamedItemNS(NULL, attName); // --> attName = "type"
Xerces deletes the type="34", but mysubelement still has 2 attributes
(!!!) :
Both attributes have the name "type", they both have the value "simple"
and the one
has NULL NamespaceURI and the other has "http://schema2" NamespaceURI.
It's like Xerces added an attribute by itself with :
name = "type"
value = "simple"
namespace = NULL Namespace.
Am I missing something? Is this a known issue?...
Thanks in advance...
Nicolas
I'm stuck for a couple of days now to the following issue, concerning
fixed/default attributes and multiple namespaces. Any help would be
greatly appreciated...
I'm using Xerces C++ 2.7.0.
Here are two XML Schemas:
SCHEMA1.XSD
-----------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:sch="http://schema2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schema1"
targetNamespace="http://schema1"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://schema2" schemaLocation="schema2.xsd"/>
<xsd:element name="myelement">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="mysubelement" type="subelementType"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="subelementType">
<xsd:attribute name="type" type="xsd:integer"/>
<xsd:attributeGroup ref="sch:myattGroup"/>
</xsd:complexType>
</xsd:schema>
SCHEMA2.XSD
-----------
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schema2"
elementFormDefault="qualified">
<attributeGroup name="myattGroup">
<attribute name="type" type="string" fixed="simple"
form="qualified"/>
</attributeGroup>
</schema>
And let's consider a simple document:
<?xml version="1.0" encoding="UTF-8"?>
<myelement xmlns="http://schema1"
xmlns:sch="http://schema2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schema1 schema1.xsd">
<mysubelement type="34"/>
</myelement>
I open the document with XercesDOMPArser
DOMXMLparser->setValidationScheme(XercesDOMParser::Val_Auto);
DOMXMLparser->setDoNamespaces(true);
DOMXMLparser->setDoSchema(true);
DOMXMLparser->setValidationSchemaFullChecking(true);
DOMXMLparser->parse(filename);
and, as expected, there are two "type" attributes for element
"mysubelement".
One type="34" with NULL NamespaceURI, which corresponds to schema1,
and one type="simple" with NamespaceURI="http://schema2" which
corresponds
to schema2 (the latter's value is fixed).
Well, now I delete the type="34" attribute with:
DOMNamedNodeMap* atts = parent->getAttributes(); // --> parent =
mysubelement
atts->removeNamedItemNS(NULL, attName); // --> attName = "type"
Xerces deletes the type="34", but mysubelement still has 2 attributes
(!!!) :
Both attributes have the name "type", they both have the value "simple"
and the one
has NULL NamespaceURI and the other has "http://schema2" NamespaceURI.
It's like Xerces added an attribute by itself with :
name = "type"
value = "simple"
namespace = NULL Namespace.
Am I missing something? Is this a known issue?...
Thanks in advance...
Nicolas