utf 8 - XmlBeans generates Java source files with ANSI encoding -
i using xmlbeans 2.6.0 compile xsd files contain enumeration of greek words:
<xs:simpletype name="t_series_report"> <xs:restriction base="xs:string"> <xs:enumeration value="Γενική"/> <xs:enumeration value="Ειδική"/> </xs:restriction> </xs:simpletype>
the compilation performed using ant task included in xbean.jar of zip binary distribution of xmlbeans. xsd files saved utf-8 , correctly stated in header java files
<?xml version="1.0" encoding="utf-8"?>
the problem java files generated xmlbeans seem saved in ansi character set , during compilation errors like:
[xmlbean] c:\projects\myproject\workspace\prj\build\xmlbeans\test\src\com\company\project\schema\myschematype\cl\cle\ext\tmytype.java:61: illegal character: \8220 [xmlbean] static final int int_ΓΕ�?ΙΚΉ = 1; [xmlbean]
is there way force xmlbeans save generated java files utf-8 instead of ansi?
we had similar problem compiling schema containing greek "omega" using xmlbeans' maven task.
problem is, xmlbeans (at least of version 2.5.0) uses javas platform default encoding, may set invoking jvm -dfile.encoding=utf-8
.
for our maven project, solution not use plugin; instead invoked xmlbeans using exec
plugin, had control on encoding. here snippet of pom.xml
<plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>exec-maven-plugin</artifactid> <executions> <execution> <id>exec-2.1.0</id> <phase>generate-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>java</executable> <arguments> <argument>-dfile.encoding=${project.build.sourceencoding}</argument> <argument>-classpath</argument> <!-- automatically creates classpath using project dependencies, adding project build directory --> <classpath/> <argument>org.apache.xmlbeans.impl.tool.schemacompiler</argument> <argument>-src</argument> <argument>${project.build.directory}/generated-sources</argument> <argument>-srconly</argument> <argument>-d</argument> <argument>${project.build.directory}/classes</argument> <argument>-javasource</argument> <argument>1.6</argument> <argument>${basedir}/src/main/2.1.0/schema/</argument> <argument>src/main/2.1.0/config/foobar_v2.1.0.xsdconfig</argument> </arguments> </configuration> </execution>
i suppose approach adaptable ant
well.
easier solution invoke ant this:
ant -dfile.encoding=utf-8 build-or-whatever
but work if source files in utf-8!
Comments
Post a Comment