I want to define an xsd for a parameter element which will allow me to define the parameter in the following manners
<parameter name="save.type" value="attribute" />
or
<parameter name="payload">
<p:AdderProcessRequest xmlns:p="http://wso2.org/bps/sample">
<!--Exactly 1 occurrence -->
<x xmlns="http://wso2.org/bps/sample">{@xvalue}</x>
<!--Exactly 1 occurrence -->
<y xmlns="http://wso2.org/bps/sample">{@yvalue}</y>
</p:AdderProcessRequest>
</parameter>
In the second approach the xml content within the parameter element is not known beforehand so it can be anything.
The following is the xsd i created but it doesn't seem to work.
<xs:element name="parameter" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="name" use="optional"/>
<xs:attribute type="xs:string" name="value" use="optional"/>
</xs:complexType>
</xs:element>
Any help with this will be much appreciated. Thanks in advance
The "use" property in the XSD definition is used to specify if the attribute is optional or mandatory. To specify that an attribute must be present, use="required" (Note: use may also be set to "prohibited", but we'll come to that later).
The <any> element enables us to extend the XML document with elements not specified by the schema.
The sequence element specifies that the child elements must appear in a sequence. Each child element can occur from 0 to any number of times.
I was able to figure it out after going through the specs posting it here so someone else might need it :). You have to add processContents="skip"
so the content won't be processed.
<xs:element name="parameter" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:any processContents="skip" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="name" use="optional"/>
<xs:attribute type="xs:string" name="value" use="optional"/>
</xs:complexType>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With