001 package net.provision.soap; 002 003 import org.jdom.*; 004 import org.jdom.input.*; 005 import org.jdom.output.*; 006 007 import java.io.*; 008 009 010 /** 011 * DOCUMENT ME! 012 * 013 * @author $author$ 014 * @version $Revision$ 015 */ 016 public class Bible { 017 String book; 018 String chapter; 019 String testament; 020 String verse; 021 022 public Bible() { 023 this("Old Testament", "Genesis", "1", "1"); 024 } 025 026 public Bible(String testament, String book, String chapter, String verse) { 027 this.testament = testament; 028 this.book = book; 029 this.chapter = chapter; 030 this.verse = verse; 031 032 try { 033 //retrieve the file from the jar file. 034 InputStream in = this.getClass().getResourceAsStream("KJVBible.xml"); 035 036 // Build the document with SAX and Xerces, no validation 037 SAXBuilder builder = new SAXBuilder(); 038 039 // Create the document 040 Document doc = builder.build(in); 041 042 Element bibleEL = doc.getRootElement(); 043 Element testamentEL = bibleEL.getChild("testament"); 044 045 if(testament.equals(testamentEL.getAttribute("value"))) { 046 Element bookEL = testamentEL.getChild("book"); 047 048 if(book.equals(bookEL.getAttribute("title"))) { 049 Element chapterEL = bookEL.getChild("chapter"); 050 051 if(chapter.equals(chapterEL.getChild("number"))) { 052 Element verseEL = chapterEL.getChild("verse"); 053 } 054 } 055 } 056 057 // Output the document, use standard formatter 058 XMLOutputter fmt = new XMLOutputter(); 059 fmt.output(doc, System.out); 060 } catch(Exception e) { 061 e.printStackTrace(); 062 } 063 } 064 }