This isn't pretty either, but my solution was to derive my parser directly from 
SAXParser and override the xmlDecl() method. (Of course, we were already doing 
the extension for other reasons, so it was fairly painless for us to add that 
feature.)

- Thomas Cox

> -----Original Message-----
> From: Rob Outar [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, June 18, 2003 12:24 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Get/Set Encoding value
> 
> 
> Thanks for the information but I am a bit confused on to 
> actually get the encoding information.  Do I need to 
> implement the Locator interface and add this method to the 
> interface?  If so, what do I return for the methods I must 
> implement as part of the Locator interface?  Or am I way off 
> base ? :-)
> 
> Thanks,
> 
> Rob
> 
> 
> -----Original Message-----
> From: Michael Glavassevich [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 18, 2003 9:40 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Get/Set Encoding value
> 
> 
> Hi Rob,
> 
> If you're using the latest version of the parser (Xerces 
> 2.4.0), you should be able to retrieve the encoding using 
> SAX. Have a look at: 
> http://xml.apache.org/xerces2-j/faq-general.html#faq-8. The 
> solution isn't particularly elegant, but SAX's Locator2 
> interface isn't available yet.
> 
> Just to clarify some things for you:
> 
> <?xml ... ?> is an xml declaration. It isn't a processing 
> instruction, so it won't be reported to your ContentHandler.
> 
> SAX is read only, so if you need to change the encoding of 
> your instance document, you'd have an easier time using DOM. 
> i.e. Parsing your document (in whatever encoding) into a DOM, 
> and then serializing it back with UTF-8 as the output encoding.
> 
> Hope that helps.
> 
> On Wed, 18 Jun 2003, Rob Outar wrote:
> 
> > I have to write a program that will fetch the encoding information 
> > from
> XML
> > files:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > and verify that all encoding is set to UTF-8, my early trials using 
> > SAX
> has
> > not worked, I thought it was a preprocessing instruction 
> but I did not 
> > get the callback for my test files.  Is there an easy way 
> to fetch and
> possibly
> > update the encoding value?
> >
> > Thanks,
> >
> > Rob
> >
> 
> --------------------
> 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]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to