为什么JAXB(jaxb2 maven插件)跳过此属性?
为什么JAXB(jaxb2 maven插件)跳过此属性?,jaxb,jaxb2,xjc,maven-jaxb2-plugin,Jaxb,Jaxb2,Xjc,Maven Jaxb2 Plugin,jaxb2maven插件1.3跳过对象的属性。我无法修改XSD。在XSD(片段)中: 为什么它不生成attA成员 这可能是内联枚举的原因吗 多谢各位 Udo。您能提供一个完整的XML模式来演示这个问题吗?下面这条线是我尝试过的,一切似乎都如预期的那样工作 当我在以下XML模式上运行XJC时: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSc
jaxb2maven插件1.3
跳过对象的属性。我无法修改XSD
。在XSD
(片段)中:
为什么它不生成attA
成员
这可能是内联枚举的原因吗
多谢各位
Udo。您能提供一个完整的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>
您使用的是什么JAXB版本?内联枚举应正确转换为Java枚举 您可以尝试在属性定义之外定义simpleType,这可能会有所帮助。转到 org.jvnet.jaxb2.maven2 maven-jaxb2-plugin 一切正常
谢谢您的时间。内联枚举如何?在哪里?对不起,我不能透露XSD。明天我在办公室的时候,我会添加一个更有意义的例子。谢谢你的时间。谢谢你的回复。我无法修改该文件。
public class ComplexClassA {
@XmlSchemaType(name = "unsignedInt")
protected Long id;
}
<?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;
}
}