<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/XMLCH10Mapping" xmlns:cns="http://www.example.org/XMLCH10Mapping" elementFormDefault="qualified">
<!--
	History:
	Version 0.3.7
	- added 106-22 option to DataTypeVersionType and TMATSDataCh10VersionType
	Version 0.3.6
	- added elements for PCM and Ethernet data type details
	- added NMEA0183 element
	Version 0.3.5: Changes related to IRIG 106-2019
	- added 106-19 option to DataTypeVersionType and TMATSDataCh10VersionType
	Version 0.3.4:
	- made "IncludeFile" option of TMATS packets available everywhere where also raw data can be used (HexBytes etc).
	Version 0.3.3:
	- updated secondaryHeaderTimeDefinition to allow unsignedShort for day definition instead of byte only, to support providing day of year for chapter 4 binary time here (use not covered by chapter 4) 
	Version 0.3.2: Changes related to IRIG 106-2017
	- added 106-17 option to DataTypeVersionType and TMATSDataCh10VersionType
	- corrected ERTC definition to long instead of unsignedLong to allow the already verbally allowed negative signs for relative definition
	- added Network Time packet definitions
	- added IRIG Time Source attribute to Time Packet definition
	- added SeparateTimeStamp tag as option for raw data sections within packets to allow intra packet time stamp generation for packets defined as raw data 
	Version 0.3.1 (version released in "IRIG 106 Chapter 10 Programmers Handbook" (RCC document 123-16) in Appendix P/Q August 2016) and RCC 123-20 Appendix Q/R.
	- for automatic Arinc 429 parity handling changed within ARINC429MessageType:
	  - renamed Data attribute to Raw32
	  - added Raw31 attribute
	  - added GenerateWrongParity attribute
	
	Version 0.3:
	- added IRIG 106-2015 version flags
	- added CAN Bus definition
	
	Version 0.2:
	- renamed all CRC to checksum
	- data CRC now requires 0x prefix
	- Raw time definition in secondary headers
 -->

	<xs:element name="ch10">
		 <xs:complexType>
			<xs:sequence minOccurs="0" maxOccurs="unbounded">
				<xs:choice> 
					<xs:element name="Packet" type="cns:PacketType"/>
					<xs:element name="ChannelDefaults" type="cns:ChannelDefaultsType"/>
					<xs:group ref="cns:RawDataGroup"/>
				</xs:choice>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	

