cannot generate classes with JAXB

2019-03-03 12:37发布

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>

标签: jaxb
2条回答
▲ chillily
2楼-- · 2019-03-03 13:16

I might guess that one of your xsd files have a regexp-based restriction attached to a type/element. Have you validated those files?

查看更多
神经病院院长
3楼-- · 2019-03-03 13:20

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) and Driver.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. HTH Flavio

查看更多
登录 后发表回答