根据XSD验证XML:Undeclared XSD元素

时间:2013-06-17 18:23:59

标签: xml delphi xsd delphi-2010

我正在尝试针对xsd文件验证xml但返回de error:

1.xsd#/schema/element[1][@name = 'envioLote']/complexType[1]/sequence[1]/element[4]
Undeclared XSD element : '{http://www.w3.org/2000/09/xmldsig#}Signature'

我正在使用以下代码

var
 DOMDocument     : IXMLDOMDocument3;
 ParseError      : IXMLDOMParseError;
 Schema          : XMLSchemaCache;
 sNameSpace      : String;
begin

 DOMDocument                  := CoDOMDocument50.Create;
 DOMDocument.async            := False;
 DOMDocument.resolveExternals := True;
 DOMDocument.validateOnParse  := True;
 DOMDocument.loadXML(sXml);
 Schema := CoXMLSchemaCache50.Create;
 Schema.add( '', 'c:\1.xsd' );
 DOMDocument.schemas := Schema;

 ParseError := DOMDocument.validate;
 Result     := (ParseError.errorCode = 0);
 if not result then      
   showmessage(ParseError.reason);

 DOMDocument := nil; 
 ParseError  := nil;
 Schema      := nil;
end;

1.xsd file

    <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/>
    <xs:element name="envioLote">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="CNPJ" type="TCnpj"/>
                <xs:element name="dhTrans" type="TDataHora"/>
                <xs:element ref="NFS-e" minOccurs="1" maxOccurs="500"/>
                <xs:element ref="ds:Signature" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
            <xs:attribute name="versao" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="NFS-e">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="infNFSe"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="infNFSe">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Id"/>
                <xs:element ref="prest"/>
                <xs:element ref="TomS"/>
                <xs:element ref="det" minOccurs="1" maxOccurs="999"/>
                <xs:element ref="total"/>
                <xs:element name="infAdicLT" type="TCodMunIBGE" minOccurs="1" maxOccurs="1"/>
                <xs:element name="infAdicES" type="TSimNao" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
            <xs:attribute name="versao" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="Id">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="cNFS-e" type="TNumAleatorio"/>
                <xs:element name="mod" type="TModelo"/>
                <xs:element name="serie" type="TSerie"/>
                <xs:element name="nNFS-e" type="TNF"/>
                <xs:element name="dEmi" type="TData"/>
                <xs:element name="hEmi" type="THora"/>
                <xs:element name="tpNF" type="TNFSe"/>
                <xs:element name="refNF" type="TChaveAcesso"/>
                <xs:element name="tpEmis" type="TEmissao"/>
                <xs:element name="ambienteEmi" type="TCharInt"/>
                <xs:element name="formaEmi" type="TCharInt"/>
                <xs:element name="empreitadaGlobal" type="TCharInt"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="prest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="CNPJ" type="TCnpj"/>
                <xs:element name="xNome" type="TString150"/>
                <xs:element name="IM" type="TString15"/>
                <xs:element ref="end"/>
                <xs:element name="regimeTrib" type="TCharInt"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="end">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="xLgr" type="TString100"/>
                <xs:element name="nro" type="TString6"/>
                <xs:element name="xBairro" type="TString100"/>
                <xs:element name="cMun" type="TCodMunIBGE"/>
                <xs:element name="xMun" type="TString60"/>
                <xs:element name="UF" type="TString2"/>
                <xs:element name="CEP" type="TCep"/>
                <xs:element name="cPais" type="TcPais"/>
                <xs:element name="xPais" type="TString100"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="TomS">
        <xs:complexType>
            <xs:sequence>
                <xs:choice>
                    <xs:element name="CNPJ" type="TCnpj"/>
                    <xs:element name="CPF" type="TCpf"/>
                </xs:choice>
                <xs:element ref="ender"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="ender">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="cMun" type="TCodMunIBGE"/>
                <xs:element name="xMun" type="TString60"/>
                <xs:element name="UF" type="TString2"/>
                <xs:element name="cPais" type="TcPais"/>
                <xs:element name="xPais" type="TString100"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="dadosDaObra">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="xLogObra" type="TString100"/>
                <xs:element name="xComplObra" type="TString100" minOccurs="0" maxOccurs="1"/>
                <xs:element name="vNumeroObra" type="TString15" minOccurs="0" maxOccurs="1"/>
                <xs:element name="xBairroObra" type="TString100" minOccurs="0" maxOccurs="1"/>
                <xs:element name="xCepObra" type="TCep" minOccurs="0" maxOccurs="1"/>
                <xs:element name="cCidadeObra" type="TCodMunIBGE"/>
                <xs:element name="xCidadeObra" type="TString60"/>
                <xs:element name="xUfObra" type="TString2"/>
                <xs:element name="cPaisObra" type="TcPais"/>
                <xs:element name="xPaisObra" type="TString100"/>
                <xs:element name="numeroArt" type="TString12" minOccurs="0" maxOccurs="1"/>
                <xs:element name="numeroCei" type="TString12" minOccurs="0" maxOccurs="1"/>
                <xs:element name="numeroProj" type="TString15" minOccurs="0" maxOccurs="1"/>
                <xs:element name="numeroMatri" type="TString15" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="transportadora">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="xNomeTrans" type="TString100"/>
                <xs:element name="xCpfCnpjTrans" type="TString15" minOccurs="0" maxOccurs="1"/>
                <xs:element name="xInscEstTrans" type="TString15" minOccurs="0" maxOccurs="1"/>
                <xs:element name="xPlacaTrans" type="TPlacaVeic" minOccurs="0" maxOccurs="1"/>
                <xs:element name="xEndTrans" type="TString100" minOccurs="0" maxOccurs="1"/>
                <xs:element name="cMunTrans" type="TCodMunIBGE" minOccurs="0" maxOccurs="1"/>
                <xs:element name="xMunTrans" type="TString60" minOccurs="0" maxOccurs="1"/>
                <xs:element name="xUfTrans" type="TString2" minOccurs="0" maxOccurs="1"/>
                <xs:element name="cPaisTrans" type="TcPais" minOccurs="0" maxOccurs="1"/>
                <xs:element name="xPaisTrans" type="TString100" minOccurs="0" maxOccurs="1"/>
                <xs:element name="vTipoFreteTrans" type="TFrete" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="det">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="nItem" type="TOrdemSeq"/>
                <xs:element ref="serv"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="serv">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="cServ" type="TString60"/>
                <xs:element name="cLCServ" type="TLCServ"/>
                <xs:element name="xServ" type="TString256"/>
                <xs:element name="localTributacao" type="TCodMunIBGE"/>
                <xs:element name="localVerifResServ" type="TCharInt"/>
                <xs:element name="uTrib" type="TString2"/>
                <xs:element name="qTrib" type="TDec_1302"/>
                <xs:element name="vUnit" type="TDec_1302"/>
                <xs:element name="vServ" type="TDec_1302"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="ISSST">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="vBCST" type="TDec_1302"/>
                <xs:element name="pISSST" type="TDec_0302"/>
                <xs:element name="vISSST" type="TDec_1302"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="total">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="vServ" type="TDec_1302"/>
                <xs:element name="vtNF" type="TDec_1302"/>
                <xs:element name="vtLiq" type="TDec_1302"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="ISS"/>
    <xs:element name="Ret">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="vRetIR" type="TDec_1302" minOccurs="0" maxOccurs="1"/>
                <xs:element name="vRetPISPASEP" type="TDec_1302" minOccurs="0" maxOccurs="1"/>
                <xs:element name="vRetCOFINS" type="TDec_1302" minOccurs="0" maxOccurs="1"/>
                <xs:element name="vRetCSLL" type="TDec_1302" minOccurs="0" maxOccurs="1"/>
                <xs:element name="vRetINSS" type="TDec_1302" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="faturas">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="fat" minOccurs="1" maxOccurs="999"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="fat">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="nItem" type="TOrdemSeq"/>
                <xs:element name="nFat" type="TNumFatura"/>
                <xs:element name="dVenc" type="TData"/>
                <xs:element name="vFat" type="TDec_1302"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:simpleType name="TCep">
        <xs:annotation>
            <xs:documentation>Tipo para Codigo Postal</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{8}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TCharInt">
        <xs:annotation>
            <xs:documentation>Tipo para caracter numerico</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{1}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TChaveAcesso">
        <xs:annotation>
            <xs:documentation>Tipo para chave de acesso   </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="39"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TCnpj">
        <xs:annotation>
            <xs:documentation>Tipo Número do CNPJ</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{14}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TCodMunIBGE">
        <xs:annotation>
            <xs:documentation>Tipo Código do Município da tabela do IBGE</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{7}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TcPais">
        <xs:annotation>
            <xs:documentation>Tipo para Codigo do Pais</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{5}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TCpf">
        <xs:annotation>
            <xs:documentation>Tipo Número do CPF</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{11}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TData">
        <xs:annotation>
            <xs:documentation> Tipo data AAAA-MM-DD</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:date">
            <xs:pattern value="\d{4}-\d{2}-\d{2}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TDataHora">
        <xs:annotation>
            <xs:documentation> Tipo datetime AAAA-MM-DD HH:MM:SS</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:whiteSpace value="preserve"/>
            <xs:pattern value="\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TDec_0302">
        <xs:annotation>
            <xs:documentation>Tipo Decimal com 5 dígitos, sendo 3 de corpo e 2 decimais</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="0"/>
            <xs:whiteSpace value="preserve"/>
            <xs:pattern value="|0|0\.[0-9]{2}|[1-9]{1}[0-9]{0,2}(\.[0-9]{2})?"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TDec_1302">
        <xs:annotation>
            <xs:documentation>Tipo Decimal com 15 dígitos, sendo 13 de corpo e 2 decimais</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="0"/>
            <xs:whiteSpace value="preserve"/>
            <xs:pattern value="|0|0\.[0-9]{2}|[1-9]{1}[0-9]{0,12}(\.[0-9]{2})?"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TEmissao">
        <xs:annotation>
            <xs:documentation>Tipo para forma de emissao  </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[NC]{1}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TFone">
        <xs:annotation>
            <xs:documentation>Tipo para numero do telefone  </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="|[0-9]{1,14}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TFrete">
        <xs:annotation>
            <xs:documentation>Tipo para frete de transportadora  </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{1}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="THora">
        <xs:annotation>
            <xs:documentation> Tipo time HH:MM</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:whiteSpace value="preserve"/>
            <xs:pattern value="\d{2}:\d{2}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TImpressao">
        <xs:annotation>
            <xs:documentation>Tipo para formato de impressao   </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="1"/>
            <!-- Em Caxias uma NFSe somente pode ser impressa no modo retrato  -->
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TLCServ">
        <xs:annotation>
            <xs:documentation>Tipo para Lei Complementar 116 </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:positiveInteger">
            <xs:maxInclusive value="9999"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TModelo">
        <xs:annotation>
            <xs:documentation>Tipo para modelo de uma NFSe   </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="2"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TMotCanc">
        <xs:annotation>
            <xs:documentation>Tipo para motivo de cancelamento</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{1}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TNF">
        <xs:annotation>
            <xs:documentation>Tipo Número do Documento Fiscal</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{0,9}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TNFSe">
        <xs:annotation>
            <xs:documentation>Tipo para uma NFSe   </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TNumAleatorio">
        <xs:annotation>
            <xs:documentation>Tipo para numero aleatorio </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:positiveInteger">
            <xs:maxInclusive value="999999999"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TNumFatura">
        <xs:annotation>
            <xs:documentation>Tipo Número de Fatura em NFS-e</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{0,3}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TOrdemSeq">
        <xs:annotation>
            <xs:documentation>Tipo para ordem sequencial de itens </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:positiveInteger">
            <xs:maxInclusive value="999"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TPlacaVeic">
        <xs:annotation>
            <xs:documentation>Tipo String para placa de veiculo com tamanho maximo 7</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[a-zA-Z]{2,3}[0-9]{3,4}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TSerie">
        <xs:annotation>
            <xs:documentation>Tipo String de tamanho maximo 3</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="3"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TSimNao">
        <xs:annotation>
            <xs:documentation>Tipo para Sim/Nao  </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[SN]{1}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TSituacaoCancelamentoNota">
        <xs:annotation>
            <xs:documentation>Tipo para situacao de cancelamento de uma NFSe </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:positiveInteger">
            <xs:maxInclusive value="999"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TSituacaoLote">
        <xs:annotation>
            <xs:documentation>Tipo para situacao de um lote de NFSe </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:positiveInteger">
            <xs:maxInclusive value="999"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TSituacaoNFSe">
        <xs:annotation>
            <xs:documentation>Tipo para situacao de uma NFSe </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:pattern value="[0-9]{1}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TSituacaoNota">
        <xs:annotation>
            <xs:documentation>Tipo para situacao de uma nota dentro de um lote submetido </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:positiveInteger">
            <xs:maxInclusive value="999"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString2">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 2</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="2"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString3">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 3</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="3"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString5">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 5</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="5"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString6">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 6</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="6"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString12">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 12</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="12"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString13">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 13</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="13"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString15">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 15</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="15"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString50">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 50</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="50"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString60">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 60</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="60"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString100">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 100</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="100"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString120">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 120</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="120"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString150">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 150</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="150"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TString256">
        <xs:annotation>
            <xs:documentation>Tipo para string de tamanho maximo 256</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="256"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Content of "sXml"

    <?xml version="1.0" encoding="utf-8"?>