<!-- Packet Header / Trailer -->
	<xs:complexType name="PacketType">
		<xs:sequence minOccurs="0">
			<xs:element name="SecondaryHeader" type="cns:SecondaryHeaderType" minOccurs="0"/>
			<xs:choice minOccurs="0">
				<xs:group ref="cns:InsidePacketRawDataGroup" minOccurs="0" maxOccurs="unbounded" />
				<xs:element name="UARTData" type="cns:UARTDataType"/>
				<xs:element name="Mil1553Data" type="cns:Mil1553DataType"/>
				<xs:element name="ARINC429Data" type="cns:ARINC429DataType"/>
				<xs:element name="CANBusData" type="cns:CANBusDataType"/>
				<xs:element name="TMATSData" type="cns:TMATSDataType"/>
				<xs:element name="TimeData" type="cns:TimeDataType"/>
				<xs:element name="NetworkTimeData" type="cns:NetworkTimeDataType"/>
				<xs:element name="EthernetData" type="cns:EthernetDataType"/>
				<xs:element name="PCMData" type="cns:PCMDataType"/>
			</xs:choice>
		</xs:sequence>
		
		<!-- Header -->
		<xs:attribute name="ChannelID" type="cns:U16HexDec" use="required"/>
		<xs:attribute name="RTC" type="cns:PacketRTCType" use="required"/>
		
		<xs:attribute name="PacketSyncPattern" type="cns:U16HexDec"/>
		<xs:attribute name="PacketLength" type="cns:RelativeU32HexDec">
			<xs:annotation><xs:documentation>If this attribute is not used, the proper length is calculated. If it contains an unsigned number this is used as a fixed value. Any signed numbers (including positive sign) will be used to manipulate the proper length calculation. The number itself can start with 0x for hex values</xs:documentation></xs:annotation>
		</xs:attribute>
		<xs:attribute name="DataLength" type="cns:RelativeU32HexDec">
			<xs:annotation><xs:documentation>If this attribute is not used, the proper length is calculated. If it contains an unsigned number this is used as a fixed value. Any signed numbers (including positive sign) will be used to manipulate the proper length calculation. The number itself can start with 0x for hex values</xs:documentation></xs:annotation>
		</xs:attribute>
	
		<xs:attributeGroup ref="cns:dataTypeVersionDefinition"/>
		
		<xs:attribute name="SequenceNumber" type="cns:RelativeU8HexDec">
			<xs:annotation><xs:documentation>If this attribute is not used, the proper sequence number is calculated. If it contains an unsigned number this is used as a fixed value. Any signed numbers (including positive sign) will be used to manipulate the proper sequence calculation. The number itself can start with 0x for hex values</xs:documentation></xs:annotation>
		</xs:attribute>
		
		<xs:attributeGroup ref="cns:packetFlagsDefinition"/>
		<xs:attributeGroup ref="cns:dataTypeDefinition"/>
		
		<xs:attribute name="HeaderChecksum" type="cns:RelativeU16HexDec">
			<xs:annotation><xs:documentation>if absent automatic, otherwise the hex value is used as checksum. If there is a sign in front (+/-) it is used as an offset to the calculated checksum. The number itself can start with 0x for hex values</xs:documentation></xs:annotation>
		</xs:attribute>
		
		<!-- Trailer -->
		<xs:attribute name="Filler" type="cns:HexBytesType">
			<xs:annotation><xs:documentation>if absent automatic, otherwise adds as many bytes as hex values are available</xs:documentation></xs:annotation>
		</xs:attribute>

		<xs:attribute name="DataChecksum" type="cns:ChecksumType">
			<xs:annotation><xs:documentation>if absent automatic, otherwise adds as many bytes as hex values are available (add leading 0 to identify number of bytes). The data will be added in little endian order. values with a sign are interpreted as offset for the automatic calculation and will use the number of bytes defined in the packet flags</xs:documentation></xs:annotation>
		</xs:attribute>
	</xs:complexType>
	
	<xs:simpleType name="ChecksumType">
		<xs:restriction base="xs:string">
			<xs:pattern value="[\+\-]?(([0-9]+)|(0x[0-9a-fA-F]+))"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="PacketRTCType">
		<xs:annotation>
			<xs:documentation>
				Absolute or relative RTC values. Absolute values are simple unsigned integers. Values starting with p are relative to the last packet, values starting with c are relative to previous packet on same channel. The second character must then be a sign to indicate the direction of the following offset. Relative and absolute values can start with 0x right before the first digit to indicate hex values
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="((c\+)|(c\-)|(p\+)|(p\-))?(([0-9]{1,15})|(0x[0-9a-fA-F]{1,12}))"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="DataTypeType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="UART Format 0"/>
			<xs:enumeration value="1553 Format 1"/>
			<xs:enumeration value="ARINC-429 Format 0"/>
			<xs:enumeration value="Time Format 1"/>
			<xs:enumeration value="Time Format 2"/>
			<xs:enumeration value="TMATS"/>
			<xs:enumeration value="CAN Bus"/>
			<xs:enumeration value="Ethernet Format 0"/>
			<xs:enumeration value="PCM Format 1"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="DataTypeVersionType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="106-04"/>
			<xs:enumeration value="106-05"/>
			<xs:enumeration value="106-07"/>
			<xs:enumeration value="106-09"/>
			<xs:enumeration value="106-11"/>
			<xs:enumeration value="106-13"/>
			<xs:enumeration value="106-15"/>
			<xs:enumeration value="106-17"/>
			<xs:enumeration value="106-19"/>
			<xs:enumeration value="106-22"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="SecondaryHeaderTimeFormatType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Chapter 4 Binary"/>
			<xs:enumeration value="IEEE 1588"/>
			<xs:enumeration value="ERTC"/>
			<xs:enumeration value="Reserved"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="ChecksumTypeType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Checksum0"/>
			<xs:enumeration value="Checksum8"/>
			<xs:enumeration value="Checksum16"/>
			<xs:enumeration value="Checksum32"/>
		</xs:restriction>
	</xs:simpleType>
	

<!-- Secondary headers -->
	<xs:complexType name="SecondaryHeaderType">
		<xs:attributeGroup ref="cns:secondaryHeaderTimeDefinition"/>
		<xs:attribute name="Filler" type="cns:HexBytesType"/>
		<xs:attribute name="Checksum" type="cns:RelativeU16HexDec"/>
	</xs:complexType>

<!-- Channel defaults -->
	<xs:complexType name="ChannelDefaultsType">
		<xs:attribute name="ChannelID" type="cns:U16HexDec" use="required"/>
		<xs:attributeGroup ref="cns:packetFlagsDefinition"/>
		<xs:attributeGroup ref="cns:dataTypeDefinition"/>
		<xs:attributeGroup ref="cns:dataTypeVersionDefinition"/>
	</xs:complexType>	


