473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Fixed attribute and multiple namespaces issue (Xerces-C 2.7.0)

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

Feb 22 '06 #1
3 1926
When default attribute values are defined in the DTD, the DOM is
expected to reinstantiate them with the default value when an explicit
setting is removed. As of DOM Level 3, a DOM may (but is not required
to) do the same for schema-defined default attributes.

http://www.w3.org/TR/2004/REC-DOM-Le...ml#ID-6D6AC0F9

Basically, if there is a default defined in the DTD or Schema, it
really is a default and you can't remove the attribute entirely. All you
can do is override it to a different value.

If that isn't what you wanted, you shouln't have defined it as a default.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 22 '06 #2
Joe thanks indeed for your answer...

I know that DOM has to (or may) re-instantiate a fixed/default
attribute if the latter
is deleted.

This is not the problem, though.

As I described in my initial post, the problem
is that Xerces instantiates an attribute with its fixed value EVEN
THOUGH
such an attribute already exists (was never deleted!!!). As a
consequence,
DOM ends up with two attributes of the same name, the same value
(the fixed one) and different namespaces (one has NULL, the other has
the
correct one). Note that this attribute is defined as "form="qualified""
in
the Schema.

Thanks again.

Nicolas

Feb 22 '06 #3
Nicolas wrote:
DOM ends up with two attributes of the same name, the same value
(the fixed one) and different namespaces (one has NULL, the other has
the
correct one).


Sorry; misread the problem description.

If your description is accurate, that sounds like a bug in their
implementation of this feature. Report a bug against Xerces-C.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Feb 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Peter Kropf | last post by:
I'm looking for a way to create multiple namespaces / dictionaries from within a Python C extension. I'd like to replicate something like: a\__init__.py a\b\__init__.py a\b\c\__init__.py ...
5
by: Russell O'Connor | last post by:
The following XML and Schema doesn't validate in Visual Studio .NET 2003. Is there some mistake I'm making, or is VS.NET in error. The error is r:\test2.xml(3): The key sequence 'foo' in Keyref...
3
by: John Smith | last post by:
Ok, I am not sure if it is possible. But what I'm trying to do is validate an XML file with out having to add namespace in the xml. What I mean is lets say I have 2 XSD they have different...
4
by: bob | last post by:
how do you import multiple namespaces from the same header?
3
by: daz_oldham | last post by:
Hi Everyone I was wondering if anyone knew of a good guide to working with multiple namespaces under .NET? And also help me with my latest poser. As you may have calculated by my other posts,...
0
by: Dave | last post by:
Hello all, Firstly I hate Citrix, especially their programming interface MFCOM. There are multiple versions, that seem to need to match an SDK Version <----Citrix Server Version This is bad...
0
by: =?Utf-8?B?Q2FtZWw=?= | last post by:
For anyone who has utilised classes under XSD.exe and CodeDOM (please redirect me to another group perhaps if not here) please any ideas on how to translate the multiple namespaces present within...
1
camel
by: camel | last post by:
For anyone who has utilised classes under XSD.exe and CodeDOM, please any ideas on how to translate the multiple namespaces present within multiple XmlSchema , i.e., via xs:import, to multiple output...
4
by: Stefan Hoffmann | last post by:
hi @all, I'm trying to validate a XML against a schema using the example from the MSDN: http://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.validationtype.aspx In my case...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.