Extend xsd complexType with elements - java

Is it possible to create the extended xsd with xslt. I get an xsd from another part and want to add some elements to the xsd but I cant get it to work. Is xslt the way to go or are there some better tools?
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.3.19">
<xs:element name="Message">
<xs:annotation>
<xs:documentation>Root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice>
<xs:element ref="addAddress"/>
<xs:element ref="addAddressResponse"/>
<xs:element ref="addEmailAddress"/>
<xs:element ref="addEmailAddressResponse"/>
</xs:choice>
</xs:element>
</xs:schema>
Extended:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.3.19">
<xs:element name="Message">
<xs:annotation>
<xs:documentation>Root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<!-- Extended field -->
<xs:element name="generalResponse" minOccurs="0">
<xs:annotation>
<xs:documentation>This response </xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="plainText" type="xs:string" minOccurs="0"/>
<xs:element name="invalidParameters" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="parameter" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="errorType" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:choice>
<xs:element ref="addAddress"/>
<xs:element ref="addAddressResponse"/>
<xs:element ref="addEmailAddress"/>
<xs:element ref="addEmailAddressResponse"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

I solved it with this.
<xsl:template match="node() | #*">
<xsl:copy>
<xsl:apply-templates select="node()|#*" />
</xsl:copy>
</xsl:template>
<xsl:template match="xs:element[#name='Message']/xs:complexType">
<xsl:copy>
<xs:sequence>
<!-- Extended field -->
<xs:element name="generalResponse" minOccurs="0">
<xs:annotation>
<xs:documentation>This response</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="plainText" type="xs:string" minOccurs="0" />
<xs:element name="invalidParameters" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="parameter" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="errorType" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xsl:apply-templates select="node()" />
</xs:sequence>
</xsl:copy>
</xsl:template>

Related

XSD to java beans

I am new to XSDs format. I am trying to convert one xsd to java bean using xjc.But on converting I am getting multiple beans rather than getting just one bean.How to obtain one single bean from the XSD?
Below is my xsd.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="TradeMessage" type="TradeMessageType"/>
<xs:simpleType name="empty-string">
<xs:restriction base="xs:string">
<xs:enumeration value="" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="decimal-or-empty">
<xs:union memberTypes="xs:decimal empty-string" />
</xs:simpleType>
<xs:complexType name="contractingEntityType">
<xs:sequence>
<xs:element type="tradingAccountType" name="tradingAccount"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="executingEntityType">
<xs:sequence>
<xs:element type="tradingAccountType" name="tradingAccount"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tradeFeesType">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element type="tradeFees_itemType" name="tradeFees_item"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="settlementCurrencyType">
<xs:sequence>
<xs:element type="xs:string" name="iSOCode"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tradingAccountType">
<xs:sequence>
<xs:element type="xs:string" name="uniqueID"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="currencyType">
<xs:sequence>
<xs:element type="xs:string" name="iSOCode"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tradingInstrumentType">
<xs:sequence>
<xs:element type="xs:string" name="CUSIP"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tradeFees_itemType">
<xs:sequence>
<xs:element type="chargeCodeType" name="chargeCode"/>
<xs:element type="xs:string" name="inConsideration"/>
<xs:element type="currencyType" name="currency"/>
<xs:element type="xs:decimal" name="currencyValue"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="IncomingTradeMessageType">
<xs:sequence>
<xs:element type="IncomingTradeType" name="IncomingTrade"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TradeMessageType">
<xs:sequence>
<xs:element type="IncomingTradeMessageType" name="IncomingTradeMessage"/>
</xs:sequence>
<xs:attribute type="xs:string" name="schemaVersion"/>
</xs:complexType>
<xs:complexType name="chargeCodeType">
<xs:sequence>
<xs:element type="xs:string" name="name"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="theirTradingAccountType">
<xs:sequence>
<xs:element type="xs:string" name="uniqueID"/>
<xs:element type="xs:string" name="organisationUniqueID"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tradeCurrencyType">
<xs:sequence>
<xs:element type="xs:string" name="iSOCode"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="transactionTypeType">
<xs:sequence>
<xs:element type="xs:string" name="uniqueID"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="channelType">
<xs:sequence>
<xs:element type="xs:string" name="name"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="IncomingTradeType">
<xs:sequence>
<xs:element type="xs:string" name="blockTradeReference"/>
<xs:element type="xs:string" name="sourceReference"/>
<xs:element type="xs:string" name="sourceVersion"/>
<xs:element type="xs:decimal" name="nominal"/>
<xs:element type="xs:decimal" name="price"/>
<xs:element type="xs:string" name="tradeDate"/>
<xs:element type="xs:string" name="valueDate"/>
<xs:element type="transactionTypeType" name="transactionType"/>
<xs:element type="tradingInstrumentType" name="tradingInstrument"/>
<xs:element type="tradeCurrencyType" name="tradeCurrency"/>
<xs:element type="xs:string" name="cancelled"/>
<xs:element type="xs:string" name="tradeTime"/>
<xs:element type="tradeFeesType" name="tradeFees"/>
<xs:element type="xs:decimal" name="grossConsideration"/>
<xs:element type="xs:decimal" name="netConsideration"/>
<xs:element type="xs:decimal" name="settlementConsideration"/>
<xs:element type="settlementCurrencyType" name="settlementCurrency"/>
<xs:element type="decimal-or-empty" name="settlementExRate"/>
<xs:element type="xs:string" name="settlementExRateDirection"/>
<xs:element type="theirTradingAccountType" name="theirTradingAccount"/>
<xs:element type="executingEntityType" name="executingEntity"/>
<xs:element type="contractingEntityType" name="contractingEntity"/>
<xs:element type="decimal-or-empty" name="calculatedNetPrice"/>
<xs:element type="xs:string" name="dealingCapacity"/>
<xs:element type="xs:string" name="agreedPriceIndicator"/>
<xs:element type="xs:string" name="orderReference"/>
<xs:element type="xs:string" name="lastAmendedOnBusinessDate"/>
<xs:element type="xs:string" name="creationAsatDate"/>
<xs:element type="xs:string" name="bpsBranchAccountNumber"/>
<xs:element type="xs:string" name="bpsAccountType"/>
<xs:element type="xs:string" name="shortSell"/>
<xs:element type="decimal-or-empty" name="facilitationPercentage"/>
<xs:element type="xs:string" name="isStepOut"/>
<xs:element type="xs:string" name="stepOutBrokerMPID"/>
<xs:element type="xs:string" name="bargainConditionFO"/>
<xs:element type="channelType" name="channel"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
This XSD is giving me different beans for different properties but actually I would need just one bean comprising of all the properties. As per my requirement I would receive input message (as per above xsd) and convert it directly to java bean and use this bean for further processing. If there is some other better strategy ,kindly let me know.
This is how JAXB works. A complex schema type is mapped to a Java class, and since this schema has many complex types you get several Java classes. When unmarshalling an XML document, you'll get one TradeMessageType instance.

