You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Andreas B. Thun" <ab...@gmx.net> on 2003/07/25 11:28:54 UTC
An exception occurred! Type:UTFDataFormatException: why??
Hi!
When invoking the Xerces DOM-Parser with parser->parse(xmlFile)
I get this error message:
I do not know what´s wrong there, my xml file is valid against the DTD...
Fatal Error at file "/home/DOMParse/example.xml", line 1, column 39
Message: An exception occurred! Type:UTFDataFormatException, Message:invalid byte 2 (r) of a 6-byte sequence.
Errors occurred, no output available
----
header of my XML file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ConstraintTypes SYSTEM "constraint_template.dtd">
header of my DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT ...
TIA,
Andi
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
> nice to hear from you again :) You are of course correct.
I think so, too.
Thx a lot!
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
RE: An exception occurred! Type:UTFDataFormatException: why??
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hey Dean,
nice to hear from you again :) You are of course correct.
Gareth
On Fri, 25 Jul 2003, Dean Roddey wrote:
> Wouldn't the problem be that those are NOT UTF-8 characters? UTF-8 is
> not a code page, it's an encoding of Unicode characters. Though UTF-8
> can clearly encode Unicode which holds German characters, that's not
> what he is providing. So he is confusing UTF-8's ability to encode
> anything that can be represented as Unicode, and how that text get into
> Unicode format to begin with.
>
> -------------------------------------
> Dean Roddey
> The Charmed Quark Controller
> droddey@charmedquark.com
> www.charmedquark.com
>
>
> -----Original Message-----
> From: Oliver Kurowski [mailto:oliver.kurowski@gmx.de]
> Sent: Friday, July 25, 2003 9:14 AM
> To: xerces-c-dev@xml.apache.org
> Subject: Re: An exception occurred! Type:UTFDataFormatException: why??
>
> Hello!
>
> The problem may be the encoding the xml file is in. When you use
> standard
> windows editors, you can't change the encoding and it defaults to the
> windows standard, win-1252, which is the same for th 7 bit ascii
> standard,
> but not for the german special characters.
>
> Hope that helps,
>
> Oliver
>
> Andreas B. Thun wrote:
> >> to confirm, you have tried this with the xml decl in the DTD? If
> >
> > It worked! Thx very much!
> >
> > Actually, I am not allowed to use the German special chars ö ü ä in my
> > comments!!!
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
RE: An exception occurred! Type:UTFDataFormatException: why??
Posted by Dean Roddey <dr...@charmedquark.com>.
Wouldn't the problem be that those are NOT UTF-8 characters? UTF-8 is
not a code page, it's an encoding of Unicode characters. Though UTF-8
can clearly encode Unicode which holds German characters, that's not
what he is providing. So he is confusing UTF-8's ability to encode
anything that can be represented as Unicode, and how that text get into
Unicode format to begin with.
-------------------------------------
Dean Roddey
The Charmed Quark Controller
droddey@charmedquark.com
www.charmedquark.com
-----Original Message-----
From: Oliver Kurowski [mailto:oliver.kurowski@gmx.de]
Sent: Friday, July 25, 2003 9:14 AM
To: xerces-c-dev@xml.apache.org
Subject: Re: An exception occurred! Type:UTFDataFormatException: why??
Hello!
The problem may be the encoding the xml file is in. When you use
standard
windows editors, you can't change the encoding and it defaults to the
windows standard, win-1252, which is the same for th 7 bit ascii
standard,
but not for the german special characters.
Hope that helps,
Oliver
Andreas B. Thun wrote:
>> to confirm, you have tried this with the xml decl in the DTD? If
>
> It worked! Thx very much!
>
> Actually, I am not allowed to use the German special chars ö ü ä in my
> comments!!!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by Oliver Kurowski <ol...@gmx.de>.
Hello!
The problem may be the encoding the xml file is in. When you use standard
windows editors, you can't change the encoding and it defaults to the
windows standard, win-1252, which is the same for th 7 bit ascii standard,
but not for the german special characters.
Hope that helps,
Oliver
Andreas B. Thun wrote:
>> to confirm, you have tried this with the xml decl in the DTD? If
>
> It worked! Thx very much!
>
> Actually, I am not allowed to use the German special chars ö ü ä in my
> comments!!!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
> to confirm, you have tried this with the xml decl in the DTD? If
It worked! Thx very much!
Actually, I am not allowed to use the German special chars ö ü ä in my
comments!!!
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi again,
to confirm, you have tried this with the xml decl in the DTD? If
so post a full DTD and XML file that does not work for you. And confirm
for me the ones I posted back to you do not work for you.
cheers,
Gareth
On Fri, 25 Jul 2003, Andreas B. Thun wrote:
> > note the lack of <?xml... in the DTD. What version of xerces are you
> > using?
>
> 2_3_0 without the patches
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
> note the lack of <?xml... in the DTD. What version of xerces are you
> using?
2_3_0 without the patches
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
the following works fine for me
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ConstraintTypes SYSTEM "constraint_template.dtd">
<ConstraintTypes>
<!-- Definition von Benutzergruppen f Zugriffskontrolle -->
<AccessControlGroups>
<AccessControlGroup>
<GroupName>schematic_designer</GroupName>
</AccessControlGroup>
<AccessControlGroup>
<GroupName>layout_designer</GroupName>
</AccessControlGroup>
</AccessControlGroups>
</ConstraintTypes>
<!ELEMENT ConstraintTypes (AccessControlGroups)>
<!ELEMENT AccessControlGroups (AccessControlGroup+)>
<!ELEMENT AccessControlGroup (GroupName, GuiRepresentation?)>
<!ELEMENT GroupName (#PCDATA)>
note the lack of <?xml... in the DTD. What version of xerces are you
using?
Gareth
On Fri, 25 Jul 2003, Andreas B. Thun wrote:
> > Can you post you DTD?
>
> The error occurs even with Validation=OFF
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!ELEMENT AccessControlGroups (AccessControlGroup+)>
> <!ELEMENT AccessControlGroup (GroupName, GuiRepresentation?)>
> <!ELEMENT GroupName (#PCDATA)>
>
> -snip-
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
> Can you post you DTD?
The error occurs even with Validation=OFF
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT AccessControlGroups (AccessControlGroup+)>
<!ELEMENT AccessControlGroup (GroupName, GuiRepresentation?)>
<!ELEMENT GroupName (#PCDATA)>
-snip-
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Can you post you DTD?
Gareth
On Fri, 25 Jul 2003, Andreas B. Thun wrote:
> > <?xml version="1.0"?>
> > <!-- some comment -->
> > <root >
> > <!-- some comment -->
> > </root>
> > <!-- some comment -->
>
> Hmm, this is not my experience. Look at my XML file:
> It only works if I remove the comment!
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE ConstraintTypes SYSTEM "constraint_template.dtd">
> <ConstraintTypes>
>
> <!-- Definition von Benutzergruppen für die Zugriffskontrolle -->
>
> <AccessControlGroups>
> <AccessControlGroup>
> <GroupName>schematic_designer</GroupName>
> <GuiRepresentation>
> <Prompt>Schematic Designer</Prompt>
> </GuiRepresentation>
> </AccessControlGroup>
> <AccessControlGroup>
> <GroupName>layout_designer</GroupName>
> <GuiRepresentation>
> <Prompt>Layout Designer</Prompt>
> </GuiRepresentation>
> </AccessControlGroup>
> </AccessControlGroups>
>
> </ConstraintTypes>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
> <?xml version="1.0"?>
> <!-- some comment -->
> <root >
> <!-- some comment -->
> </root>
> <!-- some comment -->
Hmm, this is not my experience. Look at my XML file:
It only works if I remove the comment!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ConstraintTypes SYSTEM "constraint_template.dtd">
<ConstraintTypes>
<!-- Definition von Benutzergruppen für die Zugriffskontrolle -->
<AccessControlGroups>
<AccessControlGroup>
<GroupName>schematic_designer</GroupName>
<GuiRepresentation>
<Prompt>Schematic Designer</Prompt>
</GuiRepresentation>
</AccessControlGroup>
<AccessControlGroup>
<GroupName>layout_designer</GroupName>
<GuiRepresentation>
<Prompt>Layout Designer</Prompt>
</GuiRepresentation>
</AccessControlGroup>
</AccessControlGroups>
</ConstraintTypes>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
the only place you cannot put a comment (except inside element
decls) is before the <?xml bit. Nothing can go there.
<?xml version="1.0"?>
<!-- some comment -->
<root >
<!-- some comment -->
</root>
<!-- some comment -->
all those comments are fine, but if you went
<!-- some comment -->
<?xml version="1.0"?>
<root >
</root>
this would not be legel.
Gareth
On Fri, 25 Jul 2003, Andreas B. Thun wrote:
> > <?xml version="1.0"?>
> >
> > has to be the first line in the document.
>
> Thx. That was IMHO not the problem. I had
> XML comments in my XML file. Since I have
> removed them, everything is ok.
>
> ----
> How can I add comments in my XML file without
> disturbing the dom parser?
> ----
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE ConstraintTypes SYSTEM "constraint_template.dtd">
> <ConstraintTypes>
> <!-- comments like this are a problem -->
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
> <?xml version="1.0"?>
>
> has to be the first line in the document.
Thx. That was IMHO not the problem. I had
XML comments in my XML file. Since I have
removed them, everything is ok.
----
How can I add comments in my XML file without
disturbing the dom parser?
----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ConstraintTypes SYSTEM "constraint_template.dtd">
<ConstraintTypes>
<!-- comments like this are a problem -->
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
<?xml version="1.0"?>
has to be the first line in the document.
Gareth
On Fri, 25 Jul 2003, Andreas B. Thun wrote:
> Uh! Now I found it! It does not like empty lines!!!
> How can I handle this?
>
> Is this the proper command to handle empty lines?
> parser->setIncludeIgnorableWhitespace(true);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
Uh! Now I found it! It does not like empty lines!!!
How can I handle this?
Is this the proper command to handle empty lines?
parser->setIncludeIgnorableWhitespace(true);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
> Could you attch a small piece of XML that cause this problem for you?
Yes.
<?xml version="1.0"?>
<email>
<empfaenger>A. Thun</empfaenger>
<absender>A. Thun</absender >
<thema>Test</thema>
<nachricht>
Dies ist ein Test!
</nachricht>
</email>
or this (same effect):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ConstraintTypes SYSTEM "constraint_template.dtd">
<ConstraintTypes>
<AccessControlGroups>
<AccessControlGroup>
<GroupName>schematic_designer</GroupName>
<GuiRepresentation>
<Prompt>Schematic Designer</Prompt>
</GuiRepresentation>
</AccessControlGroup>
<AccessControlGroup>
<GroupName>layout_designer</GroupName>
<GuiRepresentation>
<Prompt>Layout Designer</Prompt>
</GuiRepresentation>
</AccessControlGroup>
</AccessControlGroups>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Could you attch a small piece of XML that cause this problem for you?
Gareth
On Fri, 25 Jul 2003, Andreas B. Thun wrote:
> > When invoking the Xerces DOM-Parser with parser->parse(xmlFile)
> > I get this error message:
> > I do not know what´s wrong there, my xml file is valid against the DTD...
> >
> >
> > Fatal Error at file "/home/DOMParse/example.xml", line 1, column 39
> > Message: An exception occurred! Type:UTFDataFormatException,
> > Message:invalid byte 2 (r) of a 6-byte sequence.
>
>
> I´ve learned now, that this error coccurs always.
> It does not matter which XML file I use. :-/
>
> Any ideas out there?
>
>
> --snip
>
> // Initialise Xerces-C
> try {
> XMLPlatformUtils::Initialize();
> }
>
> catch (const XMLException& toCatch) {
> char* message = XMLString::transcode(toCatch.getMessage());
> cout << "Error during initialization of XERCES! :\n" << message << "\n";
> XMLString::release(&message);
> return 2;
> }
>
> // set validation scheme: Default for validation scheme is Val_Always
> XercesDOMParser::ValSchemes valScheme = XercesDOMParser::Val_Always;
> if (valSchemeStr == "never")
> valScheme = XercesDOMParser::Val_Never;
>
> // create parser and do some settings
> XercesDOMParser* parser = new XercesDOMParser();
> parser->setValidationScheme(valScheme);
> parser->setDoNamespaces(false);
> parser->setIncludeIgnorableWhitespace(false);
>
> // create an error handler and install it
> DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
> parser->setErrorHandler(errReporter);
>
> try {
> parser->parse("x.xml");
> }
> catch (const XMLException& toCatch) {
> char* message = XMLString::transcode(toCatch.getMessage());
> cout << "An error occurred during parsing. Exception message is: \n"<< message << "\n";
> XMLString::release(&message);
> XMLPlatformUtils::Terminate();
>
> return(2);
> }
> catch (const DOMException& toCatch) {
> char* message = XMLString::transcode(toCatch.msg);
> cout << "Exception message is: \n" << message << "\n";
> XMLString::release(&message);
> XMLPlatformUtils::Terminate();
>
> return(2);
> }
> catch (...) {
> cout << "Unexpected Exception!\n";
> XMLPlatformUtils::Terminate();
> return(2);
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Encoding header during writer
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
there are other methods in DOMwriter that will write out as UTF-8
if that is helpful to you.
Gareth
On Fri, 25 Jul 2003, Scott MacKay wrote:
> Ah, yup. I use writeToString. The problem I have
> with UTH-16 seems to be that Java's
> DocumentBuilder.parse() does not seem to like UTF-16.
> I build up a ByteArrayInputStream from a String
> representation of the output (I use a C++ Xerces app
> to construct, send to a Java app). If I have UTF-16
> I always get a sun.io.malformedInputException
> (comment: "missing byte order mark"). If I strstr it
> to UTF-8, it is happy...
>
> -Scott
>
>
>
> --- Gareth Reakes <ga...@decisionsoft.com> wrote:
> > Hi,
> > did you use writeToString? If so then it ignores
> > the setting in
> > DOMWriter and gives back UTF-16.
> >
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Encoding header during writer
Posted by Scott MacKay <sc...@yahoo.com>.
Ah, yup. I use writeToString. The problem I have
with UTH-16 seems to be that Java's
DocumentBuilder.parse() does not seem to like UTF-16.
I build up a ByteArrayInputStream from a String
representation of the output (I use a C++ Xerces app
to construct, send to a Java app). If I have UTF-16
I always get a sun.io.malformedInputException
(comment: "missing byte order mark"). If I strstr it
to UTF-8, it is happy...
-Scott
--- Gareth Reakes <ga...@decisionsoft.com> wrote:
> Hi,
> did you use writeToString? If so then it ignores
> the setting in
> DOMWriter and gives back UTF-16.
>
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Encoding header during writer
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
did you use writeToString? If so then it ignores the setting in
DOMWriter and gives back UTF-16.
Gareth
On Fri, 25 Jul 2003, Scott MacKay wrote:
> Hello,
> I am playing around with some code based on the
> DOMPrint sample and am having a devil of a time
> getting the proper encoding indicator in the <?xml>
> statement.
> I know you can setEncoding() to UTF-8 on the DOMWriter
> you use to output the node. I have done that and when
> I getEncoding() it show UTF-8, but the char stream
> output still shows UTF-16 in the actual <?xml> line.
> This would be a document built from scratch. Would
> anyone have an example of building a document and then
> outputting it with the UTF-8 encoding? Thanks in
> advance!
>
> -Scott
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
RE: Encoding header during writer
Posted by Ashay Shende <as...@cisco.com>.
Well, I have worked with an example in which i parse an XML file which does
not have the XML declaration. I then serialize it to a file with the
DOMWriter setting the encoding to either UTF-8 or UTF-16 and the output file
contains the XML declaration line with the correct encoding that was set.
I wonder if parsing an XML file and then serializing it and building a
document from scratch and then serializing it makes a difference in the
output encoding.
-----Original Message-----
From: Scott MacKay [mailto:scottmackay@yahoo.com]
Sent: Friday, July 25, 2003 5:16 PM
To: xerces-c-dev@xml.apache.org
Subject: Encoding header during writer
Hello,
I am playing around with some code based on the
DOMPrint sample and am having a devil of a time
getting the proper encoding indicator in the <?xml>
statement.
I know you can setEncoding() to UTF-8 on the DOMWriter
you use to output the node. I have done that and when
I getEncoding() it show UTF-8, but the char stream
output still shows UTF-16 in the actual <?xml> line.
This would be a document built from scratch. Would
anyone have an example of building a document and then
outputting it with the UTF-8 encoding? Thanks in
advance!
-Scott
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Encoding header during writer
Posted by Scott MacKay <sc...@yahoo.com>.
Hello,
I am playing around with some code based on the
DOMPrint sample and am having a devil of a time
getting the proper encoding indicator in the <?xml>
statement.
I know you can setEncoding() to UTF-8 on the DOMWriter
you use to output the node. I have done that and when
I getEncoding() it show UTF-8, but the char stream
output still shows UTF-16 in the actual <?xml> line.
This would be a document built from scratch. Would
anyone have an example of building a document and then
outputting it with the UTF-8 encoding? Thanks in
advance!
-Scott
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: An exception occurred! Type:UTFDataFormatException: why??
Posted by "Andreas B. Thun" <ab...@gmx.net>.
> When invoking the Xerces DOM-Parser with parser->parse(xmlFile)
> I get this error message:
> I do not know what´s wrong there, my xml file is valid against the DTD...
>
>
> Fatal Error at file "/home/DOMParse/example.xml", line 1, column 39
> Message: An exception occurred! Type:UTFDataFormatException,
> Message:invalid byte 2 (r) of a 6-byte sequence.
I´ve learned now, that this error coccurs always.
It does not matter which XML file I use. :-/
Any ideas out there?
--snip
// Initialise Xerces-C
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
cout << "Error during initialization of XERCES! :\n" << message << "\n";
XMLString::release(&message);
return 2;
}
// set validation scheme: Default for validation scheme is Val_Always
XercesDOMParser::ValSchemes valScheme = XercesDOMParser::Val_Always;
if (valSchemeStr == "never")
valScheme = XercesDOMParser::Val_Never;
// create parser and do some settings
XercesDOMParser* parser = new XercesDOMParser();
parser->setValidationScheme(valScheme);
parser->setDoNamespaces(false);
parser->setIncludeIgnorableWhitespace(false);
// create an error handler and install it
DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
parser->setErrorHandler(errReporter);
try {
parser->parse("x.xml");
}
catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
cout << "An error occurred during parsing. Exception message is: \n"<< message << "\n";
XMLString::release(&message);
XMLPlatformUtils::Terminate();
return(2);
}
catch (const DOMException& toCatch) {
char* message = XMLString::transcode(toCatch.msg);
cout << "Exception message is: \n" << message << "\n";
XMLString::release(&message);
XMLPlatformUtils::Terminate();
return(2);
}
catch (...) {
cout << "Unexpected Exception!\n";
XMLPlatformUtils::Terminate();
return(2);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org