How to define XSD to allow any XML element as child element

While working on a new feature for WSO2 GREG i came across a requirement  to allow any arbitrary XML element to be passed as a child element and i needed to define this in an XSD file. After a bit of searching and some help i was able to find the correct XSD structure for this and thought i might be helpful to share it

<xs:element maxoccurs="unbounded" minoccurs="0" name="parameter">
     <xs:any maxoccurs="unbounded" minoccurs="0" processcontents="skip">
        <xs:attribute name="name" type="xs:string" use="optional">
        <xs:attribute name="value" type="xs:string" use="optional">

The given XSD will allow an XML such as the example given below

<parameter name="payload">
 <p:adderprocessrequest xmlns:p="">
  <!--Exactly 1 occurrence -->
  <x xmlns="">x</x>
  <!--Exactly 1 occurrence -->
  <y xmlns="">y</y>
Hope this is helpful to anyone who needs to to configure an XSD for a similar situation

Popular posts from this blog

How to set up a Apache Spark cluster in your local machine

Writing Unit Tests to test JMS Queue listener code with ActiveMQ

Apache Hadoop MapReduce - Detailed word count example from scratch