wood burning stoves 2.0
The moose likes XML and Related Technologies and the fly likes parse with commons digester Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "parse with commons digester" Watch "parse with commons digester" New topic

parse with commons digester

Carlos E Z Batistao

Joined: Mar 29, 2007
Posts: 1
i'm think this is right forum to post this doubt
if i'm wrong, i'm sorry

i try to parse a xml file with validation using schema, like this:
<dictionary xmlns="http://www.atlantico.com.br/projeto-xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.atlantico.com.br/projeto-xml layouts.xsd" version="1.0">
<comment />

but when i run the program, his throw a exception
org.xml.sax.SAXParseException: Document root element is missing.

if i remove the attribuits on tag directory, it's work!!

who can i make the parse with validation schema on xml file!?
in attach the code of my class to make a parse(or try ) heheehhe

public DictionaryParser(String filePathName) throws IOException, SAXException {

// instantiate Digester and disable XML validation
Digester digester = new Digester();

// instantiate AddressBookParser class
digester.addObjectCreate("dictionary", DictionaryParser.class );
// instantiate Contact class
digester.addObjectCreate("dictionary/entry", EntryXML.class );

// set different properties of Contact instance using specified methods
digester.addCallMethod("dictionary/entry/from", "setFrom", 0);
digester.addCallMethod("dictionary/entry/to", "setTo", 0);
digester.addCallMethod("dictionary/entry/comment", "setComment", 0);

// call 'addContact' method when the next 'address-book/contact' pattern is seen
digester.addSetNext("dictionary/entry", "addEntryInColleciton" );

// now that rules and actions are configured, start the parsing process
DictionaryParser abp = (DictionaryParser) digester.parse(new File(filePathName));

tks for help!!
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

i'm think this is right forum to post this doubt

We have an XML forum where this would be better placed. I'll move it there.

if i'm wrong, i'm sorry

Don't worry about it

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link: http://aspose.com/file-tools
subject: parse with commons digester
jQuery in Action, 3rd edition