<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sefaz.am.gov.br/die" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.sefaz.am.gov.br/die" elementFormDefault="qualified" attributeFormDefault="unqualified">	
	<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/>
	<xs:element name="enviMatrizDIe" type="TEnviMatrizDIe">
		<xs:annotation>
			<xs:documentation>
				Schema XML de validação de Envio da Matriz de Tributação da Declaração de Importação Eletrônica (DI-e)
			</xs:documentation>
		</xs:annotation>
	</xs:element>	
	<xs:complexType name="TEnviMatrizDIe">
		<xs:annotation>
			<xs:documentation> 
				Tipo Pedido de Concessão de Autorização da Declaração de Importação Eletrônica (DI-e)
			</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="MatrizDIe" type="TMatrizDIe" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="versao" type="TVerMatrizDIe" use="required"/>
	</xs:complexType>
	
	<xs:complexType name="TMatrizDIe">
		<xs:sequence>
			<xs:element name="InfMatrizDIe">
				<xs:complexType>
					<xs:sequence>
							<xs:element name="Importador" type="TImportador"/>
							<xs:element name="txJustificativaMatriz" type="TInfoCompl" minOccurs="0" maxOccurs="1"/>
							<xs:element name="ItemMatriz" type="TItemMatriz" maxOccurs="unbounded"/>
						</xs:sequence>
						<xs:attribute name="versao" type="TVerMatrizDIe" use="required"/>
						<xs:attribute name="Id" use="required" >
							<xs:simpleType>
									<xs:restriction base="xs:ID">
									<xs:pattern value="MatrizDIe[0-9]{14}"/>
								</xs:restriction>
							</xs:simpleType>
						</xs:attribute>
					</xs:complexType>
			</xs:element>
			<xs:element ref="ds:Signature"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="TImportador">
		<xs:sequence>
			<xs:element name="tipoImportador" type="TTipoImportador"/>
			<xs:element name="cdImportador" type="TValor14"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="TItemMatriz">
		<xs:sequence>
			<xs:element name="cdNcmProdFinal" type="TNcm"/>
			<xs:element name="cdSuframa" type="TcdSuframa" nillable="true" minOccurs="0000"/>
			<xs:element name="cdDestinacao" type="TDestinacao"/>
			<xs:element name="cdUtilizacao" type="TUtilizacao"/>
			<xs:element name="cdTributacao" type="TCdTributacao"/>
			<xs:element name="numDecreto" type="TValor0"/>
			<xs:element name="tpDocumentoConcessivo" type="TTipoDocumentoConcessivo"/>
			<xs:element name="numDocumentoConcessivo" type="TNumDocumentoConcessivo"/>
			<xs:element name="dtInicioBeneficio" type="TData"/>
			<xs:element name="dtFimBeneficio" type="TData"/>
			<xs:element name="txJustificativaItem" type="TInfoCompl" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<xs:simpleType name="TcdSuframa">
		<xs:annotation>
			<xs:documentation>Codigo SUFRAMA/SEFAZ</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="4"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TNumeroDIe">
		<xs:restriction base="xs:positiveInteger">
			<xs:maxInclusive value="9999999999"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TTipoImportador">
		<xs:annotation>
			<xs:documentation>Tipo do Importador</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:enumeration value="1"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TTipoDocumentoConcessivo">
		<xs:annotation>
			<xs:documentation>Tipo do Documento Concessivo</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:enumeration value="1"/>
			<xs:enumeration value="2"/>
			<xs:enumeration value="3"/>
			<xs:enumeration value="4"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TVerMatrizDIe">
		<xs:annotation>
			<xs:documentation> Tipo Versão da Martiz de Tributação da DI-e - 1.00</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:pattern value="1\.00"/>
		</xs:restriction>
	</xs:simpleType>	
	<xs:simpleType name="TData">
		<xs:annotation>
			<xs:documentation> Tipo data AAAAMMDD</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:pattern value="(((20(([02468][048])|([13579][26]))0229))|(20[0-9][0-9])((((0[1-9])|(1[0-2]))((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))31)|(((0[1,3-9])|(1[0-2]))(29|30)))))"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TValor0">
		<xs:annotation>
			<xs:documentation>Tipo Número dos Valores da DIe</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:nonNegativeInteger"/>
	</xs:simpleType>	
	<xs:simpleType name="TCdTributacao">
		<xs:annotation>
			<xs:documentation>Tipo Código de Tributação</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:enumeration value="N501"/>
			<xs:enumeration value="N502"/>
			<xs:enumeration value="N503"/>
			<xs:enumeration value="N504"/>
			<xs:enumeration value="N505"/>
			<xs:enumeration value="N506"/>
			<xs:enumeration value="N507"/>
			<xs:enumeration value="N508"/>
			<xs:enumeration value="N509"/>
			<xs:enumeration value="N510"/>
			<xs:enumeration value="N511"/>
			<xs:enumeration value="N512"/>
			<xs:enumeration value="N513"/>
			<xs:enumeration value="N514"/>
			<xs:enumeration value="N515"/>
			<xs:enumeration value="N516"/>
			<xs:enumeration value="N517"/>
			<xs:enumeration value="N518"/>
			<xs:enumeration value="N519"/>
			<xs:enumeration value="N520"/>
			<xs:enumeration value="N521"/>
			<xs:enumeration value="N522"/>
			<xs:enumeration value="N523"/>
			<xs:enumeration value="N524"/>
			<xs:enumeration value="N525"/>
			<xs:enumeration value="R502"/>
			<xs:enumeration value="R503"/>
			<xs:enumeration value="R504"/>
			<xs:enumeration value="R505"/>
			<xs:enumeration value="R506"/>
			<xs:enumeration value="R507"/>
			<xs:enumeration value="R508"/>
			<xs:enumeration value="R509"/>
			<xs:enumeration value="R510"/>
			<xs:enumeration value="R511"/>
			<xs:enumeration value="S501"/>
			<xs:enumeration value="S502"/>
			<xs:enumeration value="S503"/>
			<xs:enumeration value="S504"/>
			<xs:enumeration value="S505"/>
			<xs:enumeration value="S506"/>
			<xs:enumeration value="S507"/>
			<xs:enumeration value="S508"/>
			<xs:enumeration value="S509"/>
			<xs:enumeration value="S510"/>
			<xs:enumeration value="S511"/>
			<xs:enumeration value="S512"/>
			<xs:enumeration value="S513"/>
			<xs:enumeration value="S514"/>
			<xs:enumeration value="S515"/>
			<xs:enumeration value="S516"/>
			<xs:enumeration value="S517"/>
			<xs:enumeration value="S518"/>
			<xs:enumeration value="S519"/>
			<xs:enumeration value="S520"/>
			<xs:enumeration value="S521"/>
			<xs:enumeration value="S522"/>
			<xs:enumeration value="S523"/>
			<xs:enumeration value="S524"/>
			<xs:enumeration value="S525"/>
			<xs:enumeration value="S526"/>
			<xs:enumeration value="S527"/>
			<xs:enumeration value="S528"/>
			<xs:enumeration value="S530"/>
			<xs:enumeration value="S531"/>
			<xs:enumeration value="S532"/>
			<xs:enumeration value="S533"/>
			<xs:enumeration value="S534"/>
			<xs:enumeration value="S535"/>
			<xs:enumeration value="S536"/>
			<xs:enumeration value="S538"/>
			<xs:enumeration value="S539"/>
			<xs:enumeration value="S540"/>
			<xs:enumeration value="S541"/>
			<xs:enumeration value="S542"/>
			<xs:enumeration value="T501"/>
			<xs:enumeration value="T502"/>
			<xs:enumeration value="T503"/>
			<xs:enumeration value="T504"/>
			<xs:enumeration value="T505"/>
			<xs:enumeration value="T506"/>
			<xs:enumeration value="T507"/>
			<xs:enumeration value="T508"/>
			<xs:enumeration value="T509"/>
			<xs:enumeration value="T510"/>
			<xs:enumeration value="T511"/>
			<xs:enumeration value="T512"/>
			<xs:enumeration value="T513"/>
			<xs:enumeration value="T514"/>
			<xs:enumeration value="T515"/>
			<xs:enumeration value="T516"/>
		</xs:restriction>
	</xs:simpleType>	
	<xs:simpleType name="TDestinacao">
		<xs:annotation>
			<xs:documentation>Tipo da Destinação da Adiçao da DI-e</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:enumeration value="01"/>
			<xs:enumeration value="02"/>
			<xs:enumeration value="03"/>
			<xs:enumeration value="04"/>
			<xs:enumeration value="05"/>
			<xs:enumeration value="06"/>
			<xs:enumeration value="07"/>
			<xs:enumeration value="08"/>
			<xs:enumeration value="09"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TUtilizacao">
		<xs:annotation>
			<xs:documentation>Tipo da Utilizacao da Adiçao da DI-e</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:enumeration value="00"/>
			<xs:enumeration value="01"/>
			<xs:enumeration value="02"/>
			<xs:enumeration value="03"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TNumDocumentoConcessivo">
		<xs:annotation>
			<xs:documentation>Numero do Documento Concessivo</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:positiveInteger">
			<xs:maxInclusive value="9999999999"/>
		</xs:restriction>
	</xs:simpleType>			
	<xs:simpleType name="TValor14">
		<xs:restriction base="xs:integer">
			<xs:maxInclusive value="99999999999999"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TNcm">
		<xs:restriction base="xs:integer">
			<xs:maxInclusive value="99999999"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TValor4">
		<xs:restriction base="xs:integer">
			<xs:maxInclusive value="9999"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TInfoCompl">
		<xs:annotation>
			<xs:documentation>Informacoes Complementares</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="1000"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>
