XSD with Schema with Restriction "Pattern, enumeration, max and min" Java

Asked

Viewed 31 times

2

I’m trying to generate a wsdl where it will generate a xsd reflecting the classes of entities.

The problem is, I can’t generate the Restriction in xsd as required by each property of the appropriate classes.

What I am generating:

<xs:complexType name="apolice">
<xs:sequence>
<xs:element name="CD_SISTEMA_ORIGEM" type="xs:string"/>
<xs:element name="CD_PRODUTO" type="xs:short"/>
<xs:element name="NRO_PROPOSTA" type="xs:long"/>
<xs:element name="DT_PERIODO_INI" type="xs:int"/>
<xs:element name="DT_PERIODO_FIM" type="xs:int"/>
</xs:sequence>
</xs:complexType>

Class I use to generate:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="PropostaSeguro")

public class Apolice {

public Apolice(){

}


@XmlElement(name = "CD_SISTEMA_ORIGEM", required = true)
public String cdSistemaOrigem;

@XmlElement(name = "CD_PRODUTO", required = true)
public short cdProduto;

@XmlElement(name = "NRO_PROPOSTA", required = true)
public long nroProposta;

@XmlElement(name = "DT_PERIODO_INI", required = true)
public Integer dtPeriodoIni;

@XmlElement(name = "DT_PERIODO_FIM", required = true)
public Integer dtPeriodoFim;

Plus get and set methods of class

What I need to generate:

<xs:element name="car">
 <xs:simpleType>
  <xs:restriction base="xs:string">
   <xs:enumeration value="Audi"/>
   <xs:enumeration value="Golf"/>
   <xs:enumeration value="BMW"/>
  </xs:restriction>
 </xs:simpleType>
</xs:element>

<xs:element name="letter">
 <xs:simpleType>
  <xs:restriction base="xs:string">
   <xs:pattern value="[a-z]"/>
 </xs:restriction>
</xs:simpleType>

 <xs:element name="password">
 <xs:simpleType>
  <xs:restriction base="xs:string">
   <xs:minLength value="5"/>
   <xs:maxLength value="8"/>
  </xs:restriction>
 </xs:simpleType>
</xs:element>

Thanks for your help!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.