<!-- Time packets -->
	<xs:complexType name="TimeDataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:choice>
				<xs:element name="TimeDataRelativeContent" type="cns:TimeDataRelativeContentType" />
				<xs:element name="TimeDataContent" type="cns:TimeDataContentType" />
				<xs:group ref="cns:InsidePacketRawDataGroup" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="MonthYearAvailable" type="cns:TrueType" />
		<xs:attribute name="LeapYear" type="cns:TrueType" />
		<xs:attribute name="TimeFormat" type="cns:TimeDataTimeFormatType" />
		<xs:attribute name="TimeSource" type="cns:TimeDataTimeSourceType" />
		<xs:attribute name="IRIGTimeSource" type="cns:TimeDataIRIGTimeSourceType" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>
	
	<xs:complexType name="NetworkTimeDataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:choice>
				<xs:element name="TimeDataRelativeContent" type="cns:NetworkTimeDataRelativeContentType" />
				<xs:element name="TimeDataContent" type="cns:TimeDataContentType" />
				<xs:group ref="cns:InsidePacketRawDataGroup" />
			</xs:choice>
		</xs:sequence>		
		<xs:attribute name="TimeFormat" type="cns:NetworkTimeDataTimeFormatType" />
		<xs:attribute name="TimeStatus" type="cns:NetworkTimeDataTimeStatusType" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>

	<xs:complexType name="TimeDataContentType">
		<xs:attribute name="nsec" type="xs:unsignedShort" use="optional">
			<xs:annotation>
				<xs:documentation>
					The nanoseconds are only used by the network time packets
				 </xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="usec" type="xs:unsignedShort" use="optional">
			<xs:annotation>
				<xs:documentation>
					The microseconds are only used by the network time packets
				 </xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="msec" type="xs:unsignedShort" use="optional" />
		<xs:attribute name="sec" type="xs:unsignedByte" use="required" />
		<xs:attribute name="min" type="xs:unsignedByte" use="required" />
		<xs:attribute name="hrs" type="xs:unsignedByte" use="required" />
		<xs:attribute name="day" type="xs:unsignedShort" use="required" />
		<xs:attribute name="mth" type="xs:unsignedByte" use="optional" />
		<xs:attribute name="year" type="xs:unsignedShort" use="optional" />
	</xs:complexType>

	<xs:complexType name="TimeDataRelativeContentType">
		<xs:attribute name="OffsetMs" type="xs:long" use="required">
			<xs:annotation>
				<xs:documentation>
					Offset to last properly defined time packet on same channel in milliseconds.
				 	This may wrap the year respecting the LeapYear attribute definition or CSDW flag of the last properly defined time packet
				 	on the same channel. Even if the year is wrapping the leap year attribute shall not be altered for this packet but use defined state.
				 </xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	
	<xs:complexType name="NetworkTimeDataRelativeContentType">
		<xs:attribute name="OffsetNs" type="xs:long" use="required">
			<xs:annotation>
				<xs:documentation>
					Offset to last properly defined network time packet on same channel in nanoseconds.				 	
				 </xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:simpleType name="TimeDataTimeFormatType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="IRIG B" />
			<xs:enumeration value="IRIG A" />
			<xs:enumeration value="IRIG G" />
			<xs:enumeration value="Internal" />
			<xs:enumeration value="UTC Time From GPS" />
			<xs:enumeration value="Native GPS Time" />
			<xs:enumeration value="None" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="TimeDataTimeSourceType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Internal" />
			<xs:enumeration value="External" />
			<xs:enumeration value="Internal From RMM" />
			<xs:enumeration value="None" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="TimeDataIRIGTimeSourceType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="IRIG TCG freewheeling" />
			<xs:enumeration value="IRIG TCG freewheeling from .TIME command" />
			<xs:enumeration value="IRIG TCG freewheeling from RMM time" />
			<xs:enumeration value="IRIG TCG locked to external IRIG time signal" />
			<xs:enumeration value="IRIG TCG locked to external GPS" />
			<xs:enumeration value="IRIG TCG locked to external NTP" />
			<xs:enumeration value="IRIG TCG locked to external PTP" />
			<xs:enumeration value="IRIG TCG locked to external embedded time from input" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="NetworkTimeDataTimeFormatType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="NTP V3" />
			<xs:enumeration value="IEEE-1588-2002" />
			<xs:enumeration value="IEEE-1588-2008" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="NetworkTimeDataTimeStatusType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Time Not Valid" />
			<xs:enumeration value="Time Valid" />			
		</xs:restriction>
	</xs:simpleType>

	<!-- TMATS packets -->
	<xs:complexType name="TMATSDataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:group ref="cns:InsidePacketRawDataGroup" />			
		</xs:sequence>
		<xs:attribute name="XML" type="cns:TrueType" />
		<xs:attribute name="ConfigChange" type="cns:TrueType" />
		<xs:attribute name="Ch10Version" type="cns:TMATSDataCh10VersionType" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>

	<xs:simpleType name="TMATSDataCh10VersionType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="106-07" />
			<xs:enumeration value="106-09" />
			<xs:enumeration value="106-11" />
			<xs:enumeration value="106-13" />
			<xs:enumeration value="106-15" />
			<xs:enumeration value="106-17" />
			<xs:enumeration value="106-19" />
			<xs:enumeration value="106-22" />
		</xs:restriction>
	</xs:simpleType>


