Problemas com commons digester

0 respostas
C

Fala galera, tudo bem!? :slight_smile:

seguinte, estou tentando fazer um parser de um arquivo de xml com esta api, e qdo meu arquivo está da seguinte maneira, o digester lê e faz o parser de boa…

<dictionary>
<entry>
<from>1010</from>
<to>11</to>
<comment />
</entry>
</dictionary>

mas qdo eu tenho o seguinte arquivo

<dictionary xmlns=“http://www.atlantico.com.br/projeto-xml” xmlnssi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.atlantico.com.br/projeto-xml layouts.xsd” version=“1.0”>
<entry>
<from>1010</from>
<to>11</to>
<comment />
</entry>
</dictionary>

qdo tento fazer o parser ele da o seguinte erro:
org.xml.sax.SAXParseException: Document root element is missing.

alguem saberia me dizer se na hora de implementar o meu parser eu esqueci de algo…
segue minha classe…

public DictionaryParser&#40;String filePathName&#41; throws IOException, SAXException &#123;
 		
 		// instantiate Digester and disable XML validation
         Digester digester = new Digester&#40;&#41;;
         digester.setValidating&#40;false&#41;;
         
         // instantiate AddressBookParser class
         digester.addObjectCreate&#40;"dictionary", DictionaryParser.class &#41;;
         // instantiate Contact class
         digester.addObjectCreate&#40;"dictionary/entry", EntryXML.class &#41;;
         
         // set different properties of Contact instance using specified methods
         digester.addCallMethod&#40;"dictionary/entry/from", "setFrom", 0&#41;;
         digester.addCallMethod&#40;"dictionary/entry/to", "setTo", 0&#41;;
         digester.addCallMethod&#40;"dictionary/entry/comment", "setComment", 0&#41;;
         
         // call 'addContact' method when the next 'address-book/contact' pattern is seen
         digester.addSetNext&#40;"dictionary/entry", "addEntryInColleciton" &#41;;
 
         // now that rules and actions are configured, start the parsing process
         DictionaryParser abp = &#40;DictionaryParser&#41; digester.parse&#40;new File&#40;filePathName&#41;&#41;;
 	&#125;

desde já agradeço a atenção de todos!! :grin:

Criado 22 de março de 2007
Respostas 0
Participantes 1