You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by "Gagnon, Joseph - 0553 - MITLL" <Jo...@ll.mit.edu> on 2015/05/05 14:16:24 UTC

Questions regarding parsing a DOM with Xerces

I have a situation where I will receive a DOM document
(xercesc::DOMDocument), which I then need to traverse and parse to take
further actions with.  I start out by getting the document element, and
begin traversing the document nodes.  I check the node type to determine
what I'm dealing with and take appropriate action from there.  How do I
discriminate between an attribute (DOMNode::ATTRIBUTE_NODE) that is just a
plain attribute vs. an attribute representing a namespace declaration or
other schema-related information?  For example:

 

<myNS:MissionPlan xmlns:myNS="http://some.site.org/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:altNS="urn:alt:ns" altNS:classification="U" altNS:ownerProducer="USA"
xsi:schemaLocation="http://some.site.org  schema.xsd">

 

So in this case, altNS:classification="U" and altNS:ownerProducer="USA" are
"regular" attributes of the myNS:MissionPlan element, but
xmlns:myNS="http://some.site.org/",
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance",
xmlns:altNS="urn:alt:ns" and xsi:schemaLocation="http://some.site.org
schema.xsd" define the namespaces and their prefixes as well as the schema
location information.

 

I need to be able to recognize that "classification" and "ownerProducer" are
attributes of the element and take appropriate action for attributes, while
the other "attributes" that pertain to schema and namespace information can
be processed separately.  It does not appear that there is any distinction
between "regular" attributes and schema-specific attributes.  Do I need to
parse each attribute to look for strings such as "xmlns" and
"schemaLocation"?  Is there a better way to do this?

 

Thanks,

Joe Gagnon

 

Engineer II

Group 58 - Cyber Systems & Technology

MIT Lincoln Laboratory

Lexington, MA