我使用xsd.exe工具为xml以下生成了xml架构文件(XSD)文件。 它为我提供了两个xml
的模式文件<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd" version="3.2" serie="C" folio="371" fecha="2015-03-04T12:48:04" sello="abnLKgvWQ+pPBW1YSI/N941kf7eDOn8GBttp1/AJAdkQS6n60s37saV9ugTfOpYM4G+Q+4zr0jn0RQldamFyMDo/F3BfPg3R9yG8SD5A45i4Sh3CL/El2AHH/Zkyvft8b+BgFAMCoauvpi61BOCNK1EjEPcro0eZoy8ZRBfv+Xo=" formaDePago="PAGO EN UNA SOLA EXHIBICION" noCertificado="00001000000301540335" certificado="MIIEXTCCA0WgAwIBAgIUMDAwMDEwMDAwMDAzMDE1NDAzMzUwDQYJKoZIhvcNAQEFBQAwggGKMTgwNgYDVQQDDC9BLkMuIGRlbCBTZXJ2aWNpbyBkZSBBZG1pbmlzdHJhY2nDs24gVHJpYnV0YXJpYTEvMC0GA1UECgwmU2VydmljaW8gZGUgQWRtaW5pc3RyYWNpw7NuIFRyaWJ1dGFyaWExODA2BgNVBAsML0FkbWluaXN0cmFjacOzbiBkZSBTZWd1cmlkYWQgZGUgbGEgSW5mb3JtYWNpw7NuMR8wHQYJKoZIhvcNAQkBFhBhY29kc0BzYXQuZ29iLm14MSYwJAYDVQQJDB1Bdi4gSGlkYWxnbyA3NywgQ29sLiBHdWVycmVybzEOMAwGA1UEEQwFMDYzMDAxCzAJBgNVBAYTAk1YMRkwFwYDVQQIDBBEaXN0cml0byBGZWRlcmFsMRQwEgYDVQQHDAtDdWF1aHTDqW1vYzEVMBMGA1UELRMMU0FUOTcwNzAxTk4zMTUwMwYJKoZIhvcNAQkCDCZSZXNwb25zYWJsZTogQ2xhdWRpYSBDb3ZhcnJ1YmlhcyBPY2hvYTAeFw0xMzEyMDQwMTI3NDlaFw0xNzEyMDQwMTI3NDlaMIGpMRswGQYDVQQDExJKT1JHRSBDT1JPTkEgRFVSQU4xGzAZBgNVBCkTEkpPUkdFIENPUk9OQSBEVVJBTjEbMBkGA1UEChMSSk9SR0UgQ09ST05BIERVUkFOMRYwFAYDVQQtEw1DT0RKNzAwMjE0NVEzMRswGQYDVQQFExJDT0RKNzAwMjE0SEJDUlJSMTcxGzAZBgNVBAsTEkpPUkdFIENPUk9OQSBEVVJBTjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAnnOz6hCym1vtbA6N3LPB2/dGJweT9E8EqFXdHbnq2CPaNQUKyNMLDfBJCI7KdgNE67rJPNiGgaa/o9iyXzDBqCqEK67uadESL9wSJJ4+Ljk+9iXrQvQE0qsqKp05WWbZ6UBIMpGud0jaGnDonXbX6GrF/qmjb08HBFVqIhaJf/cCAwEAAaMdMBswDAYDVR0TAQH/BAIwADALBgNVHQ8EBAMCBsAwDQYJKoZIhvcNAQEFBQADggEBAA1WDsvSBX2+YxURH8qcR9ddBs71hTXMl4qp/N3S8/L9ISfcMTfDqRrLHpeC03Ru/w2LSXKywcIQHtbUpBDMdzfseS7xJn7QBswH2wRLmjgi7MUFSHQW9mNDGbpBPm6MNe8dbhvK0KWfz7FWgAcCzUj4xKIBLyxIDdlG21GBBYjXpWGGuf30NUSXvx8c7PeCqtZPI25H80BxSMI5Z85BoLtgh7dw87q7bQT5gs59JFearYaJPyXn6yCWHY4uJM25FSeo2OpIl78Ase7uwDuADYvyDzpmD5HFWo9KszehlWTnm4D8OmLsTFkyHzGyIi/PfSbf1mFdKSIBtB53uAyJ4pU=" subTotal="869.39" TipoCambio="1.00" Moneda="Peso Mexicano" total="828.82" tipoDeComprobante="ingreso" metodoDePago="NO IDENTIFICADO" LugarExpedicion="FRANCISCO I. MADERO 2017 , NUEVA, 21100, MEXICALI, MEXICALI, BAJA CALIFORNIA, MEXICO">
<cfdi:Emisor rfc="CODJ7002145Q3" nombre="JORGE CORONA DURAN">
<cfdi:DomicilioFiscal calle="FRANCISCO I. MADERO" noExterior="2017" colonia="NUEVA" localidad="MEXICALI" municipio="MEXICALI" estado="BAJA CALIFORNIA" pais="MEXICO" codigoPostal="21100"/>
<cfdi:RegimenFiscal Regimen="PERSONA FISICA CON ACTIVIDAD EMPRESARIAL Y PROFESIONAL"/>
</cfdi:Emisor>
<cfdi:Receptor rfc="VME990127Q70" nombre="VSF MEXICO S.A. DE C.V., SOFOM, E.N.R.
">
<cfdi:Domicilio calle="AVE SANTA FE
" noExterior="495" colonia="MANZANA B LOTE B1 20
 COL. CRUZ MANCA