<!-- CANBus Packets -->
	<xs:complexType name="CANBusDataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:choice>
				<xs:element name="CANBusMessage" type="cns:CANBusMessageType" />
				<xs:group ref="cns:InsidePacketRawDataGroup" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="MessageCount" type="cns:RelativeU24HexDec" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>
	
	<xs:complexType name="CANBusMessageType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:group ref="cns:InsidePacketRawDataGroup" />
		</xs:sequence>

		<xs:attribute name="RTC" type="cns:RelativeU64HexDec">
			<xs:annotation>
				<xs:documentation>This is used as a 64 bit RTC value, i.e. the first
					16 bits are normally filled with 0. If RTC attribute is used, it
					shall take precedence over date/time. If this has a sign (+/-),
					then this is interpreted relative to the packet RTC
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>

		<xs:attributeGroup ref="cns:secondaryHeaderTimeDefinition" />
		
		<xs:attribute name="IPMessageHeader" type="cns:U32HexDec" />
		<xs:attribute name="IPIDWord" type="cns:U32HexDecNone" />
		<xs:attribute name="DataError" type="cns:TrueType" />
		<xs:attribute name="FormatError" type="cns:TrueType" />
		<xs:attribute name="ExtendedIdentifier" type="cns:TrueType" />
		<xs:attribute name="RemoteTransferRequest" type="cns:TrueType" />
		<xs:attribute name="CANBusID" type="cns:U32HexDec" />
		<xs:attribute name="Subchannel" type="cns:U8HexDec" />
		<xs:attribute name="LengthBytes" type="cns:RelativeU8HexDec" >
		<xs:annotation>
				<xs:documentation>
					The length attribute includes the 4 bytes of the Intra packet ID word per CH10.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	
	<!-- PCM Packets -->
	<xs:complexType name="PCMDataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:choice>
				<xs:element name="PCMNonThroughputFrameIPH" type="cns:PCMNonThroughputFrameIPHType" />
				<xs:group ref="cns:InsidePacketRawDataGroup" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="IPH" type="cns:TrueType" />
		<xs:attribute name="MajorFrameIndicator" type="cns:TrueType" />
		<xs:attribute name="MinorFrameIndicator" type="cns:TrueType" />
		<xs:attribute name="MajorFrameLockStatus" type="cns:PCMMajorFrameLockStatusType" />
		<xs:attribute name="MinorFrameLockStatus" type="cns:PCMMinorFrameLockStatusType" />
		<xs:attribute name="AlignmentMode" type="cns:PCMAlignmentModeType" />
		<xs:attribute name="ThroughputMode" type="cns:TrueType" />
		<xs:attribute name="PackedMode" type="cns:TrueType" />
		<xs:attribute name="UnpackedMode" type="cns:TrueType" />
		<xs:attribute name="SyncOffset" type="xs:unsignedInt" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>
	
	<xs:simpleType name="PCMAlignmentModeType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="16-bit" />
			<xs:enumeration value="32-bit" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="PCMMajorFrameLockStatusType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Major frame not locked" />
			<xs:enumeration value="Major frame check" />
			<xs:enumeration value="Major frame lock" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="PCMMinorFrameLockStatusType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Minor frame check" />
			<xs:enumeration value="Minor frame lock" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:complexType name="PCMNonThroughputFrameIPHType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:group ref="cns:InsidePacketRawDataGroup" />
		</xs:sequence>
		
		<xs:attribute name="RTC" type="cns:RelativeU64HexDec">
			<xs:annotation>
				<xs:documentation>This is used as a 64 bit RTC value, i.e. the first
					16 bits are normally filled with 0. If RTC attribute is used, it
					shall take precedence over date/time. If this has a sign (+/-),
					then this is interpreted relative to the packet RTC
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>

		<xs:attributeGroup ref="cns:secondaryHeaderTimeDefinition" />
		
		<xs:attribute name="IPDH" type="cns:U32HexDec">
			<xs:annotation>
				<xs:documentation>This is the raw intra packet data header.
				Explicit definition of the lock status will take precedence over the related bits.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>	
		
		<xs:attribute name="MajorFrameLockStatus" type="cns:PCMMajorFrameLockStatusType" />
		<xs:attribute name="MinorFrameLockStatus" type="cns:PCMMinorFrameLockStatusType" />
	</xs:complexType>
	
	
	<!-- Ethernet Packets -->
	<xs:complexType name="EthernetDataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:choice>
				<xs:element name="EthernetFrame" type="cns:EthernetFrameType" />
				<xs:group ref="cns:InsidePacketRawDataGroup" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="FrameCount" type="cns:RelativeU16HexDec" />
		<xs:attribute name="TimeTagBits" type="cns:EthernetTimeTagBitsType" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>
	
	<xs:complexType name="EthernetFrameType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:group ref="cns:InsidePacketRawDataGroup" />
		</xs:sequence>
		
		<xs:attribute name="RTC" type="cns:RelativeU64HexDec">
			<xs:annotation>
				<xs:documentation>This is used as a 64 bit RTC value, i.e. the first
					16 bits are normally filled with 0. If RTC attribute is used, it
					shall take precedence over date/time. If this has a sign (+/-),
					then this is interpreted relative to the packet RTC
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>

		<xs:attributeGroup ref="cns:secondaryHeaderTimeDefinition" />
		
		<xs:attribute name="FrameIDWord" type="cns:U32HexDec" />
				
		<xs:attribute name="FrameCRCError" type="cns:TrueType" />
		<xs:attribute name="FrameError" type="cns:TrueType" />
		<xs:attribute name="DataCRCError" type="cns:TrueType" />
		<xs:attribute name="DataLengthError" type="cns:TrueType" />
		<xs:attribute name="LengthBytes" type="cns:RelativeU16HexDec" />
		<xs:attribute name="NetworkID" type="cns:U8HexDec" />
		<xs:attribute name="CapturedDataContent" type="cns:EthernetContentType" />
		<xs:attribute name="EthernetSpeed" type="cns:EthernetSpeedType" />
	</xs:complexType>
	
	<xs:simpleType name="EthernetTimeTagBitsType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="First bit of MAC frame" />
			<xs:enumeration value="Last bit of MAC frame" />
			<xs:enumeration value="First bit of MAC frame payload" />
			<xs:enumeration value="Last bit of MAC frame payload" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="EthernetContentType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Full MAC frame" />
			<xs:enumeration value="Payload only" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="EthernetSpeedType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Auto" />
			<xs:enumeration value="10 Mbps" />
			<xs:enumeration value="100 Mbps" />
			<xs:enumeration value="1 Gbps" />
			<xs:enumeration value="10 Gbps" />
		</xs:restriction>
	</xs:simpleType>
	
	

	<!-- Mil1553 Packets -->
	<xs:complexType name="Mil1553DataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:choice>
				<xs:element name="Mil1553Message" type="cns:Mil1553MessageType" />
				<xs:group ref="cns:InsidePacketRawDataGroup" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="MessageCount" type="cns:RelativeU24HexDec" />
		<xs:attribute name="TimeTagBits" type="cns:Mil1553TimeTagBitsType" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>

	<xs:complexType name="Mil1553MessageType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:group ref="cns:InsidePacketRawDataGroup" />
		</xs:sequence>
		
		<xs:attribute name="RTC" type="cns:RelativeU64HexDec">
			<xs:annotation>
				<xs:documentation>This is used as a 64 bit RTC value, i.e. the first
					16 bits are normally filled with 0. If RTC attribute is used, it
					shall take precedence over date/time. If this has a sign (+/-),
					then this is interpreted relative to the packet RTC
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>

		<xs:attributeGroup ref="cns:secondaryHeaderTimeDefinition" />

		<xs:attribute name="BlockStatusWord" type="cns:U16HexDec" />
		<xs:attribute name="BusB" type="cns:TrueType" />
		<xs:attribute name="MessageError" type="cns:TrueType" />
		<xs:attribute name="RTRTTransfer" type="cns:TrueType" />
		<xs:attribute name="FormatError" type="cns:TrueType" />
		<xs:attribute name="ResponseTimeOut" type="cns:TrueType" />
		<xs:attribute name="WordCountError" type="cns:TrueType" />
		<xs:attribute name="SyncTypeError" type="cns:TrueType" />
		<xs:attribute name="InvalidWordError" type="cns:TrueType" />
		<xs:attribute name="GapTime1" type="cns:U8HexDec" />
		<xs:attribute name="GapTime2" type="cns:U8HexDec" />
		<xs:attribute name="LengthBytes" type="cns:RelativeU16HexDec" />
	</xs:complexType>

	<xs:simpleType name="Mil1553TimeTagBitsType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Last Bit Of Last Word" />
			<xs:enumeration value="First Bit Of First Word" />
			<xs:enumeration value="Last Bit Of First Command" />
		</xs:restriction>
	</xs:simpleType>


	<!-- ARINC429 Packets -->
	<xs:complexType name="ARINC429DataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:choice>
				<xs:element name="ARINC429Message" type="cns:ARINC429MessageType" />
				<xs:group ref="cns:InsidePacketRawDataGroup" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="MessageCount" type="cns:RelativeU16HexDec" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>

	<xs:complexType name="ARINC429MessageType">
		<xs:attribute name="IPDH" type="cns:U32HexDec" />
		<xs:attribute name="Subchannel" type="cns:U8HexDec" />
		<xs:attribute name="FormatError" type="cns:TrueType" />
		<xs:attribute name="ParityError" type="cns:TrueType" />
		<xs:attribute name="HighSpeed" type="cns:TrueType" />
		<xs:attribute name="GapTime" type="xs:unsignedInt" />
		<xs:attribute name="Raw32" type="cns:U32HexDec">
			<xs:annotation>
				<xs:documentation>The raw bits including the parity.
					If the Raw31 attribute is given, Raw32 shall be ignored.
					The state of the ParityError flag is not influenced. 
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Raw31" type="cns:U32HexDec">
			<xs:annotation>
				<xs:documentation>The raw bits excluding the parity.
					The parity bit for the raw bits is generated automatically to be correct unless the GenerateWrongParity attribute is set in which case the parity bit is generated incorrect.
					If the Raw31 attribute is given, Raw32 shall be ignored.
					The state of the ParityError flag is not influenced.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="GenerateWrongParity" type="cns:TrueType">
			<xs:annotation>
				<xs:documentation>If this is set a wrong parity bit is generated to the raw bits defined by Raw31.
					If not correct parity is generated.
					If Raw31 is not provided, there is no automatic handling of the parity bit.
					The state of the ParityError flag is not influenced.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>	
	


