Hi, It is OK. I can get the DTDGrammar by preparsing the DTD. but then how can I use its methods like startDTD, textDecl, elementDecl, etc ? When I am trying to extend the DTDGrammar to a new class then again it creates problem in initialising it. I would be grateful, if someone can send a sample program which exploits the above mentioned methods, ofcourse by extending the class DTDGrammar.
Thanks, Utsav On Thu, 12 Jun 2003, Michael Glavassevich wrote: > Hi Utsav, > > DTDGrammar implements org.apache.xerces.xni.grammars.Grammar, so all you > need to do is cast it to a DTDGrammar (first checking that it's an > instanceof DTDGrammar of course). > > As a side note, if you call getGrammarDescription().getGrammarType() on > the Grammar object, you'll be > able to tell what type of grammar was returned from the grammar > preparser. You might want to have a look at the javadoc for the > org.apache.xerces.xni.grammars package > (http://xml.apache.org/xerces2-j/javadocs/xni/index.html). > > On Fri, 13 Jun 2003 [EMAIL PROTECTED] wrote: > > > Hi Michael, > > > > Thanks for the reply. Yes, you are right . I need the available > > information from the given DTD. For any element I want its all possible > > children. Thats why I tried to get DTDGrammar.(Is there any other suitable > > way??) > > Now as suggested by you, I have parsed the diven DTD but it returns me > > Grammar. How can I get DTDGrammar? > > > > Utsav > > > > > > > Hi Ustav, > > > > > > It seems to me that you're trying to parse a DTD, and obtain it's > > > representation as a DTDGrammar. You should take a look at the > > > XMLGrammarPreparser > > > (http://xml.apache.org/xerces2-j/faq-grammars.html#faq-3). > > > > > > The approach you're taking doesn't do what you probably expected. Creating > > > an instance of DTDGrammar doesn't cause your DTD to be parsed. > > > DTDGrammar is a container, not a parser. The object won't contain any > > > declarations, after instantiating it. It's normally populated from a > > > stream generated by the XML scanner. So unless you were planning to > > > populate it > > > yourself by some other means, your best bet is to use the > > > XMLGrammarPreparser. > > > > > > Hope that helps. > > > > > > On Thu, 12 Jun 2003, Utsav Boobna wrote: > > > > > >> > > >> Hi > > >> In my Java program, I was trying to initiate a DTDGrammar.Below is > > >> the part of my code ....... I cant understand why the grammar doesnt > > >> initiate, probably I am missing something. > > >> Please help. > > >> > > >> SymbolTable sym = new SymbolTable(2039); > > >> XMLDTDDescription desc = new XMLDTDDescription > > >> (null,"book.dtd",null,"book.dtd","book"); > > >> DTDGrammar grammar = new DTDGrammar (sym,desc); > > >> > > >> Problem might be in specifying the system ID of the DTD(??). > > >> all the files are in same directory. > > >> > > >> Thanks, > > >> Utsav > > >> > > >> > > >> --------------------------------------------------------------------- > > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > > >> For additional commands, e-mail: [EMAIL PROTECTED] > > >> > > >> > > > > > > -------------------- > > > Michael Glavassevich > > > [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -------------------- > Michael Glavassevich > [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- Utsav Boobna Third Year UnderGraduate Mathematics And Scientific Computing Indian Institute Of Technology, Kanpur --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
