Can you do something like this:
DTDValidator& x = (DTDValidator&)m_parser->getValidator();
DTDGrammar* grammar = (DTDGrammar*) x.getGrammar();
XMLDTDDescription* description
= (XMLDTDDescription*)grammar->getGrammarDescription();
XMLCh* rootName = description->getRootName();
Thanks!
Frank
--- On Mon, 7/6/09, Gelle, Sreenivasulu <[email protected]> wrote:
> From: Gelle, Sreenivasulu <[email protected]>
> Subject: Replacement for 2.7.0 depecated API getRootElemId in 3.0.1
> To: [email protected], [email protected]
> Cc: "Ho, XuanLoan" <[email protected]>, "Zhou, Xiaofan"
> <[email protected]>
> Date: Monday, July 6, 2009, 9:31 PM
> 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
>
>
>
>
>
>
>
>
>
>