" localidad="MEXICO" municipio="CUAJIMALPA" estado="DISTRITO FEDERAL" pais="MEXICO" codigoPostal="05349"/>
</cfdi:Receptor>
<cfdi:Conceptos>
<cfdi:Concepto cantidad="1.00" unidad="No aplica" noIdentificacion="RECU" descripcion="RECUPERACION" valorUnitario="869.39" importe="869.39"/>
</cfdi:Conceptos>
<cfdi:Impuestos totalImpuestosRetenidos="179.67" totalImpuestosTrasladados="139.10">
<cfdi:Retenciones>
<cfdi:Retencion impuesto="ISR" importe="86.94"/>
<cfdi:Retencion impuesto="IVA" importe="92.73"/>
</cfdi:Retenciones>
<cfdi:Traslados>
<cfdi:Traslado impuesto="IVA" tasa="16.00" importe="139.10"/>
</cfdi:Traslados>
</cfdi:Impuestos>
<cfdi:Complemento>
<tfd:TimbreFiscalDigital xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/TimbreFiscalDigital http://www.sat.gob.mx/TimbreFiscalDigital/TimbreFiscalDigital.xsd" selloCFD="abnLKgvWQ+pPBW1YSI/N941kf7eDOn8GBttp1/AJAdkQS6n60s37saV9ugTfOpYM4G+Q+4zr0jn0RQldamFyMDo/F3BfPg3R9yG8SD5A45i4Sh3CL/El2AHH/Zkyvft8b+BgFAMCoauvpi61BOCNK1EjEPcro0eZoy8ZRBfv+Xo=" FechaTimbrado="2015-03-04T14:48:50" UUID="07BEEF18-45AF-5F3B-BB44-C2758802ADCF" noCertificadoSAT="00001000000202864883" version="1.0" selloSAT="pnaIMS1fcN4BIkKmoibQQTYANHJeG+1uvwO32ZC4io0wM/INNnspsig9/R+GrCx+fHwCGmyISlU+WLgmww9G5IpB4YuNywJW1j0ggaFunW2hOyLfgmYC2IJeMPUCxrL8pd64NiyNMYzNb0zI/6miefmzgSnAAFZXAYB3YuAMoPo="/>
</cfdi:Complemento>
</cfdi:Comprobante>
我正在尝试使用生成的模式文件验证模式,但我得到了一个错误。请参阅下面的我的vb.net代码:
Protected Function XmlValidate(ByVal xmlFile As String, ByVal invoiceSchema As String, ByVal digitalSchema As String) As Boolean
Try
Library.Log("Xml validation began for voucher file " & XmlFile & " begins: ", LogType.INFOLOG, ImportType.VOU)
Dim settings = New XmlReaderSettings()
settings.Schemas.Add("", invoiceSchema)
settings.Schemas.Add("", digitalSchema)
settings.ValidationType = ValidationType.Schema
AddHandler settings.ValidationEventHandler, New ValidationEventHandler(AddressOf ValidationEventHandler)
Dim reader As XmlReader = XmlReader.Create(XmlFile, Settings)
While reader.Read()
End While
reader.Close()
Library.Log("Voucher file validation completed for file " & XmlFile, LogType.INFOLOG, ImportType.ECOUNSEL_IMP)
Catch ex As Exception
Library.Log("Voucher Imported errored out (XMLValidate):" & ex.ToString(), LogType.ERRORLOG, ImportType.ECOUNSEL_IMP)
_import = False
End Try
XmlValidate = _import
End Function
''' <summary>
''' Validation event hanlder for xml validation
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Protected Sub ValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs)
Try
Select Case e.Severity
Case XmlSeverityType.Error
Dim err As String = e.Message.ToString()
Library.Log("Error occured while validating xml" & err, LogType.ERRORLOG, ImportType.ECOUNSEL_IMP)
Case XmlSeverityType.Warning
Dim err As String = e.Message.ToString()
Library.Log("Error occured while validating xml" & err, LogType.ERRORLOG, ImportType.ECOUNSEL_IMP)
End Select
_import = False
Catch ex As Exception
Library.Log("Voucher import errored out in ValidationEventHandler:" & ex.ToString(), LogType.ERRORLOG, ImportType.ECOUNSEL_IMP)
End Try
End Sub