jaxb, xsd substitution complextype

I have the following xsd
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="screen">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"></xs:element>
<xs:element name="controls" type="Controls"></xs:element>
</xs:sequence>
<xs:attribute name="ref" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:complexType name="Controls">
<xs:sequence>
<xs:element name="control" type="Control" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Control" abstract="true">
<xs:sequence>
<xs:element name="name" type="xs:string"></xs:element>
<xs:element name="id" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Button">
<xs:complexContent>
<xs:extension base="Control">
<xs:sequence>
<xs:element name="action" type="xs:string"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="TextField">
<xs:complexContent>
<xs:extension base="Control">
<xs:sequence>
<xs:element name="value" type="xs:string"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
How can I generate the following xml document
<?xml version = "1.0"?>
<screen ref="10_20_25_vwopstellen">
<name>VWOpstellen</name>
<controls>
<button>
<name>btnA</name>
<id>btn_10</id>
<action>click</action>
</button>
<textfield>
<name>fldA</name>
<id>fld_20</id>
</textfield>
</controls>
</screen>
Now it is generating the following xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<screen ref="scrVWOpstellen">
<name>VWOpstellen</name>
<controls>
<control xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Button">
<name>btnA</name>
</control>
<control xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Button">
<name>btnB</name>
</control>
</controls>
</screen>
And when i read my xml document I want a list of contols containing either buttons or textfields
List --> having Button and TextField
I have no idea, i think I should use substitution group but how. I tried something but the xsd is not generating any java code.
thanks
Johan
I'd suggest using an xs:choice, and also defining a target namespace, (http://my.target.namespace in my example), which can make working with JAXB easier in general.
E.g.:
<xs:schema targetNamespace="http://my.target.namespace" xmlns:tns="http://my.target.namespace" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="screen">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"></xs:element>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="button" type="tns:Button" />
<xs:element name="textfield" type="tns:TextField" />
</xs:choice>
</xs:sequence>
<xs:attribute name="ref" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:complexType name="Control" abstract="true">
<xs:sequence>
<xs:element name="name" type="xs:string"></xs:element>
<xs:element name="id" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Button">
<xs:complexContent>
<xs:extension base="tns:Control">
<xs:sequence>
<xs:element name="action" type="xs:string"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="TextField">
<xs:complexContent>
<xs:extension base="tns:Control">
<xs:sequence>
<xs:element name="value" type="xs:string"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Another thought, sometimes the type derivation isn't really worth it. For something like this you might also just do:
E.g.:
<xs:schema targetNamespace="http://my.target.namespace" xmlns:tns="http://my.target.namespace" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="screen">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"></xs:element>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="button" type="tns:Button" />
<xs:element name="textfield" type="tns:TextField" />
</xs:choice>
</xs:sequence>
<xs:attribute name="ref" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:complexType name="Button">
<xs:sequence>
<xs:element name="name" type="xs:string"></xs:element>
<xs:element name="id" type="xs:string"></xs:element>
<xs:element name="action" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TextField">
<xs:sequence>
<xs:element name="name" type="xs:string"></xs:element>
<xs:element name="id" type="xs:string"></xs:element>
<xs:element name="value" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>

