我已经为您提供了一个快速模式,这可能不是您所需要的,因为我无法从示例数据中判断它是否允许多个或某些元素等:
<xs:schema version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="CRMMessage">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="RequestSource">
<xs:complexType>
<xs:attribute name="Testsource" type="xs:string"/>
<xs:attribute name="version" type="xs:integer"/>
</xs:complexType>
</xs:element>
<xs:element minOccurs="1" maxOccurs="1" name="RequestCode" type="xs:string"/>
<xs:element minOccurs="1" maxOccurs="1" name="DataSet">
<xs:complexType>
<xs:all>
<xs:element minOccurs="1" maxOccurs="1" name="DataSetColumns">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="DSColumn">
<xs:complexType>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="1" maxOccurs="1" name="Rows">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="Row">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="Col" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="language" type="xs:string"/>
<xs:attribute name="currency" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
您应该能够以此为起点。然后我通过maven插件和我的pom中的以下内容
将它编译成一个类:xjc
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<id>bind-crm</id>
<configuration>
<schemaDirectory>src/main/resources/</schemaDirectory>
<generatePackage>com.my.package.crm</generatePackage>
<forceRegenerate>true</forceRegenerate>
</configuration>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
这给了我以下代码:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"requestSource",
"requestCode",
"dataSet"
})
@XmlRootElement(name = "CRMMessage")
public class CRMMessage {
@XmlElement(name = "RequestSource", required = true)
protected CRMMessage.RequestSource requestSource;
@XmlElement(name = "RequestCode", required = true)
protected String requestCode;
@XmlElement(name = "DataSet", required = true)
protected CRMMessage.DataSet dataSet;
@XmlAttribute(name = "language")
protected String language;
@XmlAttribute(name = "currency")
protected String currency;
/**
* Gets the value of the requestSource property.
*
* @return
* possible object is
* {@link CRMMessage.RequestSource }
*
*/
public CRMMessage.RequestSource getRequestSource() {
return requestSource;
}
/**
* Sets the value of the requestSource property.
*
* @param value
* allowed object is
* {@link CRMMessage.RequestSource }
*
*/
public void setRequestSource(CRMMessage.RequestSource value) {
this.requestSource = value;
}
/**
* Gets the value of the requestCode property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRequestCode() {
return requestCode;
}
/**
* Sets the value of the requestCode property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRequestCode(String value) {
this.requestCode = value;
}
/**
* Gets the value of the dataSet property.
*
* @return
* possible object is
* {@link CRMMessage.DataSet }
*
*/
public CRMMessage.DataSet getDataSet() {
return dataSet;
}
/**
* Sets the value of the dataSet property.
*
* @param value
* allowed object is
* {@link CRMMessage.DataSet }
*
*/
public void setDataSet(CRMMessage.DataSet value) {
this.dataSet = value;
}
/**
* Gets the value of the language property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getLanguage() {
return language;
}
/**
* Sets the value of the language property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setLanguage(String value) {
this.language = value;
}
/**
* Gets the value of the currency property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCurrency() {
return currency;
}
/**
* Sets the value of the currency property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCurrency(String value) {
this.currency = 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">
* <all>
* <element name="DataSetColumns">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="DSColumn" maxOccurs="unbounded">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* <element name="Rows">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Row" maxOccurs="unbounded">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Col" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </all>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
})
public static class DataSet {
@XmlElement(name = "DataSetColumns", required = true)
protected CRMMessage.DataSet.DataSetColumns dataSetColumns;
@XmlElement(name = "Rows", required = true)
protected CRMMessage.DataSet.Rows rows;
/**
* Gets the value of the dataSetColumns property.
*
* @return
* possible object is
* {@link CRMMessage.DataSet.DataSetColumns }
*
*/
public CRMMessage.DataSet.DataSetColumns getDataSetColumns() {
return dataSetColumns;
}
/**
* Sets the value of the dataSetColumns property.
*
* @param value
* allowed object is
* {@link CRMMessage.DataSet.DataSetColumns }
*
*/
public void setDataSetColumns(CRMMessage.DataSet.DataSetColumns value) {
this.dataSetColumns = value;
}
/**
* Gets the value of the rows property.
*
* @return
* possible object is
* {@link CRMMessage.DataSet.Rows }
*
*/
public CRMMessage.DataSet.Rows getRows() {
return rows;
}
/**
* Sets the value of the rows property.
*
* @param value
* allowed object is
* {@link CRMMessage.DataSet.Rows }
*
*/
public void setRows(CRMMessage.DataSet.Rows value) {
this.rows = 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="DSColumn" maxOccurs="unbounded">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"dsColumn"
})
public static class DataSetColumns {
@XmlElement(name = "DSColumn", required = true)
protected List<CRMMessage.DataSet.DataSetColumns.DSColumn> dsColumn;
/**
* Gets the value of the dsColumn 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 dsColumn property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getDSColumn().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link CRMMessage.DataSet.DataSetColumns.DSColumn }
*
*
*/
public List<CRMMessage.DataSet.DataSetColumns.DSColumn> getDSColumn() {
if (dsColumn == null) {
dsColumn = new ArrayList<CRMMessage.DataSet.DataSetColumns.DSColumn>();
}
return this.dsColumn;
}
/**
* <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">
* <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
public static class DSColumn {
@XmlAttribute(name = "name")
protected String name;
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = 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="Row" maxOccurs="unbounded">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Col" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"row"
})
public static class Rows {
@XmlElement(name = "Row", required = true)
protected List<CRMMessage.DataSet.Rows.Row> row;
/**
* Gets the value of the row 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 row property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getRow().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link CRMMessage.DataSet.Rows.Row }
*
*
*/
public List<CRMMessage.DataSet.Rows.Row> getRow() {
if (row == null) {
row = new ArrayList<CRMMessage.DataSet.Rows.Row>();
}
return this.row;
}
/**
* <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="Col" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"col"
})
public static class Row {
@XmlElement(name = "Col", required = true)
protected List<String> col;
/**
* Gets the value of the col 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 col property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCol().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link String }
*
*
*/
public List<String> getCol() {
if (col == null) {
col = new ArrayList<String>();
}
return this.col;
}
}
}
}
/**
* <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">
* <attribute name="Testsource" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}integer" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
public static class RequestSource {
@XmlAttribute(name = "Testsource")
protected String testsource;
@XmlAttribute(name = "version")
protected BigInteger version;
/**
* Gets the value of the testsource property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTestsource() {
return testsource;
}
/**
* Sets the value of the testsource property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTestsource(String value) {
this.testsource = value;
}
/**
* Gets the value of the version property.
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public BigInteger getVersion() {
return version;
}
/**
* Sets the value of the version property.
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public void setVersion(BigInteger value) {
this.version = value;
}
}
}
这种帮助?