<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://www.gnre.pe.gov.br"
	xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
	attributeFormDefault="unqualified" elementFormDefault="qualified"
	targetNamespace="http://www.gnre.pe.gov.br"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:v2="http://www.gnre.pe.gov.br/v2">
	<xs:include schemaLocation="dados_gnre_v2.00.xsd" />
	<xs:include schemaLocation="dados_gnre_v1.00.xsd"></xs:include>
	<xs:element name="TRetorno_GNRE">
		<xs:complexType>
			<xs:sequence>
				<xs:element minOccurs="1" name="dados"
					maxOccurs="unbounded">
					<xs:complexType>
						<xs:sequence>
                        <xs:choice>
                        	<xs:sequence>
		    					<xs:group ref="dadosGnre_2.00_1" />
		    					<xs:group ref="dadosGnre_2.00_2_retorno" />
		    					<xs:group ref="dadosGnre_2.00_3" />
                        		<xs:element minOccurs="0"
                        			name="dataLimitePagamento" type="TData">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Data máxima que o banco pode
                        					receber o pagamento, que
                        					estará impressa na guia e no
                        					código de barras.
                        				</xs:documentation>
                        			</xs:annotation>
                        		</xs:element>
                        		<xs:element minOccurs="0"
                        			name="informacoesComplementares">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Informação complementar a
                        					ser impressa na guia.
                        				</xs:documentation>
                        			</xs:annotation>
                        			<xs:complexType>
                        				<xs:sequence>
                        					<xs:element
                        						name="informacao" minOccurs="1"
                        						maxOccurs="3">
                        						<xs:simpleType>
                        							<xs:restriction
                        								base="TString">
                        								<xs:maxLength
                        									value="100" />
                        								<xs:minLength
                        									value="1" />
                        							</xs:restriction>
                        						</xs:simpleType>
                        					</xs:element>
                        				</xs:sequence>
                        			</xs:complexType>
                        			<!-- <xs:simpleType>
                        				<xs:restriction base="TString">
                        				<xs:maxLength value="300" />
                        				</xs:restriction>
                        				</xs:simpleType> -->
                        		</xs:element>
                        		<xs:element minOccurs="0"
                        			name="nossoNumero">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Número interno da guia
                        					gerado pela UF
                        				</xs:documentation>
                        			</xs:annotation>
                        			<xs:simpleType>
                        				<xs:restriction
                        					base="xs:string">
                        					<xs:whiteSpace
                        						value="preserve" />
                        					<xs:pattern
                        						value="[0-9]{16}" />
                        				</xs:restriction>
                        			</xs:simpleType>
                        		</xs:element>
                        		<xs:element name="dadosPagamento"
                        			maxOccurs="1" minOccurs="0">
                        			<xs:complexType>
                        				<xs:sequence>
                        					<xs:element minOccurs="0" name="data" type="TDataHora">
                        						<xs:annotation>
                        							<xs:documentation>Quando for uma validacao, retorna a Data prevista de pagamento informada pelo contribuinte. Quando for uma consulta da guia retorna a Data do pagamento da guia no banco.</xs:documentation>
                        						</xs:annotation>
                        					</xs:element>
                        					<xs:element minOccurs="0" name="autenticacao">
                        						<xs:annotation>
                        							<xs:documentation>Autenticacao bancaria do pagamento da	guia.</xs:documentation>
                        						</xs:annotation>
                        						<xs:simpleType>
                        							<xs:restriction	base="TString">
                        								<xs:maxLength value="23" />
                        							</xs:restriction>
                        						</xs:simpleType>
                        					</xs:element>
                        					<xs:element minOccurs="0" name="banco">
                        						<xs:annotation>
                        							<xs:documentation>Codigo do Banco onde foi paga a guia.</xs:documentation>
                        						</xs:annotation>
                        						<xs:simpleType>
                        							<xs:restriction base="xs:string">
                        								<xs:whiteSpace value="preserve" />
                        								<xs:pattern value="[0-9]{3}" />
                        							</xs:restriction>
                        						</xs:simpleType>
                        					</xs:element>
                        					<xs:element minOccurs="0" name="agencia">
                        						<xs:annotation>
                        							<xs:documentation>Código da Agencia bancaria onde foi paga a guia.</xs:documentation>
                        						</xs:annotation>
                        						<xs:simpleType>
                        							<xs:restriction base="xs:string">
                        								<xs:whiteSpace value="preserve" />
                        								<xs:pattern value="[0-9]{4,5}" />
                        							</xs:restriction>
                        						</xs:simpleType>
                        					</xs:element>
                        					<xs:element minOccurs="0" name="txId" maxOccurs="1">
                        						<xs:annotation>
                        							<xs:documentation>Identificador da transacao PIX.</xs:documentation>
                        						</xs:annotation>
                        						<xs:simpleType>
                        							<xs:restriction
                        								base="xs:string">
                        								<xs:whiteSpace value="collapse" />
                        								<xs:pattern value="[a-zA-Z0-9]{1,35}" />
                        							</xs:restriction>
                        						</xs:simpleType>
                        					</xs:element>
                        					<xs:element minOccurs="0" name="e2eId" maxOccurs="1">
                        						<xs:annotation>
                        							<xs:documentation>Identificador fim a fim da transacao PIX.</xs:documentation>
                        						</xs:annotation>
                        						<xs:simpleType>
                        							<xs:restriction
                        								base="xs:string">
                        								<xs:whiteSpace value="collapse" />
                        								<xs:pattern value="[a-zA-Z0-9]{1,35}" />
                        							</xs:restriction>
                        						</xs:simpleType>
                        					</xs:element>
                        					<xs:element minOccurs="0" name="pspPagador" maxOccurs="1">
                        						<xs:annotation>
                        							<xs:documentation>Raiz do CNPJ da instituicao financeira onde o contribuinte efetuou o pagamento da GNRE.</xs:documentation>
                        						</xs:annotation>
                        						<xs:simpleType>
                        							<xs:restriction
                        								base="xs:string">
                        								<xs:whiteSpace value="collapse" />
                        								<xs:pattern value="[0-9]{8}" />
                        							</xs:restriction>
                        						</xs:simpleType>
                        					</xs:element>
                        				</xs:sequence>
                        			</xs:complexType>
                        		</xs:element>
                        	</xs:sequence>
                        	<xs:sequence>
                        		<xs:group ref="dadosGnre_1.00_1" />
                        		<xs:element minOccurs="0"
                        			name="c07_atualizacaoMonetaria"
                        			type="TDec_1502">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Atualização monetária do
                        					valor original até a data de
                        					pagamento.
                        				</xs:documentation>
                        			</xs:annotation>
                        		</xs:element>
                        		<xs:element minOccurs="0"
                        			name="c08_juros" type="TDec_1502">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Valor de juros sobre o valor
                        					original até a data de
                        					pagamento.
                        				</xs:documentation>
                        			</xs:annotation>
                        		</xs:element>
                        		<xs:element minOccurs="0"
                        			name="c09_multa" type="TDec_1502">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Valor da multa aplicada
                        					sobre o valor original.
                        				</xs:documentation>
                        			</xs:annotation>
                        		</xs:element>
                        		<xs:group ref="dadosGnre_1.00_2" />
                        		<xs:element minOccurs="0"
                        			name="c29_dataLimitePagamento"
                        			type="TData">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Data máxima que o banco pode
                        					receber o pagamento, que
                        					estará impressa na guia e no
                        					código de barras.
                        				</xs:documentation>
                        			</xs:annotation>
                        		</xs:element>
                        		<xs:group ref="dadosGnre_1.00_3" />
                        		<xs:element minOccurs="0"
                        			name="c23_informacoes">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Informação complementar a
                        					ser impressa na guia.
                        				</xs:documentation>
                        			</xs:annotation>
                        			<xs:simpleType>
                        				<xs:restriction
                        					base="TString">
                        					<xs:maxLength value="300" />
                        				</xs:restriction>
                        			</xs:simpleType>
                        		</xs:element>
                        		<xs:element minOccurs="0"
                        			name="c30_nossoNumero">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Número interno da guia
                        					gerado pela UF
                        				</xs:documentation>
                        			</xs:annotation>
                        			<xs:simpleType>
                        				<xs:restriction
                        					base="xs:string">
                        					<xs:whiteSpace
                        						value="preserve" />
                        					<xs:pattern
                        						value="[0-9]{16}" />
                        				</xs:restriction>
                        			</xs:simpleType>
                        		</xs:element>
                        		<xs:element minOccurs="0"
                        			name="c24_autenticacao">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Autenticação bancária do
                        					pagamento da guia.
                        				</xs:documentation>
                        			</xs:annotation>
                        			<xs:simpleType>
                        				<xs:restriction
                        					base="TString">
                        					<xs:maxLength value="23" />
                        				</xs:restriction>
                        			</xs:simpleType>
                        		</xs:element>
                        		<xs:element minOccurs="0"
                        			name="c31_banco">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Código do Banco onde foi
                        					paga a guia.
                        				</xs:documentation>
                        			</xs:annotation>
                        			<xs:simpleType>
                        				<xs:restriction
                        					base="xs:string">
                        					<xs:whiteSpace
                        						value="preserve" />
                        					<xs:pattern
                        						value="[0-9]{3}" />
                        				</xs:restriction>
                        			</xs:simpleType>
                        		</xs:element>
                        		<xs:element minOccurs="0"
                        			name="c32_agencia">
                        			<xs:annotation>
                        				<xs:documentation>
                        					Código da Agência bancária
                        					onde foi paga a guia.
                        				</xs:documentation>
                        			</xs:annotation>
                        			<xs:simpleType>
                        				<xs:restriction
                        					base="xs:string">
                        					<xs:whiteSpace
                        						value="preserve" />
                        					<xs:pattern
                        						value="[0-9]{4,5}" />
                        				</xs:restriction>
                        			</xs:simpleType>
                        		</xs:element>
                        		<xs:group ref="dadosGnre_1.00_4" />
                        	</xs:sequence>
                        </xs:choice>
                       	<xs:element name="dataEmissaoDados"
                       		type="TData" maxOccurs="1" minOccurs="0">
                                <xs:annotation>
                                	<xs:documentation>Este campo deve ser preenchido quando do retorno de uma consulta de Guia por Documento de Origem, ocasião em que pode ocorrer a incidência de mais de uma Guia no mesmo retorno.</xs:documentation>
                                </xs:annotation>
                       	</xs:element>
                       	<xs:element name="horaEmissaoDados"
                       		type="xs:time" maxOccurs="1" minOccurs="0">
                                <xs:annotation>
                                	<xs:documentation>Este campo deve ser preenchido quando do retorno de uma consulta de Guia por Documento de Origem, ocasião em que pode ocorrer a incidência de mais de uma Guia no mesmo retorno.</xs:documentation></xs:annotation>
                       	</xs:element>
                       	</xs:sequence>
                        <xs:attribute name="versao" use="required">
							<xs:simpleType>
								<xs:restriction base="xs:string">
									<xs:pattern value="\d\.\d{2}"></xs:pattern>
								</xs:restriction>
							</xs:simpleType>
                        </xs:attribute>
					</xs:complexType>
				</xs:element>
				<xs:element minOccurs="1" name="situacao">
					<xs:annotation>
						<xs:documentation>
							Indica o status do processamento da guia 
							0 – Gerada com sucesso; 
							1 – Erro de	preenchimento; 
							2 – Erro de comunicação;
							3 - Pendencia de tempo de processamento
						</xs:documentation>
					</xs:annotation>
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:whiteSpace value="preserve" />
							<xs:enumeration value="0" />
							<xs:enumeration value="1" />
							<xs:enumeration value="2" />
							<xs:enumeration value="3" />
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
				<xs:element minOccurs="0" name="erros">
					<xs:annotation>
						<xs:documentation>
							Erros no processamento da GNRE.
						</xs:documentation>
					</xs:annotation>
					<xs:complexType>
						<xs:choice>
							<xs:element maxOccurs="unbounded"
								name="erro">
								<xs:complexType>
									<xs:sequence>
                                        <xs:element name="item"
                                        	type="xs:integer" 
                                        	minOccurs="0">
                                        	<xs:annotation>
                                        		<xs:documentation>
                                        			Ordem do item onde
                                        			tem campo com erro
                                        			de validação
                                        		</xs:documentation>
                                        	</xs:annotation>
                                        </xs:element>
                                        <xs:element minOccurs="0"
											name="campo" type="TCamposGNRE2">
											<xs:annotation>
												<xs:documentation>
													Campo que apresentou
													erro durante o
													processamento.
												</xs:documentation>
											</xs:annotation>
										</xs:element>
										<xs:element minOccurs="1"
											name="mensagem" type="xs:string">
											<xs:annotation>
												<xs:documentation>
													Mensagem com o
													motivo do erro
													gerado para o campo.
												</xs:documentation>
											</xs:annotation>
										</xs:element>

									</xs:sequence>
								</xs:complexType>
							</xs:element>
						</xs:choice>
					</xs:complexType>
				</xs:element>
				<xs:element minOccurs="0" name="linhaDigitavel">
					<xs:annotation>
						<xs:documentation>Linha digitável gerada nas UFs.</xs:documentation>
					</xs:annotation>
					<xs:simpleType>
						<xs:restriction base="TString">
							<xs:whiteSpace value="preserve" />
							<xs:length value="48"></xs:length>
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
				<xs:element minOccurs="0" name="qrcodePayload">
					<xs:annotation>
						<xs:documentation>String que sera utilizada para a geracao do QRCode do pagamento PIX.</xs:documentation>
					</xs:annotation>
					<xs:simpleType>
						<xs:restriction base="TString">
							<xs:whiteSpace value="preserve" />
							<xs:maxLength value="512"></xs:maxLength>
							<xs:minLength value="100"></xs:minLength>
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
				<xs:element minOccurs="0" name="dataEmissao"
					type="TData">
					<xs:annotation>
						<xs:documentation>
							Data de emissão da guia. (Formato
							AAAA-MM-DD)
						</xs:documentation>
					</xs:annotation>
				</xs:element>
				<xs:element minOccurs="0" name="horaEmissao"
					type="xs:time">
					<xs:annotation>
						<xs:documentation>
							Hora de emissão da guia. (Formato HH:MM:SS)
						</xs:documentation>
					</xs:annotation>
				</xs:element>
			</xs:sequence>
			<xs:attribute name="versao" use="required" fixed="2.00">
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:pattern value="\d\.\d{2}"></xs:pattern>
					</xs:restriction>
				</xs:simpleType>
			</xs:attribute>
		</xs:complexType>
	</xs:element>
</xs:schema>