问题描述
我尝试使用JAXB生成类但是我得到一个异常:
IllegalArgumentException:非法模式字符'g'
我正在使用复杂的XSD文件和绑定文件,如下所示。
有人能说明调查的地方吗?
i try to generate classes using JAXB but I a get an exception : IllegalArgumentException: Illegal pattern character 'g'I'using a complex XSD file and a binding file as below.Can somebody give a clue to where investigate ?
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jxb:extensionBindingPrefixes="xjc">
<jxb:bindings schemaLocation="IFX170_XSD.xsd" node="/xs:schema">
<jxb:schemaBindings>
<jxb:package name="cy.com.netinfo.netteller.ifx"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings schemaLocation="RemitDetail_Type.xsd" node="/xs:schema">
<jxb:schemaBindings>
<jxb:package name="cy.com.netinfo.netteller.ifx.remitdetailinfo"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings schemaLocation="$pain.001.001.01.xsd" node="/xs:schema">
<jxb:schemaBindings>
<jxb:package name="cy.com.netinfo.netteller.ifx.swift.pain_001_001_1"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings schemaLocation="$pain.002.001.01.xsd" node="/xs:schema">
<jxb:schemaBindings>
<jxb:package name="cy.com.netinfo.netteller.ifx.swift.pain_002_001_1"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings schemaLocation="$pain.004.001.01.xsd" node="/xs:schema">
<jxb:schemaBindings>
<jxb:package name="cy.com.netinfo.netteller.ifx.swift.pain_004_001_1"/>
</jxb:schemaBindings>
</jxb:bindings>
推荐答案
最后我找到了答案。
问题是由于com.sun.tools.xjc包中的类选项出错。
在方法getPrologComment中,类构建一个本地化消息,从本地化资源包中获取参数fot日期和时间,然后使用固定的Locale.ENGLISH格式化日期。此行为在JAXB 2.2.6中。
我解决了这个问题,只需在jar文件jaxb-xjc.jar的软件包com\sun\tools\xjc \\中更新文件MessageBundle_it.properties(在我的意大利语中为italian)。
我所做的更改是:
Driver.DateFormat = aaaa.MM.gg(原始)到Driver.DateFormat = yyyy / MM / dd(新)和
Driver.TimeFormat = hh: mm:ss az(原始)到Driver.TimeFormat = HH:mm:ss(新)
通过这些更改,我可以根据需要生成类。
HTH
Flavio
At last I found the answer.The problem is due to a mistake in the class Options in the package com.sun.tools.xjc.In the method getPrologComment the class builds a localized message taking parameter fot date and time from a localized resource bundle, but then formats the date using a fixed Locale.ENGLISH. This behavior is inside JAXB 2.2.6.I solved the problem simply updating the file MessageBundle_it.properties (in my case for italian) in the package com\sun\tools\xjc\ of the jar file jaxb-xjc.jar.The changes I made was :Driver.DateFormat = aaaa.MM.gg (original) to Driver.DateFormat = yyyy/MM/dd (new) andDriver.TimeFormat = hh:mm:ss a z (original) to Driver.TimeFormat = HH:mm:ss (new)With those changes I was able to generate the classes as needed.HTHFlavio
这篇关于无法使用JAXB生成类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!