<!-- UART Packets -->
	<xs:complexType name="UARTDataType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:choice>
				<xs:element name="UARTMessage" type="cns:UARTMessageType" />
				<xs:group ref="cns:InsidePacketRawDataGroup" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="IPTS" type="cns:TrueType" />
		<xs:attribute name="CSDW" type="cns:U32HexDec" />
	</xs:complexType>

	<xs:complexType name="UARTMessageType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:group ref="cns:InsidePacketRawDataGroup" />
		</xs:sequence>

		<xs:attribute name="RTC" type="cns:RelativeU64HexDec">
			<xs:annotation>
				<xs:documentation>This is used as a 64 bit RTC value, i.e. the first
					16 bits are normally filled with 0. If RTC attribute is used, it
					shall take precedence over date/time. If this has a sign (+/-),
					then this is interpreted relative to the packet RTC. If neither RawTime not RTC nor date/time is used, the IPH is left out.
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>

		<xs:attributeGroup ref="cns:secondaryHeaderTimeDefinition" />

		<xs:attribute name="IDWord" type="cns:U32HexDec" />
		<xs:attribute name="Subchannel" type="cns:U16HexDec" />
		<xs:attribute name="ParityError" type="cns:TrueType" />
		<xs:attribute name="LengthBytes" type="cns:RelativeU16HexDec" />
		<!--  TODO filler byte corruption settings -->
	</xs:complexType>


	
