Thanks Keith,
It is working for DTD files after I removed the first line "<? xml version
= ... ?>" as you said. Thanks alott!!
As you said I cannot use DTDParser for parsing XML files, then if I need to
parse an XML file which API should I use?.
I will be glad if you could analyse my requirement and suggest me the
needful. My requirement is to traverse through an XML file (content.xml - it
is generated by open office), search for a particular Tag/Node for its
existence and if the Tag/Node exists, I need to duplicate that node n times
and save the xml file. How can I accomplish this? Please suggest me. Your
advice would be of utmost help.
Thanks in advance again. Will be lookign forward for a reply.
Regards,
Raj
-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 21, 2002 5:46 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Probelm while Parsing an XML/DTD file.
One more note, the DTDParser will not parse an XML file, it will only
parse a DTD file, so if you are trying to parse an internal-subset from
an XML file, it won't work unless you pass only the internal-subset to
the DTDParser by stripping off the surrounding XML.
--Keith
Hemanth Raju wrote:
>
> Hi all,
>
> I have probem parsing an XML/DTD file. Whenever I am passing XML
or DTD
> file to the DTDParser to its Input() method it is throwing me a
> TokenMgrException because it has found a "?" character in the XML file??
>
> Here's my code:
>
> // instantiate input byte stream, associated with the input file
> inputStream = new FileInputStream("d:\\shared\\build.dtd");
>
> // instantiate character reader from the input file byte stream
> reader = new InputStreamReader(inputStream, "UTF-8");
>
> // instantiate char stream for initial parser from the input
reader
> charStream = new InputCharStream(reader);
>
> // instantiate initial parser
> initialParser = new DTDInitialParser( charStream );
>
> // get result of initial parsing - DTD text document with
parameter entity
> references expanded
> intermedResult = initialParser.Input();
>
> // construct StringReader from the intermediate parsing result
> strReader= new StringReader( intermedResult );
>
> // instantiate char stream for the main parser
> charStream = new InputCharStream(strReader);
>
> // instantiate main parser
> parser = new DTDParser(charStream);
>
> dtd = parser.Input();
>
> The exception is as follows:-
>
> org.exolab.castor.xml.dtd.parser.TokenMgrError: Lexical error at line 1,
> column 2. Encountered: "?" (63), after : "<"
> at
>
org.exolab.castor.xml.dtd.parser.DTDParserTokenManager.getNextToken(DTDParse
> rTokenManager.java:2883)
> at
>
org.exolab.castor.xml.dtd.parser.DTDParser.jj_scan_token(DTDParser.java:2367
> )
> at org.exolab.castor.xml.dtd.parser.DTDParser.jj_3_1(DTDParser.java:1703)
> at org.exolab.castor.xml.dtd.parser.DTDParser.jj_2_1(DTDParser.java:709)
> at org.exolab.castor.xml.dtd.parser.DTDParser.Input(DTDParser.java:23)
>
> Am I missing something?? I will be glad if anyone can help me in this
> regard. Will be looking forward.
>
> Thanks a million in advance. Will be looking forward.
>
> Regards,
> Raj
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev