This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes parse with commons digester Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "parse with commons digester" Watch "parse with commons digester" New topic
Author

parse with commons digester

Carlos E Z Batistao
Greenhorn

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">
<entry>
<from>1010</from>
<to>11</to>
<comment />
</entry>
</dictionary>

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();
digester.setValidating(false);

// 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
Bartender

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: parse with commons digester
 
Similar Threads
Editor Application with Interpreter pattern
Commons Digester wildcards question
Playing with KeyPair
How to add String element to List Object using Digester
Jakarta commons Digester