Gostaria de pedir uma ajuda a quem já trabalho com isso.
Estou gerando o XML para envio da nota fiscal eletrônica (em lote) mas realmente ainda não estou entendendo muito bem como tudo isso funciona.
Gerei o XML (usando o manual de v400) e fui validar no site da SEFAZ RS (eles tem esse validar de de XML de NF-e), porém está dando erro, sem que é em relação ao Namespace mas não sei como solucionar isso.
Segue parte do código que gera o XMLString versaoEnviNFe = "1.10";
String nameSpace = "http://www.portalfiscal.inf.br/nfe";
Namespace par = Namespace.getNamespace(nameSpace);
Document documento = new Document();
Element enviNFe = new Element("enviNFe", par);
enviNFe.setAttribute("versao", versaoEnviNFe);
Element idLote = new Element("idLote", par);
idLote.setText(numeroLote);
enviNFe.addContent(idLote);
documento.setRootElement(enviNFe);
for (NotaFiscal nota : lista) {
Element NFe = new Element("NFe", par); // PARECE QUE O PROBLEMA ESTÁ AQUI
Namespace par1 = par; // apenas atribui o Namespace já declarado
enviNFe.addContent(NFe);
Endereco enderecoEmitente = nota.getEmitente().getEndereco();
String codigoMunicipioIBGE = enderecoEmitente.getCodigoMunicipio();
String chaveAcesso = Lib.getChaveAcessoNota(nota);
Date dataEmissaoNota = nota.getDataEmissao();
String codigoUnico = new SimpleDateFormat("dHHmmS").format(dataEmissaoNota);
String modeloNota = nota.getModeloDocumento(); // geralmente: 55
String serieNota = nota.getSerie();
String numeroNota = new DecimalFormat("000000000").format(nota.getNumero());
String codigoUF = Lib.getListaEstadoIBGE().get(enderecoEmitente.getUF()).getCodigo().toString();
String cnpjEmitente = nota.getEmitente().getIdentificador().replaceAll("[./-]", "");
String dv = Lib.getDigitosChaveAcessoNFe(chaveAcesso);
chaveAcesso = "NFe" + chaveAcesso + dv;
Element InfNfe = new Element("infNfe", par1);
InfNfe.setAttribute("versao", versaoEnviNFe);
InfNfe.setAttribute("id", chaveAcesso);
Element ide = new Element("ide", par1);
...
}
O erro apresentado no validador do SEFAZ RS:
PARSER XML: OK
TIPO DE MENSAGEM: Lote NF-e
SCHEMA: The element 'NFe' in namespace 'http://www.portalfiscal.inf.br/nfe' has invalid child element 'infNfe' in namespace 'http://www.portalfiscal.inf.br/nfe'. List of possible elements expected: 'http://www.portalfiscal.inf.br/nfe:infNFe'.
The element 'NFe' in namespace 'http://www.portalfiscal.inf.br/nfe' has invalid child element 'infNfe' in namespace 'http://www.portalfiscal.inf.br/nfe'. List of possible elements expected: 'http://www.portalfiscal.inf.br/nfe:infNFe'.
The element 'NFe' in namespace 'http://www.portalfiscal.inf.br/nfe' has invalid child element 'infNfe' in namespace 'http://www.portalfiscal.inf.br/nfe'. List of possible elements expected: 'http://www.portalfiscal.inf.br/nfe:infNFe'.
The element 'NFe' in namespace 'http://www.portalfiscal.inf.br/nfe' has invalid child element 'infNfe' in namespace 'http://www.portalfiscal.inf.br/nfe'. List of possible elements expected: 'http://www.portalfiscal.inf.br/nfe:infNFe'.
Alguém poderia dar um help?