<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
  -->
<xs:schema targetNamespace="https://plc4x.apache.org/schemas/parser-serializer-testsuite.xsd"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="testsuite">
        <xs:complexType>
            <xs:sequence>
                <!-- The name of the testsuite -->
                <xs:element name="name" type="xs:string"/>
                <!-- The protocolName(id) of the protocol -->
                <xs:element name="protocolName" type="xs:string"/>
                <!-- The outputFlavor of the protocol-->
                <xs:element name="outputFlavor" type="xs:string"/>

                <xs:element name="options" minOccurs="0" maxOccurs="1" type="parameterList">
                    <xs:annotation>
                        <xs:documentation>
                            List of options which are specific to execution of test or environment.
                            This might be used ie. to influence test framework lookup strategies.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <!--
                    Each testcase is a set of hexadecimal input and expected output.
                    A test will parse the binary input and compare the parsed result
                    with the expected output. If that matches, it serializes the model
                    back to it's binary representation and then compares the binary
                    output with the original.
                -->
                <xs:element name="testcase" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <!-- The name of the test, as it is output by the test-runner -->
                            <xs:element name="name" type="xs:string"/>
                            <!-- Some optional description of what the test should do -->
                            <xs:element name="description" type="xs:string" minOccurs="0"/>
                            <!-- A hexadecimal representation of the input to the parser -->
                            <xs:element name="raw" type="xs:hexBinary"/>
                            <!-- The root type we should use for serializing and parsing -->
                            <xs:element name="root-type" type="xs:string"/>
                            <!-- If the root type need additional arguments for parsing, provide them here -->
                            <xs:element name="parser-arguments" minOccurs="0" maxOccurs="1">
                                <xs:complexType>
                                    <xs:sequence minOccurs="1" maxOccurs="unbounded">
                                        <xs:any processContents="lax" namespace="##local"/>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                            <!-- An Xml serialized representation of the expected model -->
                            <xs:element name="xml" type="xs:anyType"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:attribute name="byteOrder" type="byteOrder"/>
        </xs:complexType>
    </xs:element>

    <xs:complexType name="parameterList">
        <xs:sequence minOccurs="1" maxOccurs="unbounded">
            <xs:element name="parameter">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="name" type="xs:string" />
                        <xs:element name="value" type="xs:string" minOccurs="0" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="byteOrder" final="restriction">
        <xs:restriction base="xs:string">
            <xs:enumeration value="BIG_ENDIAN"/>
            <xs:enumeration value="LITTLE_ENDIAN"/>
        </xs:restriction>
    </xs:simpleType>

</xs:schema>