Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Accessing xmlns attributes via SAX in MSXML

From: JimF@-----------.---------.---
To: NULL
Date: 7/14/2008 1:07:00 PM

Accessing xmlns attributes via SAX in MSXML

Hi,

I'm having a little trouble using the MSXML implementation of SAX, 
specifically with reading xmlns attributes using ISAXAttributes::getName. The 
calling application is written in C++ with Visual Studio 2008.

MORE BACKGROUND: We're using the SAX interface to import data from an XML 
document (file) to our application's own internal memory structure. Since the 
document may be large, we chose SAX rather than the DOM to avoid having too 
much duplication of data in memory at once. In the XML, elements defined in a 
namespace separate from our own may have been inserted by a third party. The 
third-party elements and their namespace declarations must be preserved in 
memory, then written back out to the file as-is with the other data native to 
the application. As such, we need to have the namespace declarations as 
defined in element attributes loaded and preserved so that they can be 
written back to the file intact.

To load the element attributes that define namespaces (e.g. 
xmlns:myns="my_namespace_url.com") and other attributes, we're using the 
ISAXAttributes interface pointer passed to ISAXContentHandler::startElement.

Also, the "namespaces" feature is set to true, and the "namespace-prefixes" 
feature is set to true.

PROBLEM: When we call ISAXAttributes::getName, specifying the index of a 
namespace declaration attribute, the local name for the attribute returned is 
empty. Is this to be expected? This seems inconsistent and leads me to wonder 
if I'm using the API correctly.

EXAMPLE: Given the following XML start element tag: <myns:MyElement 
xmlns:myns="my_namespace_url.com" myns:title="My Title">, calling 
ISAXAttributes::getName with index zero returns the following:

	Local name: ""
	Qualified name: "xmlns:myns"
	Uri: "http://www.w3.org/2000/xmlns/"
	(getValue retrieves the value: "my_namespace_url.com")

In contrast, when I pass index one, getName returns the following:

	Local name: "title"
	Qualified name: "xmlns:title"
	Uri: "mynamespace_url.com"
	(getValue retrieves the value: "My Title")

So the local name returned for index one is what I would expect, but the 
local name returned for index zero is not.

Thanks in advance for any help.

Jim


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent