You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Rob Outar <ro...@ideorlando.org> on 2003/06/18 14:50:47 UTC

Get/Set Encoding value

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

RE: Get/Set Encoding value

Posted by Rob Outar <ro...@ideorlando.org>.
I was not using 2.4.. thought I was.  Anyhow I can now fetch it.  Thanks a
lot.

Thanks,

Rob

-----Original Message-----
From: Rob Outar [mailto:routar@ideorlando.org]
Sent: Wednesday, June 18, 2003 12:24 PM
To: xerces-j-user@xml.apache.org
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:mrglavas@apache.org]
Sent: Wednesday, June 18, 2003 9:40 AM
To: xerces-j-user@xml.apache.org
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
mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


RE: Get/Set Encoding value

Posted by Rob Outar <ro...@ideorlando.org>.
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:mrglavas@apache.org]
Sent: Wednesday, June 18, 2003 9:40 AM
To: xerces-j-user@xml.apache.org
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
mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Get/Set Encoding value

Posted by Michael Glavassevich <mr...@apache.org>.
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
mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org