<!--  common type definitions -->
	<xs:group name="RawDataGroup">
		<xs:choice>
			<xs:element name="HexBytes" type="cns:HexBytesType" />
			<xs:element name="HexWords" type="cns:HexWordsType" />
			<xs:element name="HexLongWords" type="cns:HexLongWordsType" />
			<xs:element name="ASCII" type="cns:ASCIIStringType" />
			<xs:element name="NMEA0183" type="cns:ASCIIStringType">
				<xs:annotation>
					<xs:documentation>Special for NMEA0183 messages (GPS): The content is treated like the ASCII element, except that in the end an asterisk (*) is added
					followed by an automatically generated two character checksum and a carriage return and line feed. It doesn't add the $ or ! prefix.
					</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="IncludeFile" type="xs:string">
				<xs:annotation>
					<xs:documentation>If the filename is relative or has no path at all it should be relative to the XML file
					</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:choice>
	</xs:group>
	
	<xs:group name="InsidePacketRawDataGroup">
		<xs:choice>
			<xs:group ref="cns:RawDataGroup"/>
			<xs:element name="SeparateTimeStamp" type="cns:SeparateTimeReferenceType" />			
		</xs:choice>
	</xs:group>
	
	<xs:complexType name="SeparateTimeReferenceType">
		<xs:annotation><xs:documentation>Creates a 64 bit time stamp as used in Intra Packet Time Stamps. Can refer to the containing packet's RTC.</xs:documentation></xs:annotation>
		<xs:attribute name="RTC" type="cns:RelativeU64HexDec"/><!-- Takes precedence over other definitions. A positive or negative sign can be used to make it relative to the containing packet RTC. -->
		<xs:attributeGroup ref="cns:secondaryHeaderTimeDefinition" />
	</xs:complexType>

	<xs:attributeGroup name="dataTypeDefinition">
		<xs:attribute name="DataTypeRaw" type="cns:U8HexDec"/>
		<xs:attribute name="DataType" type="cns:DataTypeType">
			<xs:annotation><xs:documentation>This takes precedence over data_type_raw.</xs:documentation></xs:annotation>
		</xs:attribute>	
	</xs:attributeGroup>

	<xs:attributeGroup name="dataTypeVersionDefinition">
		<xs:attribute name="DataTypeVersionRaw" type="cns:U8HexDec"/>
		<xs:attribute name="DataTypeVersion" type="cns:DataTypeVersionType">
			<xs:annotation><xs:documentation>This takes precedence over data_type_version_raw.</xs:documentation></xs:annotation>
		</xs:attribute>
	</xs:attributeGroup>	
		
		

	<xs:attributeGroup name="packetFlagsDefinition">
		<xs:attribute name="PacketFlags" type="cns:U8HexDec"/>
		<xs:attribute name="SecondaryHeaderPresent" type="cns:TrueType"/>
		<xs:attribute name="SecondaryHeaderTimeForIntraPacketTime" type="cns:TrueType"/>
		<xs:attribute name="RTCSyncError" type="cns:TrueType"/>
		<xs:attribute name="DataOverflow" type="cns:TrueType"/>
		<xs:attribute name="SecondaryHeaderTimeFormat" type="cns:SecondaryHeaderTimeFormatType"/>
		<xs:attribute name="ChecksumType" type="cns:ChecksumTypeType"/>	
	</xs:attributeGroup>

	<xs:attributeGroup name="secondaryHeaderTimeDefinition">
		<xs:attribute name="nsec" type="xs:unsignedShort" use="optional" />
		<xs:attribute name="usec" type="xs:unsignedShort" use="optional" />
		<xs:attribute name="msec" type="xs:unsignedShort" use="optional" />
		<xs:attribute name="sec" type="xs:unsignedByte" use="optional" />
		<xs:attribute name="min" type="xs:unsignedByte" use="optional" />
		<xs:attribute name="hrs" type="xs:unsignedByte" use="optional" />
		<xs:attribute name="day" type="xs:unsignedShort" use="optional" />
		<xs:attribute name="mth" type="xs:unsignedByte" use="optional">
			<xs:annotation>
				<xs:documentation>If this attribute is used and no ERTC or RawTime, a IEEE-1588 time is created</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="year" type="xs:unsignedShort" use="optional">
			<xs:annotation>
				<xs:documentation>If this attribute is used and no ERTC or RawTime, a IEEE-1588 time is created</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ERTC" type="xs:long">
			<xs:annotation>
				<xs:documentation>If this attribute is used it takes precedence over 
					date/time but not RawTime. Any signed numbers (including positive sign) will be
					relative to the packet RTC (after extending the packet RTC to 1ns
					units). Numbers without sign are treated absolute
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="RawTime" type="cns:U64Hex">
			<xs:annotation>
				<xs:documentation>If this attribute is used it takes precedence over 
					date/time and ERTC. It will place the defined hexadecimal value into the 8 time bytes (little endian)
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:attributeGroup>
	
	
	<xs:simpleType name="ASCIIStringType">
		<xs:annotation>
			<xs:documentation>
				This represents a 7-Bit ASCII encoded string
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			 <xs:pattern value="\p{IsBasicLatin}*"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="HexBytesType">
		<xs:annotation>
			<xs:documentation>
				This type represents a sequence of 8 bit hexadecimal values separated by spaces. The values are stored in this sequence in the CH10 file. The sequence may be empty.
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="([a-fA-F0-9]{2}( [a-fA-F0-9]{2})*)|"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="HexWordsType">
		<xs:annotation>
			<xs:documentation>
				This type represents a sequence of 16 bit hexadecimal values separated by spaces. The values are stored in this sequence in the CH10 file. When storing to the little endian CH10 file each value will be byte reversed. The sequence may be empty.
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="([a-fA-F0-9]{4}( [a-fA-F0-9]{4})*)|"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="HexLongWordsType">
		<xs:annotation>
			<xs:documentation>
				This type represents a sequence of 32 bit hexadecimal values separated by spaces. The values are stored in this sequence in the CH10 file. When storing to the little endian CH10 file each value will be byte reversed. The sequence may be empty.
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="([a-fA-F0-9]{8}( [a-fA-F0-9]{8})*)|"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="TrueType">
		<xs:annotation>
			<xs:documentation>
				This type is used for attributes that just have two states. The false-state is indicated by omitting the attribute at all. 
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			 <xs:enumeration value="True"/>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="NoneType">
		<xs:restriction base="xs:string">
			 <xs:enumeration value="None"/>
		</xs:restriction>
	</xs:simpleType>


	<xs:simpleType name="RelativeU8HexDec">
			<xs:annotation>
			<xs:documentation>
				This type represents a 8 bit unsigned integer that is interpreted hexadecimal if the number is prefixed with 0x and decimal otherwise. The first character is an optional + or - to indicate that the number shall be interpreted relative to something (likely a calculated auto value).
			</xs:documentation>
		</xs:annotation>
	
		<xs:restriction base="xs:string">
			<xs:pattern value="[\+\-]?(([0-9]{1,3})|(0x[a-fA-F0-9]{1,2}))"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="RelativeU16HexDec">
			<xs:annotation>
			<xs:documentation>
				This type represents a 16 bit unsigned integer that is interpreted hexadecimal if the number is prefixed with 0x and decimal otherwise. The first character is an optional + or - to indicate that the number shall be interpreted relative to something (likely a calculated auto value).
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="[\+\-]?(([0-9]{1,5})|(0x[a-fA-F0-9]{1,4}))"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="RelativeU24HexDec">
			<xs:annotation>
			<xs:documentation>
				This type represents a 24 bit unsigned integer that is interpreted hexadecimal if the number is prefixed with 0x and decimal otherwise. The first character is an optional + or - to indicate that the number shall be interpreted relative to something (likely a calculated auto value).
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="[\+\-]?(([0-9]{1,8})|(0x[a-fA-F0-9]{1,6}))"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="RelativeU32HexDec">
		<xs:annotation>
			<xs:documentation>
				This type represents a 32 bit unsigned integer that is interpreted hexadecimal if the number is prefixed with 0x and decimal otherwise. The first character is an optional + or - to indicate that the number shall be interpreted relative to something (likely a calculated auto value).
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="[\+\-]?(([0-9]{1,10})|(0x[a-fA-F0-9]{1,8}))"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="RelativeU64HexDec">
		<xs:annotation>
			<xs:documentation>
				This type represents a 64 bit unsigned integer that is interpreted hexadecimal if the number is prefixed with 0x and decimal otherwise. The first character is an optional + or - to indicate that the number shall be interpreted relative to something (likely a calculated auto value).
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="[\+\-]?(([0-9]{1,20})|(0x[a-fA-F0-9]{1,16}))"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="U8HexDec">
		<xs:annotation>
			<xs:documentation>
				This type represents a 8 bit unsigned integer that is interpreted hexadecimal if it is prefixed with 0x and decimal otherwise.
			</xs:documentation>
		</xs:annotation>
		<xs:union memberTypes="xs:unsignedByte cns:U8Hex" />
	</xs:simpleType>

	<xs:simpleType name="U8Hex">
		<xs:restriction base="xs:string">
			<xs:pattern value="0x[a-fA-F0-9]{1,2}"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
 	<xs:simpleType name="U16HexDec">
		<xs:annotation>
			<xs:documentation>
				This type represents a 16 bit unsigned integer that is interpreted hexadecimal if it is prefixed with 0x and decimal otherwise.
			</xs:documentation>
		</xs:annotation>
		<xs:union memberTypes="xs:unsignedShort cns:U16Hex" />
	</xs:simpleType>
	
	<xs:simpleType name="U16Hex">
		<xs:restriction base="xs:string">
			<xs:pattern value="0x[a-fA-F0-9]{1,4}"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="U32HexDec">
		<xs:annotation>
			<xs:documentation>
				This type represents a 32 bit unsigned integer that is interpreted hexadecimal if it is prefixed with 0x and decimal otherwise.
			</xs:documentation>
		</xs:annotation>
		<xs:union memberTypes="xs:unsignedInt cns:U32Hex" />
	</xs:simpleType>

	<xs:simpleType name="U32Hex">
		<xs:restriction base="xs:string">
			<xs:pattern value="0x[a-fA-F0-9]{1,8}"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="U64HexDec">
		<xs:annotation>
			<xs:documentation>
				This type represents a 64 bit unsigned integer that is interpreted hexadecimal if it is prefixed with 0x and decimal otherwise.
			</xs:documentation>
		</xs:annotation>
		<xs:union memberTypes="xs:unsignedLong cns:U64Hex" />
	</xs:simpleType>

	<xs:simpleType name="U64Hex">
		<xs:restriction base="xs:string">
			<xs:pattern value="0x[a-fA-F0-9]{1,16}"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="U32HexDecNone">
		<xs:annotation>
			<xs:documentation>
				This type allows the definitions like in U32HexDec but adds the additional state "None" that is used to completely leave the 32 bits out
			</xs:documentation>
		</xs:annotation>
		<xs:union memberTypes="cns:NoneType cns:U32HexDec" />
	</xs:simpleType>

</xs:schema>