You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by kris16 <kr...@tietoenator.com> on 2007/02/09 16:36:59 UTC
Problem with Scandinavian characters åäö
Hi,
I am using java 5 and xmlbeans 2.2.0.
I am trying to read an xml document from file an it works fine.
The xml file is using UTF-8.
But when I set a value for an element to contain the Scandinavian character
"ä" as in Pärsson, then
I get the following exception
<ComponentID schemeName="SourceSystem">Pärsson</ComponentID>:
java.io.CharConversionException: Malformed UTF-8 character: 0xf6 0x6e 0x73
0x73
If I change the the encoding to ISO-8859-1 then it works but I get the
following result
when I print it out:
<ComponentID schemeName="SourceSystem">Põrsson</ComponentID>
What am I doing wrong here ?
Why is not UTF-8 working at all ?
Why do I get the result Põrsson instead of Pärsson ?
/Regards Krister
--
View this message in context: http://www.nabble.com/Problem-with-Scandinavian-characters-%C3%A5%C3%A4%C3%B6-tf3200981.html#a8887787
Sent from the Xml Beans - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
decoding errors
Posted by "Samuel B. Quiring" <sb...@cayuse.com>.
Greetings,
I am trying to map some of the validating parse error messages into something our non-technical users could understand. For example, the message:
string length (string) is less than minLength facet (0) for 1
might map to:
The field <blah-blah> is empty, but it is required that you type something into that field.
Most of our users only see 2 or 3 different kinds of errors. If I can make those error messages understandable, I'll have covered 95% of the situations our customers experience. I'm looking for the best way to test an XmlError object to find out if it is a specific error, for example is it the error shown above? Obviously I could test the message for an exact match to the text shown above, but there seem to be 3 parameters in the message, "string", "0", and "1", so there are problems with that approach. Not to mention the text might be changed in the future.
When I get the above error, my code prints out the value of getErrorCode() and it is: "cvc-minLength-valid.1.1". So I thought I'll compare the value returned by getErrorCode() with a constant from XmlErrorCodes. But when I look at the constants in the XmlErrorCodes package I have no error code has this value. The closest is:
public static final java.lang.String DATATYPE_MIN_LENGTH_VALID = "cvc-minLength-valid";
when I look at this web site: http://xmlbeans.apache.org/docs/2.0.0/reference/constant-values.html and search for "cvc-minLength-valid.1.1", I get this:
public static final String DATATYPE_MIN_LENGTH_VALID$STRING "cvc-minLength-valid.1.1"
but the variable name DATATYPE_MIN_LENGTH_VALID$STRING is not in my local copy of XmlErrorCodes.
Does anyone know what's going on here. I'm not really a Java expert, so I'm not quite sure how to take this $STRING suffix.
-Sam
Re: Problem with Scandinavian characters åäö
Posted by kris16 <kr...@tietoenator.com>.
Hi,
I noticed that i had not saved the xml file in UTF-8 formate,
that is why i got the exception java.io.CharConversionException.
To solve the strange characters I used the toString("UTF-8") method to make
the characters appear correct in my console:
ByteArrayOutputStream result = new ByteArrayOutputStream();
newShowItem.save(result, opts);
System.out.println("\nPrint newShowItem.save(result);");
System.out.println(result.toString("UTF-8"));
/Regards Krister
kris16 wrote:
>
> Hi,
> I am using java 5 and xmlbeans 2.2.0.
>
> I am trying to read an xml document from file an it works fine.
> The xml file is using UTF-8.
> But when I set a value for an element to contain the Scandinavian
> character "ä" as in Pärsson, then
> I get the following exception
> <ComponentID schemeName="SourceSystem">Pärsson</ComponentID>:
> java.io.CharConversionException: Malformed UTF-8 character: 0xf6 0x6e 0x73
> 0x73
>
> If I change the the encoding to ISO-8859-1 then it works but I get the
> following result
> when I print it out:
> <ComponentID schemeName="SourceSystem">Põrsson</ComponentID>
>
> What am I doing wrong here ?
> Why is not UTF-8 working at all ?
>
> Why do I get the result Põrsson instead of Pärsson ?
>
> /Regards Krister
>
--
View this message in context: http://www.nabble.com/Problem-with-Scandinavian-characters-%C3%A5%C3%A4%C3%B6-tf3200981.html#a8921622
Sent from the Xml Beans - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org