2013-06-18 63 views
2
  1. 從那裏XSD:http://www.loc.gov/ead/ead.xsd
  2. JAXB命令:XJC ead.xsd -b ead.xjb
  3. ead.xjb:
     
    < bindings xmlns="http://java.sun.com/xml/ns/jaxb" 
         xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" 
         xmlns:xs="http://www.w3.org/2001/XMLSchema" 
         version="2.1" > 
    < bindings schemaLocation="ead.xsd" version="1.0"> 
        < bindings node="//xs:complexType[@name='title']"> 
         < bindings node=".//xs:attribute[@name='type']"> 
          < property name="TAttribute"/> 
         < /bindings> 
        < /bindings> 
    < /bindings> 
    < /bindings> 
    
  4. 異常
     
    parsing a schema... 
    Exception in thread "main" java.lang.AssertionError: javax.xml.bind.JAXBException 
    
                
        
    • with linked exception: [com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions com.sun.xml.bind.api.impl.NameConverter is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at com.sun.xml.bind.api.impl.NameConverter at public com.sun.xml.bind.api.impl.NameConverter com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.nameConverter at com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding ] at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationContext(BindInfo.java:356) at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationUnmarshaller(BindInfo.java:362)

什麼可能是錯誤?JAXBException上EAD XSD代

回答

3

您使用哪種xjc? 我會建議使用jdk1.6內置的xjc來生成所需的綁定。

+1

是的。問題與Java版本。使用xjc和java 1.7一切正常。 – Martynas