Criei minhas classes com JAXB a partir de um XSD.
Tenho esta classe:
public static class PISOutr {
@XmlElement(name = "CST", required = true)
protected String cst;
@XmlElementRefs({
@XmlElementRef(name = "pPIS", type = JAXBElement.class, required = false),
@XmlElementRef(name = "vBC", type = JAXBElement.class, required = false)
})
protected List<JAXBElement<String>> vbcOrPPIS;
@XmlElementRefs({
@XmlElementRef(name = "qBCProd", type = JAXBElement.class, required = false),
@XmlElementRef(name = "vAliqProd", type = JAXBElement.class, required = false)
})
protected List<JAXBElement<String>> qbcProdOrVAliqProd;
@XmlElement(name = "vPIS", required = true)
protected String vpis;
public String getCST() {
return cst;
}
public void setCST(String value) {
this.cst = value;
}
public List<JAXBElement<String>> getVBCOrPPIS() {
if (vbcOrPPIS == null) {
vbcOrPPIS = new ArrayList<JAXBElement<String>>();
}
return this.vbcOrPPIS;
}
public List<JAXBElement<String>> getQBCProdOrVAliqProd() {
if (qbcProdOrVAliqProd == null) {
qbcProdOrVAliqProd = new ArrayList<JAXBElement<String>>();
}
return this.qbcProdOrVAliqProd;
}
public String getVPIS() {
return vpis;
}
public void setVPIS(String value) {
this.vpis = value;
}
}
para utilizar essa classe faço assim:
EnvCFe.LoteCFe.CFe.InfCFe.Det.Imposto.PIS.PISOutr pisOutr = new EnvCFe.LoteCFe.CFe.InfCFe.Det.Imposto.PIS.PISOutr();
pisOutr.setCST(tributacao);
pisOutr.setVPIS(vPis);
// como preencho os outros campos no xml?
Segue a estrutura do conteúdo do XML:
XSD:
<xs:element name="PISOutr" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="CST" minOccurs="1" maxOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="^\d{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:choice minOccurs="1" maxOccurs="1">
<xs:choice minOccurs="2" maxOccurs="2">
<xs:element name="vBC" minOccurs="0" maxOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="^\d{1,13}[.]{1}[0-9]{2}$"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="pPIS" minOccurs="0" maxOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="^\d{1}[.]{1}[0-9]{4}$"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
<xs:choice minOccurs="2" maxOccurs="2">
<xs:element name="qBCProd" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="^\d{1,12}[.]{1}[0-9]{4}$"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="vAliqProd" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="^\d{1,11}[.]{1}[0-9]{4}$"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:choice>
<xs:element name="vPIS" minOccurs="1" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="^\d{1,13}[.]{1}[0-9]{2}$"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Preciso preencher o campo (vBC e pPIS) ou (qBCProd e vAliqProd)
Como faço para preencher estes campos utilizando a classe que foi criada pelo JAXB?