Java XML Schema Validation elementFormDefault="qualified"

I have a XSD:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="Structure">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="Tag1"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="Tag2"/>
<xs:element minOccurs="0" ref="Properties"/>
<xs:element minOccurs="0" ref="Tag3"/>
</xs:sequence>
<xs:attribute name="url"/>
</xs:complexType>
</xs:element>
<xs:element name="Tag1">
<xs:complexType>
<xs:attribute name="attr"/>
<xs:attribute name="attr2"/>
</xs:complexType>
</xs:element>
<xs:element name="Tag2">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element minOccurs="0" ref="Object"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="Tag2"/>
</xs:sequence>
<xs:attribute name="filter"/>
</xs:complexType>
</xs:element>
<xs:element name="Object">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="tag35">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:element maxOccurs="unbounded" minOccurs="0" ref="Tag3"/>
</xs:sequence>
<xs:attribute name="attr4"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="attr48"/>
</xs:complexType>
</xs:element>
<xs:element name="element52">
<xs:annotation>
<xs:documentation>Text54</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="el58"/>
</xs:sequence>
<xs:attribute name="vector"/>
</xs:complexType>
</xs:element>
<xs:element name="el66" type="el66Type"/>
<xs:element name="el58">
<xs:complexType mixed="true">
<xs:attribute name="ID" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Tag3">
<xs:complexType>
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element minOccurs="0" name="MetaProperty">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:any/>
</xs:sequence>
<xs:attribute name="name"/>
<xs:attribute name="value"/>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" ref="Property"/>
</xs:sequence>
<xs:attribute name="ID"/>
<xs:attribute name="language" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="Property">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:any minOccurs="0" processContents="skip"/>
</xs:sequence>
<xs:attribute name="name"/>
<xs:attribute name="type"/>
</xs:complexType>
</xs:element>
<xs:element name="Properties">
<xs:complexType>
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element minOccurs="0" ref="Property"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType mixed="true" name="el66Type">
<xs:attribute name="ID" type="xs:string"/>
</xs:complexType>
</xs:schema>
And an xml:
<Structure url="/Test/url">
<Tag1/>
<Tag2>
<Object>
<tag35/>
</Object>
</Tag2>
<Properties>
<Property name="bla" type="value1"/>
<Property name="bla2" type="value2"/>
</Properties>
</Structure>
I am doing a validation, and I am getting the following error:
org.xml.sax.SAXParseException; cvc-complex-type.2.4.a: Invalid content was found starting with element 'Tag2'. One of '{Tag1, Tag2, Tag3}' is expected.
I checked in previous questions and always the solution is related with elementFormDefault="qualified" but now it is not the case so, could it be possible that there is a bug there? Any clue, will be grateful.
Your XML is valid against your XSD as posted in your question.
The error message in your question would not be returned. It must have been from different XML or XSD documents.
As Michael Kay states in the comments:
elementFormDefault only affects local elements declarations.
elementFormDefault only comes into play when the XSD has a targetNamespace.
For more details about elementFormDefault see this answer.

Error in creating classes using JAXB

