0

How can I create all possible XMLs of these XSD:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns="http://beep2000/client/beep.de" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://beep2000/client/beep.de">
    <xsd:complexType name="TextType">
        <xsd:sequence>
            <xsd:element name="Text" minOccurs=1">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="255"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="StreetType">
        <xsd:sequence>
            <xsd:element name="Street" type="xsd:string" minOccurs="1"/>
            <xsd:element name="HouseNumber" type="xsd:int" minOccurs="1"/>
            <xsd:element name="Suffix" type="xsd:string" minOccurs="1">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="1"/>
                        <xsd:enumeration value="A"/>
                        <xsd:enumeration value="B"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="BodyType">
        <xsd:sequence>
            <xsd:element name="FirstPart" type="TextType" minOccurs="1"/>
            <xsd:element name="SecondPart" type="TextType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="AdressType">
        <xsd:sequence>
            <xsd:element name="Street" type="StreetType" minOccurs="0">
            <xsd:element name="PostalCode" minOccurs="0">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="5"/>
                    <xsd:pattern value="[0-9]{5}"/>
                </xsd:restriction>
            </xsd:simpleType>
            <xsd:element name="City" type="xsd:string" minOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="RequestEnvelope">
        <xsd:sequence>
            <xsd:element name="Title" type="xsd:string" minOccurs="0"/>
            <xsd:element name="Forename" type="xsd:string" minOccurs="1"/>
            <xsd:element name="Surname" type="xsd:string" minOccurs="0"/>
            <xsd:element name="PersonalID" minOccurs="0">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="20"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="Adress" type="AdressType" minOccurs="0"/>
            <xsd:element name="Body" type="BodyType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ResponseEnvelope">
        <xsd:sequence>
            <xsd:element name="Result" minOccurs="1">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="3"/>
                        <xsd:enumeration value="OK"/>
                        <xsd:enumeration value="NOK"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="Errorcode" type="xsd:integer" minOccurs="0"/>
            <xsd:element name="Errortext" minOccurs="0">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="255"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="Comment" type="TextType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="MsgResponse" type="ResponseEnvelope"/>
    <xsd:element name="MsgRequest" type="RequestEnvelope"/>
</xsd:schema>

There are some fields which are optional and some field which are mandatory. So there is a variety of XMLs. How can I find all possible structures of XMLs?

I expect something like:

XML No.1:

  • Field 1 --> mandatory
  • Field 2 --> mandatory
  • Field 3 --> optional
  • ......

XML No.2.:

  • Field 1 --> mandatory
  • Field 2 --> mandatory
  • Field 4 --> mandatory
  • .....
mrfsl
  • 65
  • 1
  • 10
  • You are aware, that this are infinitely many? – Henry Mar 05 '18 at 07:44
  • A xsd (schema) is xml format so any xml parsing method will work. The optional fields are the ones with minOccurs=0. – jdweng Mar 05 '18 at 07:47
  • I know that minOccurs = 0 signalises that this field is optional but I what I need is to find a way to find out how to create all possible XML structures ?! – mrfsl Mar 05 '18 at 09:13

1 Answers1

0

Generating all possible XML files that conform to this schema would take an infinite amount of time and they would occupy an infinite amount of space.

However, you can generate a selection of sample documents using tools such as those described here:

How to generate sample XML documents from their DTD or XSD?

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Sorry but this does not help me. Why should it take an infinite amount of time? I do not understand it... – mrfsl Mar 05 '18 at 09:15
  • There's an infinite number of documents that conform to any non-trivial schema, and you said you wanted them all. – Michael Kay Mar 05 '18 at 15:23