jaxb2-maven-plugin 1.3跳过对象中的属性。我不能修改XSD。在XSD (片段)中:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="classA" type="classA" substitutionGroup="classSubA"/>
<xs:complexType name="complexClassA" mixed="true">
<xs:attribute name="attA">
<xs:annotation>
<xs:appinfo>
<moProperty value="classA:attA"/>
<label value="Attribute A" default="true"/>
<externAccess value="readWrite"/>
<description value="NO COMMENTS"/>
</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="off"/>
<xs:enumeration value="on"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="id" type="xs:unsignedInt">
<xs:annotation>
<xs:appinfo>
<moProperty value="myClassB:id"/>
<label value="Id" default="true"/>
<externAccess value="readWrite"/>
<description value="NO COMMENTS"/>
</xs:appinfo>
</xs:annotation>
</xs:attribute>
</xs:schema>生成的Java Object (片段):
public class ComplexClassA {
@XmlSchemaType(name = "unsignedInt")
protected Long id;
}为什么它不生成attA成员?
是否会导致内联枚举?
谢谢。
乌多。
发布于 2011-07-28 16:01:29
在转到
org.jvnet.jaxb2.maven2 maven-jaxb2-plugin
一切都很正常。
谢谢您抽时间见我。
发布于 2011-07-28 00:18:13
您能提供一个完整的XML模式来演示这个问题吗?下面这条线是我尝试过的,一切似乎都像预期的那样工作。
当我在以下XML模式上运行XJC时:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Foo" xmlns="http://www.example.org/Foo"
elementFormDefault="qualified">
<xs:complexType name="complexClassA" mixed="true">
<xs:attribute name="attA">
<xs:annotation>
<xs:appinfo>
<moProperty value="classA:attA"/>
<label value="Attribute A" default="true"/>
<externAccess value="readWrite"/>
<description value="NO COMMENTS"/>
</xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="off"/>
<xs:enumeration value="on"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="id" type="xs:unsignedInt">
<xs:annotation>
<xs:appinfo>
<moProperty value="myClassB:id"/>
<label value="Id" default="true"/>
<externAccess value="readWrite"/>
<description value="NO COMMENTS"/>
</xs:appinfo>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:schema>不出所料,我得到了以下类:
package org.example.foo;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "complexClassA", propOrder = {
"content"
})
public class ComplexClassA {
@XmlValue
protected String content;
@XmlAttribute
protected String attA;
@XmlAttribute
@XmlSchemaType(name = "unsignedInt")
protected Long id;
public String getContent() {
return content;
}
public void setContent(String value) {
this.content = value;
}
public String getAttA() {
return attA;
}
public void setAttA(String value) {
this.attA = value;
}
public Long getId() {
return id;
}
public void setId(Long value) {
this.id = value;
}
}发布于 2011-07-28 00:20:16
您使用的是哪个JAXB版本?内联枚举应正确转换为Java枚举。
您可以尝试在属性定义之外定义simpleType,这可能会有所帮助。
https://stackoverflow.com/questions/6845416
复制相似问题