You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Ashay <as...@yahoo.com> on 2003/04/27 10:08:35 UTC

adding attributes to Node objects.

Hi,I am very new to Xerces and Xalan.I am working with DOM_Node and related APIs. When I apply an XPath to a DOM_Document type object(first converting it to XalanDocument using XercesDocumentBridge API), I finally have a list of DOM_Node objects of type Element nodes.I now have to add attributes these elements. As they are contained in DOM_Node objects, i cannot use the setAttribute function as it is defined only for DOM_Element objects. Can anybody give me a clue as to how this can be done. When I try to cast a DOM_Node ptr to DOM_Element pointer, i get the syntax error: "the source object is not polymorphic".(I am using gcc 2.95). Is this a problem witb the compiler or am I doing something vague :-) Basically, I am looking for  a solution as to how to invoke the methods of Elements if I have a Node object and it is known that the node is of type Element. A quick reply would be highly appreciated. AS. 

---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

Re: adding attributes to Node objects.

Posted by da...@us.ibm.com.



This is really a Xerces-C question.  If you are not already subscribed to
the Xerces-C list, you should do so, and post your Xerces-C questions
there.

You can perform the cast like this:

DOM_Element
foo(const DOM_Node&   node)
{
    DOM_Element   elem = static_cast<const DOM_Element&>(node);

    return elem;
}

Dave



|---------+--------------------------->
|         |           Ashay           |
|         |           <ashaytech@yahoo|
|         |           .com>           |
|         |                           |
|         |           04/27/2003 01:08|
|         |           AM              |
|---------+--------------------------->
  >--------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                |
  |        To:      xalan-c-users@xml.apache.org                                                                                   |
  |        cc:      (bcc: David N Bertoni/Cambridge/IBM)                                                                           |
  |        Subject: adding attributes to Node objects.                                                                             |
  >--------------------------------------------------------------------------------------------------------------------------------|



Hi,
I am very new to Xerces and Xalan.
I am working with DOM_Node and related APIs.

When I apply an XPath to a DOM_Document type object(first converting it to
XalanDocument using XercesDocumentBridge API), I finally have a list of
DOM_Node objects of type Element nodes.
I now have to add attributes these elements. As they are contained in
DOM_Node objects, i cannot use the setAttribute function as it is defined
only for DOM_Element objects.

Can anybody give me a clue as to how this can be done.
When I try to cast a DOM_Node ptr to DOM_Element pointer, i get the syntax
error: "the source object is not polymorphic".(I am using gcc 2.95).

Is this a problem witb the compiler or am I doing something vague :-)

Basically, I am looking for  a solution as to how to invoke the methods of
Elements if I have a Node object and it is known that the node is of type
Element.

A quick reply would be highly appreciated.

AS.



Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.