Re: Java source escaping

Andreas Loew <[email protected]> Mon, 28 Jan 2013 15:14:29 +0100
Newsgroups gmane.text.xml.xmlbeans.user
Organization Oracle Deutschland B.V. & Co. KG
Message-ID <[email protected]>
Hi Dridi,

Am 28.01.2013 14:57, schrieb Dridi Boukelmoune:
> I'm having trouble building a project on Linux because of the classes
> generated by XmlBeans. The build works properly on a Solaris platform
> using the same tools:
>
> Java : Hotspot 1.5.0_16
> Ant : 1.6.5
> XmlBeans: 2.3.1.0
>
> For the XmlBeans version, it comes with Weblogic 10.0:
> com.bea.core.xml.beaxmlbeans_2.3.1.0.jar
> com.bea.core.xquery.xmlbeans-interop_1.0.0.0.jar
> com.bea.core.xquery.beaxmlbeans-interop_1.0.0.0.jar
> com.bea.core.xml.xmlbeans_2.3.1.0.jar
>
> I hope my problem is not related to Weblogic's version.
I don't think so (see below for the details) - I rather tend to think 
that this is a locale/encoding issue in the XSD and/or between those 
platforms.

> So I have an XSD file containing something like:
> <simpleType name="MyType">
>          <restriction base="string">
>                  <enumeration value="A cliché"></enumeration>
>                  ...
>          </restriction>
> </simpleType>
>
> With Linux, I get this output:
> static final Enum A_CLICHÉ = Enum.forString("A cliché");
>
> On the other hand, it produces this on Solaris:
> static final Enum A_CLICH\311 = Enum.forString("A clich\351");
>
> The java source code generated on Linux doesn't compile because of an
> encoding mess I can't address now, so I'm currently trying to
> understand how the code is generated. I haven't found yet which option
> leads to either one or the other output that could have different
> defaults based on the platform.
>
> I hope someone can help me on this one.
Most probably, sorting out your locale/character encoding issues should 
solve the issue.

First and foremost: Does the XSD in question with the French é include 
an encoding declaration? Such as

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema>
     (...)
</xs:schema>

If it does not, you need to explicitly mention the appropriate encoding 
of that file in this place to make this portable.

If you don't, I expect the XMLBeans code generator to use the system's 
default locale, which will be calculated on Unix platforms from 
environment variables such as LANG, LC_CTYPE etc.?

Do you call scomp from the command line, or do you use Ant or Maven to 
call the code generator?

Also, how did you transport/copy the source code from the Solaris to the 
Linux machine? Did you copy files in binary mode, or using scp (which 
might have done recoding of text files on the fly based on 
language/encoding settings on source and target machine)? So you should 
check that your XSD files on both machines indeed are binary identical.

I hope that you should be able to simply add the appropriate encoding to 
your XSD and be fine.

Hope this helps & best regards,
Andreas

-- 
Andreas Loew | Senior Java Architect
Oracle Advanced Customer Services
ORACLE Germany