<envioLote versao="1.0">
    <CNPJ>93120350000172</CNPJ>
    <dhTrans>2013-06-17 16:12:45</dhTrans>
    <NFS-e>
        <infNFSe versao="1.1">
            <Id>
                <cNFS-e>12</cNFS-e>
                <mod>55</mod>
                <serie>S</serie>
                <nNFS-e>12</nNFS-e>
                <dEmi>2013-06-17</dEmi>
                <hEmi>13:48</hEmi>
                <tpNF>1</tpNF>
                <refNF>439312035000017255S00000000012850064870</refNF>
                <tpEmis>N</tpEmis>
                <ambienteEmi>2</ambienteEmi>
                <formaEmi>2</formaEmi>
                <empreitadaGlobal>2</empreitadaGlobal>
            </Id>
            <prest>
                <CNPJ>93120350000172</CNPJ>
                <xNome>CFC ELITRONIC CAR BETA 2 LTDA</xNome>
                <IM>8198</IM>
                <end>
                    <xLgr>RUA X</xLgr>
                    <nro>120</nro>
                    <xBairro>BAIRRO</xBairro>
                    <cMun>4305108</cMun>
                    <xMun>CAXIAS DO SUL</xMun>
                    <UF>RS</UF>
                    <CEP>97015530</CEP>
                    <cPais>01058</cPais>
                    <xPais>BRASIL</xPais>
                </end>
                <regimeTrib>3</regimeTrib>
            </prest>
            <TomS>
                <CPF>00295819073</CPF>
                <ender>
                    <cMun>4305108</cMun>
                    <xMun>CAXIAS DO SUL</xMun>
                    <UF>RS</UF>
                    <cPais>01058</cPais>
                    <xPais>BRASIL</xPais>
                </ender>
            </TomS>
            <det>
                <nItem>1</nItem>
                <serv>
                    <cServ>10</cServ>
                    <cLCServ>1405</cLCServ>
                    <xServ>AULA PRATICA - CATEGORIA A</xServ>
                    <localTributacao>4305108</localTributacao>
                    <localVerifResServ>1</localVerifResServ>
                    <uTrib>UN</uTrib>
                    <qTrib>20</qTrib>
                    <vUnit>29.95</vUnit>
                    <vServ>599.00</vServ>
                </serv>
            </det>
            <total>
                <vServ>599.00</vServ>
                <vtNF>599.00</vtNF>
                <vtLiq>599.00</vtLiq>
            </total>
            <infAdicLT>4305108</infAdicLT>
        </infNFSe>
    </NFS-e>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
        <SignedInfo>
            <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
            <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
            <Reference URI="">
                <Transforms>
                    <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                    <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
                </Transforms>
                <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                <DigestValue>JJtzvD6DJIlwd/ciT6gF1KZl7DA=</DigestValue>
            </Reference>
        </SignedInfo>
        <SignatureValue>
      DCD5WbABTQpfS8GvmNBBP2+LRUZVWX35fSXA1lX6Thbwf/uyXaD0OdeDhC0Oz6hB5TnqKkUX
      Bgerr7PwUG0/jicrL2V7vTKZ+08DPhU+GwDPgkd8g5jk367rMsUe+rWq70e+98SjWpGNaFZn
      zY1Q7Wqu+uT9DPlDS6hci5Hi5Bg=
    </SignatureValue>
        <KeyInfo>
            <X509Data>
                <X509SubjectName>CN=SB SISTEMAS LTDA:07081093000175, OU=AR SERASA, OU=RFB e-CNPJ A3, OU=Secretaria da Receita Federal do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BOtt8xo8bRNxx9aA41yifpS16z9iYKN
bQB/B0Ebp9E09Vm2AsbuKSb8thHmRys+/tgVjkIWpNeTq6p5K/E/sZ/quKNqmVuC
mdsVxTeGWXU+GXnUwjJqaFFMCJ/pAQ==</X509Certificate>
            </X509Data>
        </KeyInfo>
    </Signature>
</envioLote>

我之前使用过相同的代码没有问题,我对xsd没有太多经验,所以如果有人能给我一个帮助就会心存感激

1 个答案:

答案 0 :(得分:2)

错误消息显示您有一个未定义的XSD元素,它告诉您来自命名空间Signature的元素是http://www.w3.org/2000/09/xmldsig#。解决此问题的明显第一步是找到该元素的定义位置;如果找不到它,你也很难找到别的东西。

定义“missing”元素的命名空间仅提到另一个地方,即xs:import元素。我和你一样有XSD的经验,但是我可以非常有信心地猜测该元素可以从其他地方导入定义,可能来自schemaLocation属性中给出的位置。

简单的Web搜索显示了大量名为 xmldsig-core-schema_v1.01.xsd 的文件实例,它确实定义了类型Signature

显然,需要存在该文件才能验证对架构的遵守情况。