Java XSD模式中的选项属性不会生成到JAXB
我有一个带有Java XSD模式中的选项属性不会生成到JAXB,java,maven,xsd,jaxb,Java,Maven,Xsd,Jaxb,我有一个带有complexType的XSD模式,它包含choice元素 <xsd:complexType mixed="true" name="CreateApprovedPurchaseRequestType"> <xsd:choice maxOccurs="unbounded" minOccurs="0"> <xsd:element maxOccurs="unbounded" minOccurs="0" name="ALSRules" typ
complexType
的XSD模式,它包含choice
元素
<xsd:complexType mixed="true" name="CreateApprovedPurchaseRequestType">
<xsd:choice maxOccurs="unbounded" minOccurs="0">
<xsd:element maxOccurs="unbounded" minOccurs="0" name="ALSRules" type="RuleSetType"/>
<xsd:element name="CDFs">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="CDF" type="CDFType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
<xsd:attribute name="RequestId" type="xsd:string" use="optional"/>
</xsd:complexType>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name=“CreateApprovedPurchaseRequestType”,Propoder={
“内容”
})
公共类CreateApprovedPurchaseRequestType{
@XmlElementRefs({
@xmlementref(name=“ALSRules”,type=JAXBElement.class,required=false),
@xmlementref(name=“CDFs”,type=JAXBElement.class,required=false)
})
@混合
受保护的列表内容;
@xmldattribute(name=“RequestId”)
受保护的字符串请求ID;
/**
*获取内容属性的值。
*
*
*此访问器方法返回对活动列表的引用,
*不是快照。因此,对
*返回的列表将出现在JAXB对象中。
*这就是为什么内容属性没有set
方法的原因。
*
*
*例如,要添加新项目,请执行以下操作:
*
*
*
*
*列表中允许以下类型的对象
*{@link CDFType}
*
*
*/
公共列表getCDF(){
如果(cdf==null){
cdf=新的ArrayList();
}
返回此.cdf;
}
}
}
我尝试使用绑定文件并设置正确的生成。但它没有影响,我无法达到预期的效果
请尝试以下操作。(免责声明:我是作者。)
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for CreateApprovedPurchaseRequestType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="CreateApprovedPurchaseRequestType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <choice maxOccurs="unbounded" minOccurs="0">
* <element name="ALSRules" type="{}RuleSetType" maxOccurs="unbounded" minOccurs="0"/>
* <element name="CDFs">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="CDF" type="{}CDFType" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </choice>
* <attribute name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CreateApprovedPurchaseRequestType", propOrder = {
"content"
})
public class CreateApprovedPurchaseRequestType {
@XmlElementRefs({
@XmlElementRef(name = "ALSRules", type = JAXBElement.class, required = false),
@XmlElementRef(name = "CDFs", type = JAXBElement.class, required = false)
})
@XmlMixed
protected List<Serializable> content;
@XmlAttribute(name = "RequestId")
protected String requestId;
/**
* Gets the value of the content property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the content property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getContent().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link CreateApprovedPurchaseRequestType.CDFs }{@code >}
* {@link String }
* {@link JAXBElement }{@code <}{@link RuleSetType }{@code >}
*
*
*/
public List<Serializable> getContent() {
if (content == null) {
content = new ArrayList<Serializable>();
}
return this.content;
}
/**
* Gets the value of the requestId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRequestId() {
return requestId;
}
/**
* Sets the value of the requestId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRequestId(String value) {
this.requestId = value;
}
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="CDF" type="{}CDFType" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"cdf"
})
public static class CDFs {
@XmlElement(name = "CDF")
protected List<CDFType> cdf;
/**
* Gets the value of the cdf property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the cdf property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCDF().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link CDFType }
*
*
*/
public List<CDFType> getCDF() {
if (cdf == null) {
cdf = new ArrayList<CDFType>();
}
return this.cdf;
}
}
}
<jxb:bindings
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.1">
<jxb:globalBindings choiceContentProperty="true">
<xjc:simple />
</jxb:globalBindings>
</jxb:bindings>