I'm using JAXB for the first time and trying to create class files using my xsd files but unfortunately getting errors.
This is my xsd :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="DbOperation" type="DbOperation"/>
<xs:complexType name="DbOperation">
<xs:sequence>
<xs:element name="ruleList" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element ref="Rule" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Rule">
<xs:sequence>
<xs:element name="Action" type="xs:string" minOccurs="0"/>
<xs:element name="TableName" type="xs:string" minOccurs="0"/>
<xs:element name="conditionList" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element ref="Conditions" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Conditions">
<xs:sequence>
<xs:element name="Condition" type="Condition" minOccurs="0"/>
<xs:element name="Operator" type="xs:string" minOccurs="0"/>
<xs:element name="Condition" type="Condition" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Condition">
<xs:sequence>
<xs:element name="fieldName" type="xs:string" minOccurs="0"/>
<xs:element name="Operation" type="xs:string" minOccurs="0"/>
<xs:element name="Value" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
And these are the errors I'm getting :
parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'Rule' to a(n) 'element declaration
' component.
line 11 of file:/C:/Documents%20and%20Settings/priyanka.jain/Desktop/JAXB/Rule
.xsd
[ERROR] src-resolve: Cannot resolve the name 'Conditions' to a(n) 'element decla
ration' component.
line 25 of file:/C:/Documents%20and%20Settings/priyanka.jain/Desktop/JAXB/Rule
.xsd
[ERROR] cos-nonambig: Condition and Condition (or elements from their substituti
on group) violate "Unique Particle Attribution". During validation against this
schema, ambiguity would be created for those two particles.
line 32 of file:/C:/Documents%20and%20Settings/priyanka.jain/Desktop/JAXB/Rule
.xsd
Failed to parse a schema.
This is the sample xml for which I've created xsd:
<?xml version="1.0" encoding="UTF-8"?>
<DbOperation>
<Rule>
<Action>Delete</Action>
<TableName>
issue
</TableName>
<Conditions>
<Condition>
<fieldName>
trader
</fieldName>
<Operation>
>=
</Operation>
<Value>
250
</Value>
</Condition>
<Operator>AND</Operator>
<Condition>
<fieldName>
traderName
</fieldName>
<Operation>
=
</Operation>
<Value>
jk
</Value>
</Condition>
</Conditions>
</Rule>
</DbOperation>
Use an XML editor to validate your schema first...
You are referencing a type as if it were an element
<xs:element ref="Conditions" minOccurs="0" maxOccurs="unbounded"/>
<xs:complexType name="Conditions">
<xs:sequence> ....
<xs:element ref="Rule" minOccurs="0" maxOccurs="unbounded"/>
The "REF" attribute indicates that the element and not the type.
Error can be corrected in two ways:
first:
<xs:complexType name="DbOperation">
<xs:sequence>
<xs:element name="ruleList" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Rule" type="Rule" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
second:
<xs:complexType name="DbOperation">
<xs:sequence>
<xs:element name="ruleList" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element ref="Rule" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="Rule" type="Rule"/>

Java jaxb xsd how to allow maxOccurence

I want following xml output and have following xsd
<msgBody>
<Contato>
<cd_id>11</cd_id>
<property key="name" value="Adde" />
<property key="Phone" value="34343" />
<property key="Address" value="address" />
</Contato>
<Contato>
<cd_id>12</cd_id>
<property key="name" value="BJ" />
<property key="Phone" value="7899" />
<property key="Address" value="sdfkjsdfsdf" />
</Contato>
</msgBody>
I have following xsd where i don't know how can i allow to have multiple property tags
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="msgBody">
<xs:complexType>
<xs:sequence>
<xs:element name="Contato" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="cd_id"/>
<xs:element type="property_data_type" name="property"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="property_data_type">
<xs:sequence>
<xs:element type="xs:string" name="key"/>
<xs:element type="xs:string" name="value"/>
</xs:sequence>
Try this
<xs:element name="msgBody">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="Contato"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="contao">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="cd_id"/>
<xs:element maxOccurs="unbounded" ref="propertytype"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="propertytype">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="key"/>
<xs:element type="xs:string" name="value"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Please add maxOccurs.
<xs:element type="property_data_type" name="property" maxOccurs="unbounded"/>
Alternatively, you can put any concrete limit like:
<xs:element type="property_data_type" name="property" maxOccurs="10"/>
It means you can only have a maximum of 10 property elements. The <maxOccurs> indicator specifies the maximum number of times an element can occur.

Categories