XSD for validering av XML for SkdirFodselsMelding

SkdirFodselsMelding.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
	<xs:element name="SkdirFodselsMelding">
		<xs:annotation>
			<xs:documentation>Inneholder definisjonen av hovedelementene i meldingen. Det er en fødselsmelding pr barn.</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:sequence>
				<xs:element name="Meldingsinfo" type="_meldingsinfo"  minOccurs="1" maxOccurs="1"/>
				<xs:element name="Barnet" type="_barnet"  minOccurs="1" maxOccurs="1"/>
				<xs:element name="foreldre" type="_foreldre"  minOccurs="1" maxOccurs="1"/>
				<xs:element name="Signaturinfo" type="_signaturinfo"  minOccurs="1" maxOccurs="1"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<!-- Egne typer ............................................................ -->
	<!-- Meldingsinfo ............ -->
	<xs:complexType name="_meldingsinfo">
		<xs:sequence>
			<xs:annotation>
				<xs:documentation>Generell info om meldingen.</xs:documentation>
			</xs:annotation>
			<xs:element name="referanseDenneMelding" type="_hnummer"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="referanseTidligereMelding" type="xs:string"  minOccurs="0"/>
			<xs:element name="institusjonNummer" type="xs:integer"  minOccurs="0"/>
			<xs:element name="institusjonNavn" type="xs:string"  minOccurs="0"/>
			<xs:element name="institusjonEpost" type="xs:string"  minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
	<!-- Barnet  ............-->
	<xs:complexType name="_barnet">
		<xs:sequence>
			<xs:annotation>
				<xs:documentation>Info om barnet denne meldingen gjelder for</xs:documentation>
			</xs:annotation>
			<xs:element name="fodselsdato" type="xs:date" />
			<xs:element name="pluralitet" minOccurs="1" maxOccurs="1">
				<xs:complexType>
					<xs:sequence>
						<xs:annotation>
							<xs:documentation>Ved flerfødsel, er det viktig å definere riktig rekkefølge på barna i nr feltet og at totalt feltet er likt for alle innenfor denne fødselen</xs:documentation>
						</xs:annotation>
						<xs:element name="enkeltFodsel" type="xs:boolean" minOccurs="1"/>
						<xs:element name="nr" type="xs:integer" minOccurs="0" default="1"/>
						<xs:element name="totalt" type="xs:integer" minOccurs="0" default="1"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="fodested" type="_fodested" />
		</xs:sequence>
		<xs:attribute name="levendeFodt" type="xs:boolean" use="optional" default="true"/>
		<xs:attribute name="kjonn" type="_Kjonn" use="required"/>
	</xs:complexType>
	<!-- Foreldre ............-->
	<xs:complexType name="_foreldre">
		<xs:sequence>
			<xs:element name="Mor" type="_mor"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="Far" type="_far" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="gift" type="xs:boolean" use="required"/>
		<xs:attribute name="samboere" type="xs:boolean" use="optional"/>
	</xs:complexType>
	<!-- Mor ............-->
	<xs:complexType name="_mor">
		<xs:sequence>
			<xs:element name="personalia" type="_personalia"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="adresse" type="_adresse"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="morkommune" type="_kommune" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<!-- Far ............-->
	<xs:complexType name="_far">
		<xs:sequence>
			<xs:element name="personalia" type="_personalia"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="farkommune" type="_kommune" minOccurs="0" maxOccurs="1"/>
			<xs:element name="erkjennelseFarskapBekreftet" type="_farskapserkjennelse" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="_signaturinfo">
		<xs:sequence>
			<xs:element name="signertdato" type="xs:date"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="signertAv" type="_navn"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="signertAvHprNummer" type="_hnummer" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<!-- Personalia ............-->
	<xs:complexType name="_personalia">
		<xs:sequence>
			<xs:element name="fornavn" type="_navn"  minOccurs="1" maxOccurs="1">
			</xs:element>
			<xs:element name="mellomnavn" type="_navn" minOccurs="0" maxOccurs="1"/>
			<xs:element name="slektsnavn" type="_navn"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="fodselsdato" type="xs:date"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="personnr" type="_personnr" minOccurs="0" maxOccurs="1"/>
			<xs:element name="statsborgerskap" type="_statsborgerskap"  minOccurs="1" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<!-- Personnummer ............-->
	<xs:simpleType name="_personnr">
		<xs:restriction base="xs:integer"/>
	</xs:simpleType>
	<!-- farskapserkjennelse............-->
	<xs:complexType name="_farskapserkjennelse">
		<xs:attribute name="erkjent" type="xs:boolean" use="required"/>
	</xs:complexType>	
	<!-- Statsborgerskap ............-->
	<xs:complexType name="_statsborgerskap">
		<xs:sequence>
			<xs:element name="annetStatsborgerskap" type="_landkode" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="norsk" type="xs:boolean" use="required"/>
	</xs:complexType>
	<!-- Kjønn..........-->
	<xs:simpleType name="_Kjonn">
		<xs:annotation>
			<xs:appinfo>
				<attribute name="_Kjonn"/>
				<code value="1" text="Gutt"/>
				<code value="2" text="Jente"/>
				<code value="0" text="Ukjent"/>
			</xs:appinfo>
		</xs:annotation>
		<xs:restriction base="xs:nonNegativeInteger">
			<xs:enumeration value="1"/>
			<xs:enumeration value="2"/>
			<xs:enumeration value="0"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- Fodested ............-->
	<xs:complexType name="_fodested">
		<xs:sequence>
			<xs:element name="fodeinstitusjon" type="_fodeinstitusjon" minOccurs="0" maxOccurs="1"/>
			<xs:element name="fodekommune" type="_kommune"  minOccurs="1" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="utenforInstitusjon" type="xs:boolean" use="required"/>
	</xs:complexType>
	<!-- Fodeinstitusjon ............-->
	<xs:complexType name="_fodeinstitusjon">
		<xs:sequence>
			<xs:element name="institusjonsnr" type="xs:int"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="navn" type="_navn"  minOccurs="1" maxOccurs="1"/>
			<xs:element name="adresse" type="_adresse" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<!-- Adresse ............-->
	<xs:complexType name="_adresse">
		<xs:sequence>
			<xs:element name="veiGateAdresse" type="xs:string" minOccurs="0"/>
			<xs:element name="postnr" type="xs:integer"/>
			<xs:element name="poststed" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
	<!-- kommune ............-->
	<xs:complexType name="_kommune">
		<xs:sequence>
			<xs:element name="navn" type="_navn"  minOccurs="1" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="kommunenr" type="xs:integer" use="required"/>
	</xs:complexType>
	<!-- CountryCode ............-->
	<xs:simpleType name="_landkode">
		<xs:restriction base="xs:string">
			<xs:length value="3"/>
			<xs:pattern value="([A-Z]){3}"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="_navn">
		<xs:restriction base="xs:string">
			<xs:minLength value ="1"/>
			<xs:maxLength value="200"/>
			<xs:pattern value="[a-zA-ZæøåÆØÅÁÀÂÃÄČÇÐÉÈÊËÍÌÎÏÑŊÓÒÔÕÖŠŦÞÚÙÛÜÝŸŽáàâãäçčðđéèêëíìîïñŋóòôößþšŧúùûüýÿž *\-'`´‘’‛′‵]+"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="_gateadresse">
		<xs:restriction base="xs:string">
			<xs:pattern value="[a-zA-ZæøåÆØÅÁÀÂÃÄÇÐÉÈÊËÍÌÎÏÑÓÒÔÕÖÞÚÙÛÜÝŸČĐŊŠŦŽáàâãäçðéèêëíìîïñóòôõößþúùûüýÿčđŋšŧž 0-9_:'`´‘’‛′‵.,()\-/# ]"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="_hnummer">
		<xs:restriction base="xs:string">
			<xs:maxLength value="30"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>