By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Nov 30 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


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?


--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 30 '05 #2

P: n/a
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

Nov 30 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.