Fixed/default attributes in Xerces: Namespace prefix missing?...

V

VanOrton

Hi all,

When XercesDOMParser parses an XML document with a Schema instance, by
default it
adds all missing default and fixed attributes. I have the impression
though that it misses the
namespace prefices... I'm using Xerces 2.5.0.

Here's a document parsed by Xerces:

<?xml version="1.0" encoding="UTF-8"?>
<mads xmlns="http://www.loc.gov/mads/"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loc.gov/mads/ mads.xsd">
<authority type="simple"/>
</mads>

The "type" attribute in element "authority" was automatically added by
the parser...

But "type" is defined in xlink (namespace
"http://www.w3.org/1999/xlink"). Shouldn't
Xerces have added its prefix in front?? (xlink:type="simple") ??? I
think there is a
problem here... Anybody experienced it? Or anybody can help?

"mads" schema has: attributeFormDefault="unqualified"

You can find the above Schemas at:

http://www.loc.gov/mads/ : http://www.loc.gov/standards/mads/mads.xsd
http://www.loc.gov/mods/v3 :
http://www.loc.gov/standards/mods/v3/mods-3-0.xsd
http://www.w3.org/1999/xlink :
http://www.loc.gov/standards/mods/xlink.xsd

Thank you all in advance...

Nicolas
 
M

Martin Honnen

VanOrton wrote:

When XercesDOMParser parses an XML document with a Schema instance, by
default it
adds all missing default and fixed attributes. I have the impression
though that it misses the
namespace prefices... I'm using Xerces 2.5.0.

Is that Xerces Java or Xerces C++?
Here's a document parsed by Xerces:

<?xml version="1.0" encoding="UTF-8"?>
<mads xmlns="http://www.loc.gov/mads/"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loc.gov/mads/ mads.xsd">
<authority type="simple"/>
</mads>

The "type" attribute in element "authority" was automatically added by
the parser...

But "type" is defined in xlink (namespace
"http://www.w3.org/1999/xlink"). Shouldn't
Xerces have added its prefix in front?? (xlink:type="simple") ???

I don't quite understand what you are doing, are you loading an XML
document from a file to build a DOM (document object model), then
serialize that DOM back to a file and then the proper namespace
attribute or prefix is missing?
Then how exactly do you serialize?
 
V

VanOrton

Martin, thanks for your quick answer...

I'm using C++ (Borland C++ Builder).

Well my XML document is in the form of a text file. The file looks
exactly like the one
I posted in my previous post, except that element "authority" has no
attribute.
I load the document on a DOM using XercesDOMParser like this:

DOMXMLparser->setValidationScheme(XercesDOMParser::Val_Auto);
DOMXMLparser->setDoNamespaces(true);
DOMXMLparser->setDoSchema(true);
DOMXMLparser->parse(shortPathName);

Then I project the DOM tree on a TreeView control and I clearly see
that Parser
inserted the "type" attribute by itself.
The problem is that this node has NULL for prefix (node->getPrefix() =
NULL).
It also has: node->getNodeName() = "type" and node->getLocalName() =
"type".
It gives: node->getNamespaceURI() = xlink-namespace (the real one!...).

Shouldn't Xerces have given a name with a prefix to this attribute?
Or should I do this myself before projecting the DOM to the TreeView?
And how?... Traverse all document and checking Namespaces and
Prefices?...

Am I missing something important maybe?... Thank you very much again...


Nicolas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top