maudruidas Posted December 13, 2017 Report Share Posted December 13, 2017 Boa tarde, gostaria de saber se alguém tem alguma rotina para validação de XSD (esquema XML)? Quote Link to comment Share on other sites More sharing options...
kapiaba Posted December 13, 2017 Report Share Posted December 13, 2017 Veja se ajuda: https://www.sefaz.rs.gov.br/nfe/nfe-val.aspx Quote Link to comment Share on other sites More sharing options...
maudruidas Posted December 13, 2017 Author Report Share Posted December 13, 2017 Este link é da Nfe, gostaria de saber se existe para o esocial. Eu queria comparar / validar meu XML com os esquemas XSD. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted December 13, 2017 Report Share Posted December 13, 2017 Sorry, yo no conoco. só se for aqui: https://portal.esocial.gov.br/ Quote Link to comment Share on other sites More sharing options...
Alain da Silva Posted December 16, 2017 Report Share Posted December 16, 2017 **classe sefazclass FUNCTION DomDocValidaXml( cXml, cFileXsd ) LOCAL oXmlDomDoc, oXmlSchema, oXmlErro, cRetorno := "ERRO" /* validando o arquivo s1000.xml esquema .\shema\evtinfoempregador.xsd */ IF " <" $ cXml .OR. "> " $ cXml cRetorno:="Espaços inválidos no XML entre as tags" RETURN cRetorno //mResultado("eSocial",IIF(m->hDados['NFEProducao'],"PRODUÇÃO","HOMOLOGAÇÃO"),cErroRet) ENDIF IF Empty( cFileXsd ) RETURN "OK" ENDIF IF ! File( cFileXSD ) cRetorno:="Erro não encontrado arquivo " + cFileXSD RETURN cRetorno //mResultado("eSocial 1: ",IIF(m->hDados['NFEProducao'],"PRODUÇÃO","HOMOLOGAÇÃO"),cErroRet) ENDIF do while .t. cRetorno := "Erro Carregando MSXML2.DomDocument.6.0" oXmlDomDoc := xhb_CreateObject( "MSXML2.DomDocument.6.0" ) oXmlDomDoc:aSync := .F. oXmlDomDoc:ResolveExternals := .F. oXmlDomDoc:ValidateOnParse := .T. cRetorno := "Erro Carregando XML" oXmlDomDoc:LoadXml( cXml ) IF oXmlDomDoc:ParseError:ErrorCode <> 0 cRetorno:= "Erro XML inválido " + ; " Linha: " + AllTrim( Transform( oXmlDomDoc:ParseError:Line, "" ) ) + ; " coluna: " + AllTrim( Transform( oXmlDomDoc:ParseError:LinePos, "" ) ) + ; " motivo: " + AllTrim( Transform( oXmlDomDoc:ParseError:Reason, "" ) ) + ; " errcode: " + AllTrim( Transform( oXmlDomDoc:ParseError:ErrorCode, "" ) ) exit ENDIF cRetorno := "Erro Carregando MSXML2.XMLSchemaCache.6.0" oXmlSchema := xhb_CreateObject( "MSXML2.XMLSchemaCache.6.0" ) cRetorno := "Erro carregando " + cFileXSD oXmlSchema:Add( "http://www.esocial.gov.br/schema/evt/evtInfoEmpregador/v02_04_01", cFileXSD ) oXmlDomDoc:Schemas := oXmlSchema oXmlErro := oXmlDomDoc:Validate() IF oXmlErro:ErrorCode <> 0 cRetorno:= "Erro: " + AllTrim( Transform( oXmlErro:ErrorCode, "" ) ) + " " + ConverteErroValidacao( oXmlErro:Reason, "" ) exit ENDIF cErroret:= "OK" exit ENDDO RETURN cRetorno FUNCTION ConverteErroValidacao( cTexto ) LOCAL nPosIni, nPosFim cTexto := AllTrim( Transform( cTexto, "" ) ) DO WHILE .T. IF ! "{" $ cTexto .OR. ! "}" $ cTexto EXIT ENDIF nPosIni := At( "{", cTexto ) - 1 nPosFim := At( "}", cTexto ) + 1 IF nPosIni > nPosFim EXIT ENDIF cTexto := Substr( cTexto, 1, nPosIni ) + Substr( cTexto, nPosFim ) ENDDO RETURN cTexto bom dia, eu também estou procurando sobre isso, achei o seguinte. No site do pctoledo, vi com o josequintas que na classe sefazclass tem essa rotina. porém ele da a seguinte mensagem de erro: Ele da a seguinte mensagem de erro: evtInfoEmpregador.XSD#/schema/element[1][@name = 'eSocial']/complexType[1]/sequence[1]/element[2] Elemento XSD não declarado: '{http://www.w3.org/2000/09/xmldsig#}Signature'. : ADD Args: [ 1] = C http://www.esocial.gov.br/schema/evt/ev ... /v02_04_01 [ 2] = C .\SHEMA\evtInfoEmpregador.XSD Inclusive achei um site que faz essa conversão do xsd para o xml mas que também apresenta o mesmo erro: http://xsd2xml.com/, Error!!! The 'http://www.w3.org/2000/09/xmldsig#:Signature' element is not declared. Alguem sabe o problema? Quote Link to comment Share on other sites More sharing options...
kapiaba Posted December 18, 2017 Report Share Posted December 18, 2017 Veja se ajuda: http://desenvolvimentonfse.forumeiros.com/t486-validacao-xml-xsd Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.