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 "Gelle, Sreenivasulu" <sr...@sap.com> on 2009/07/07 06:31:28 UTC

Replacement for 2.7.0 depecated API getRootElemId in 3.0.1

HI All,

 

I am upgrading Xerces from 2.7.0 to 3.0.1. I am having a problem when I
am trying to get the root element for a given DTD. Your inputs are
appreciated to fix this upgrade issue.

 

 

When using 2.7.0, I have the following piece of code to get the root
node of the DTD:

 

                        DTDValidator&               x
= (DTDValidator&)m_parser->getValidator();

 

                        DTDGrammar*                           grammar =
(DTDGrammar*) x.getGrammar();

                        U4                    root_id =
grammar->getRootElemId();

                        NameIdPoolEnumerator<DTDElementDecl> elemEnum =
grammar->getElemEnumerator();

                        while(elemEnum.hasMoreElements())

                        {

                                    const DTDElementDecl& curElem =
elemEnum.nextElement();

                                    if(root_id  == curElem.getId())

                                    {

                                                //Getting the root
element name.

                                                rootName =
(UChar*)curElem.getFullName();

                                                break;

                                    }

                        }

 

In the above code, m_parser is an instance of SAXParser, and it parse an
XML with a DTD associated with it using <!DOCTYPE .../>.

 

Now in 3.0.1, I noticed that the interface getRootElemId() does not
exist in DTDGrammar class anymore. 

What is the alternative way to get the root element? Can anyone point me
to the new interface?

 

Thanks

-Srini