Pessoal, boa tarde.
Estou tentando ler um arquivo XML referente à NFe. Consegui ler varias partes desse XML. Entretanto, quando vou ler um elemento que está duplicado no XML tenho um erro:
Exception in thread "main" com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$DuplicateFieldException: det
---- Debugging information ----
duplicate-field : det
class : model.NFeProc
required-type : model.InfNFe
path : /nfeProc/NFe/infNFe/det[2]
-------------------------------
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$SeenFields.add(AbstractReflectionConverter.java:322)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:234)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:246)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:218)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:246)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:218)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:162)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:82)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:137)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:923)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:909)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853)
at controller.NFeProcController.getNFeProc(NFeProcController.java:20)
at teste.TestaInfNFe.main(TestaInfNFe.java:14)
Java Result: 1
Estou lendo este trecho de XML através da API XStream:
<PIS>
<PISOutr>
<CST>99</CST>
<vBC>8.37</vBC>
<pPIS>1.65</pPIS>
<vPIS>0.13</vPIS>
</PISOutr>
</PIS>
<COFINS>
<COFINSOutr>
<CST>99</CST>
<vBC>8.37</vBC>
<pCOFINS>7.60</pCOFINS>
<vCOFINS>0.63</vCOFINS>
</COFINSOutr>
</COFINS>
Segundo o erro, este fala de duplicação. Mas como faço pra resolver isso? Queria a dica de vocês, sugestão. Alguém ja teve este problema pra ler XML’s com XStream?
O XML é enorme, então postei apenas parte do trecho que da problemas. Lembrando que, se eu tirar os elementos que se repetem, vai blza… Fiz várias composições nas classes de modelo (beans). Tem como alterar no Xstream o nome de algum elemento (no java claro, pois no xml nao posso alterar nada…rs)
Desculpa a ignorância.
Agradeço desde já pela ajuda.