• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wmixvideo / nfe / #7309

22 Sep 2025 01:04PM UTC coverage: 51.767%. First build
#7309

push

web-flow
Adaptação NT 2025.002 v1.20: ajustes IBSCBS/IS (#1080)

- **Criados** transformers `NFNotaInfoImpostoTributacaoIBSCBSTransformer` e `NFNotaInfoImpostoTributacaoISTransformer`, registrados em `DFRegistryMatcher`
- **Alteradas** inner classes do IBSCBS para `static`
- **Corrigido** posicionamento do campo `vIBS`: movido de `GIBSMun` para `NFNotaInfoItemImpostoIBSCBSTIBS`
- **Atualizado** `DFXMLValidador` para utilizar o diretório de schemas da versão 1.20
- **Incluídos** os `XSDs` faltantes da versão 1.20 (copiados da estrutura da versão anterior)
- **Corrigidos** getters da classe `NFNotaInfoItemImpostoIS` que estavam fazendo papel de setter
- **Corrigidos** validadores de 15_2 para 13_2
- **Padronizados** nomes dos getter/setter da propriedade uTrib da classe `NFNotaInfoItemImpostoIS`

Co-authored-by: Diego Fincatto <58352+fincatto@users.noreply.github.com>

4 of 27 new or added lines in 6 files covered. (14.81%)

14415 of 27846 relevant lines covered (51.77%)

0.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.05
/src/main/java/com/fincatto/documentofiscal/validadores/DFXMLValidador.java
1
package com.fincatto.documentofiscal.validadores;
2

3
import java.io.IOException;
4
import java.io.StringReader;
5
import java.net.URISyntaxException;
6
import java.net.URL;
7
import javax.xml.transform.stream.StreamSource;
8
import javax.xml.validation.Schema;
9
import javax.xml.validation.SchemaFactory;
10
import org.xml.sax.SAXException;
11

12
public final class DFXMLValidador {
×
13

14
    private static boolean valida(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
15
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_008i2/%s", xsd));
×
16
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
×
17
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
×
18
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
×
19
        return true;
×
20
    }
21

22
    public static boolean validaLote(final String arquivoXML) throws Exception {
23
        return DFXMLValidador.valida(arquivoXML, "enviNFe_v3.10.xsd");
×
24
    }
25

26
    public static boolean validaNota(final String arquivoXML) throws Exception {
27
        return DFXMLValidador.valida(arquivoXML, "nfe_v3.10.xsd");
×
28
    }
29

30
    public static boolean valida400(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
NEW
31
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_010b_NT2025_002_v1.20/%s", xsd));
×
32
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
×
33
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
×
34
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
×
35
        return true;
×
36
    }
37

38
    public static boolean validaLote400(final String arquivoXML) throws Exception {
39
        return DFXMLValidador.valida400(arquivoXML, "enviNFe_v4.00.xsd");
×
40
    }
41

42
    public static boolean validaNota400(final String arquivoXML) throws Exception {
43
        return DFXMLValidador.valida400(arquivoXML, "nfe_v4.00.xsd");
×
44
    }
45

46
    /**
47
     * Valida MDFe. Para evitar "org.xml.sax.SAXParseException", message:
48
     * "Current configuration of the parser doesn't allow a maxOccurs attribute
49
     * value to be set greater than the value 5.000", foi adicionado a linha
50
     * System.setProperty("jdk.xml.maxOccurLimit", "10000");
51
     *
52
     * @param xml
53
     * @param xsd
54
     * @return
55
     * @throws IOException
56
     * @throws SAXException
57
     * @throws URISyntaxException
58
     */
59
    private static boolean validaMDF(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
60
        System.setProperty("jdk.xml.maxOccurLimit", "20000");
1✔
61
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_MDFe_300b_NT022024/%s", xsd));
1✔
62
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
1✔
63
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
1✔
64
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
1✔
65
        return true;
1✔
66
    }
67

68
    public static boolean validaLoteMDFe(final String arquivoXML) throws Exception {
69
        return DFXMLValidador.validaMDF(arquivoXML, "enviMDFe_v3.00.xsd");
×
70
    }
71

72
    public static boolean validaMDFe(final String arquivoXML) throws Exception {
73
        return DFXMLValidador.validaMDF(arquivoXML, "mdfe_v3.00.xsd");
×
74
    }
75
    
76
    public static boolean validaMDFeProcessado(final String xml) throws Exception {
77
        return DFXMLValidador.validaMDF(xml, "procMDFe_v3.00.xsd");
1✔
78
    }
79

80
    public static boolean validaEventoMDFe(final String xml) throws Exception {
81
        return DFXMLValidador.validaMDF(xml, "eventoMDFe_v3.00.xsd");
×
82
    }
83

84
    public static boolean validaEventoPagamentoOperacaoMDFe(final String xml) throws Exception {
85
        return DFXMLValidador.validaMDF(xml, "evPagtoOperMDFe_v3.00.xsd");
×
86
    }
87

88
    private static boolean validaCTe(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
89
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_CTe_300a_NT2022.001/%s", xsd));
×
90
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
×
91
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
×
92
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
×
93
        return true;
×
94
    }
95

96
    public static boolean validaLoteCTe300(final String arquivoXML) throws Exception {
97
        return DFXMLValidador.validaCTe(arquivoXML, "enviCTe_v3.00.xsd");
×
98
    }
99

100
    public static boolean validaCTeOS300(final String arquivoXML) throws Exception {
101
        return DFXMLValidador.validaCTe(arquivoXML, "cteOS_v3.00.xsd");
×
102
    }
103

104
    public static boolean validaNotaCte(final String arquivoXML) throws Exception {
105
        return DFXMLValidador.validaCTe(arquivoXML, "cte_v3.00.xsd");
×
106
    }
107

108
    public static boolean validaEventoCTe300(final String arquivoXML) throws Exception {
109
        return DFXMLValidador.validaCTe(arquivoXML, "eventoCTe_v3.00.xsd");
×
110
    }
111

112
    public static boolean validaEventoCancelamentoCTe300(final String arquivoXML) throws Exception {
113
        return DFXMLValidador.validaCTe(arquivoXML, "evCancCTe_v3.00.xsd");
×
114
    }
115

116
    public static boolean validaEventoCancelamentoComprovanteEntregaCTe300(final String arquivoXML) throws Exception {
117
        return DFXMLValidador.validaCTe(arquivoXML, "evCancCECTe_v3.00.xsd");
×
118
    }
119

120
    public static boolean validaEventoCartaCorrecaoCTe300(final String arquivoXML) throws Exception {
121
        return DFXMLValidador.validaCTe(arquivoXML, "evCCeCTe_v3.00.xsd");
×
122
    }
123

124
    public static boolean validaEventoComprovanteEntregaCTe300(final String arquivoXML) throws Exception {
125
        return DFXMLValidador.validaCTe(arquivoXML, "evCECTe_v3.00.xsd");
×
126
    }
127

128
    public static boolean validaEventoEpecCTe300(final String arquivoXML) throws Exception {
129
        return DFXMLValidador.validaCTe(arquivoXML, "evEPECCTe_v3.00.xsd");
×
130
    }
131

132
    public static boolean validaEventoGtvCTe300(final String arquivoXML) throws Exception {
133
        return DFXMLValidador.validaCTe(arquivoXML, "evGTV_v3.00.xsd");
×
134
    }
135

136
    public static boolean validaEventoPrestacaoEmDesacordoCTe300(final String arquivoXML) throws Exception {
137
        return DFXMLValidador.validaCTe(arquivoXML, "evPrestDesacordo_v3.00.xsd");
×
138
    }
139

140
    public static boolean validaEventoRegistroMultimodalCTe300(final String arquivoXML) throws Exception {
141
        return DFXMLValidador.validaCTe(arquivoXML, "evRegMultimodal_v3.00.xsd");
×
142
    }
143

144
    private static boolean validaCTe400(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
145
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_CTe_400_NT2025.001_RTC_1.05/%s", xsd));
×
146
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
×
147
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
×
148
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
×
149
        return true;
×
150
    }
151

152
    public static boolean validaNotaCte400(final String arquivoXML) throws Exception {
153
        return DFXMLValidador.validaCTe400(arquivoXML, "cte_v4.00.xsd");
×
154
    }
155

156
    public static boolean validaNotaCTeOS400(final String arquivoXML) throws Exception {
157
        return DFXMLValidador.validaCTe400(arquivoXML, "cteOS_v4.00.xsd");
×
158
    }
159

160
    public static boolean validaEventoCTe400(final String arquivoXML) throws Exception {
161
        return DFXMLValidador.validaCTe400(arquivoXML, "eventoCTe_v4.00.xsd");
×
162
    }
163

164
    public static boolean validaEventoCancelamentoCTe400(final String arquivoXML) throws Exception {
165
        return DFXMLValidador.validaCTe400(arquivoXML, "evCancCTe_v4.00.xsd");
×
166
    }
167

168
    public static boolean validaEventoCancelamentoComprovanteEntregaCTe400(final String arquivoXML) throws Exception {
169
        return DFXMLValidador.validaCTe400(arquivoXML, "evCancCECTe_v4.00.xsd");
×
170
    }
171

172
    public static boolean validaEventoCartaCorrecaoCTe400(final String arquivoXML) throws Exception {
173
        return DFXMLValidador.validaCTe400(arquivoXML, "evCCeCTe_v4.00.xsd");
×
174
    }
175

176
    public static boolean validaEventoComprovanteEntregaCTe400(final String arquivoXML) throws Exception {
177
        return DFXMLValidador.validaCTe400(arquivoXML, "evCECTe_v4.00.xsd");
×
178
    }
179

180
    public static boolean validaEventoEpecCTe400(final String arquivoXML) throws Exception {
181
        return DFXMLValidador.validaCTe400(arquivoXML, "evEPECCTe_v4.00.xsd");
×
182
    }
183

184
    public static boolean validaEventoGtvCTe400(final String arquivoXML) throws Exception {
185
        return DFXMLValidador.validaCTe400(arquivoXML, "evGTV_v4.00.xsd");
×
186
    }
187

188
    public static boolean validaEventoPrestacaoEmDesacordoCTe400(final String arquivoXML) throws Exception {
189
        return DFXMLValidador.validaCTe400(arquivoXML, "evPrestDesacordo_v4.00.xsd");
×
190
    }
191

192
    public static boolean validaEventoRegistroMultimodalCTe400(final String arquivoXML) throws Exception {
193
        return DFXMLValidador.validaCTe400(arquivoXML, "evRegMultimodal_v4.00.xsd");
×
194
    }
195

196
    public static boolean validaEventoCancelamentoPrestacaoEmDesacordoCTe400(final String arquivoXML) throws Exception {
197
        return DFXMLValidador.validaCTe400(arquivoXML, "evCancPrestDesacordo_v4.00.xsd");
×
198
    }
199

200
    public static boolean validaEventoCancelamentoInsucessoEntregaCTe400(final String arquivoXML) throws Exception {
201
        return DFXMLValidador.validaCTe400(arquivoXML, "evCancIECTe_v4.00.xsd");
×
202
    }
203

204
    public static boolean validaEventoInsucessoEntregaCTe400(final String arquivoXML) throws Exception {
205
        return DFXMLValidador.validaCTe400(arquivoXML, "evIECTe_v4.00.xsd");
×
206
    }
207

208
    private static boolean validaDfe(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
209
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_NFeDistDFe_102/%s", xsd));
×
210
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
×
211
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
×
212
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
×
213
        return true;
×
214
    }
215
    private static boolean validaDistribuicaoCTe(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
216
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_CTeDistDFe_100/%s", xsd));
×
217
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
×
218
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
×
219
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
×
220
        return true;
×
221
    }
222
    public static boolean validaDistribuicaoCTe(final String arquivoXML) throws IOException, SAXException, URISyntaxException {
223
        return DFXMLValidador.validaDistribuicaoCTe(arquivoXML, "distDFeInt_v1.00.xsd");
×
224
    }
225

226
    private static boolean validaDistribuicaoMDFe(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
227
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_MDFeDistDFe_100/%s", xsd));
×
228
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
×
229
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
×
230
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
×
231
        return true;
×
232
    }
233
    public static boolean validaDistribuicaoMDFe(final String arquivoXML) throws IOException, SAXException, URISyntaxException {
234
        return DFXMLValidador.validaDistribuicaoMDFe(arquivoXML, "distDFeInt_v1.00.xsd");
×
235
    }
236
    
237
    public static boolean validaConsultaDfe(final String arquivoXML) throws Exception {
238
        return DFXMLValidador.validaDfe(arquivoXML, "distDFeInt_v1.01.xsd");
×
239
    }
240

241
    private static boolean validaEpec(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException {
242
        final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/Evento_EPEC_PL_v1.01/%s", xsd));
×
243
        final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
×
244
        final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString()));
×
245
        schema.newValidator().validate(new StreamSource(new StringReader(xml)));
×
246
        return true;
×
247
    }
248

249
    public static boolean validaEpec(final String arquivoXML) throws Exception {
250
        return DFXMLValidador.validaEpec(arquivoXML, "envEPEC_v1.00.xsd");
×
251
    }
252

253
    public static boolean validaEventoEpec(final String arquivoXML) throws Exception {
254
        return DFXMLValidador.validaEpec(arquivoXML, "EPEC_v1.00.xsd");
×
255
    }
256
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc