You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "McFall, Kevin" <ke...@sungard.com> on 2002/06/21 19:14:04 UTC

Question about DOM_Element and DOM_Node...

I'm using DOM to build XML Documents and wrapping the classes up so they can
be used through a C API.  I keep a static DOM_ELEMENT for both the
currentElement and the parentElement and add children or siblings to the
current element through the API.  However, I just realized that I need to be
able to go back up a level.  So, I tried to use the
DOM_Node::getParentNode() method which returns a DOM_Node, but I need a
DOM_Element.  

My question is how do I go from a DOM_Node to a DOM_Element?

I want to be able to go up so I can add attributes/other children to that
parent, which I can't do through a DOM_Node, only a DOM_Element.

Thanks,

Kevin




Re: Couple of simple questions

Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,

On Mon, 24 Jun 2002, Graham Mann wrote:

> I suspect these have been asked before but I cant find a FAQ or old mail to help (I also suspect I know the answers but...)
> 
> After a document has been parsed against an XML Schema into a DOM, is there a way to link DOM_Nodes back to schema data types.
> In the first instance even the name of the xsd datatype would help (And then (fancifully!) to further inspect those data types for inheritance etc).

As far as I can see the answer is no. Take a look at SEnumVal, it shows  
you how to get access to the schema grammar after a parse. However 
this does not associate the DOM_Nodes with the grammar. You could override 
the parser and store the information in the UserData section of the 
DOM_Node. Otherwise you will have to wait for PSVI (on the todo list), 
although even then I don't know how that will be accessed through the DOM 
(anyone any ideas on this as I really would like to know, I cant fully 
implement XPath2 without the schema info). 

Its also possible that the Abstract Schemas object model from level 3 will 
help. I don't know enough about it to say. Perhaps someone else can help 
here. However thats not yet made it onto the todo list.

Gareth

-- 
Gareth Reakes, Head of Product Development  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Couple of simple questions

Posted by Graham Mann <gm...@adobe.com>.
I suspect these have been asked before but I cant find a FAQ or old mail to help (I also suspect I know the answers but...)

After a document has been parsed against an XML Schema into a DOM, is there a way to link DOM_Nodes back to schema data types.
In the first instance even the name of the xsd datatype would help (And then (fancifully!) to further inspect those data types for inheritance etc).

In many cases I'd like an iterator to the child elements of a particular element rather than an iterator to the remaining elements (ie grand children etc) in the document or to all the child nodes. I have several ways of handling this but all are a bit clunky.

Graham Mann
Adobe Systems Europe Ltd.



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Question about DOM_Element and DOM_Node...

Posted by Gert van Spijker <ge...@ab-graph.com>.
Question about DOM_Element and DOM_Node...I don't consider myself an expert on DOM (just yet) but I see your query is unanswered, so I'll give it a go. A DOM_Element is derived from DOM_Node so you can use getParentNode() to go up the tree, then check the Node type using DOM_Node::getNodeType(), then cast it to a DOM_Element if the type is DOM_Node::ELEMENT_NODE.

Gert
  ----- Original Message ----- 
  From: McFall, Kevin 
  To: 'xerces-c-dev@xml.apache.org' 
  Sent: Friday, June 21, 2002 6:14 PM
  Subject: Question about DOM_Element and DOM_Node...


  I'm using DOM to build XML Documents and wrapping the classes up so they can be used through a C API.  I keep a static DOM_ELEMENT for both the currentElement and the parentElement and add children or siblings to the current element through the API.  However, I just realized that I need to be able to go back up a level.  So, I tried to use the DOM_Node::getParentNode() method which returns a DOM_Node, but I need a DOM_Element.  

  My question is how do I go from a DOM_Node to a DOM_Element? 

  I want to be able to go up so I can add attributes/other children to that parent, which I can't do through a DOM_Node, only a DOM_Element.

  Thanks, 

  Kevin