[jsword-svn] r1009 - in trunk/jsword/src: main/java/org/crosswire/jsword/book main/java/org/crosswire/jsword/book/basic main/java/org/crosswire/jsword/book/filter/gbf main/java/org/crosswire/jsword/book/filter/plaintext main/java/org/crosswire/jsword/book/filter/thml main/java/org/crosswire/jsword/book/readings main/java/org/crosswire/jsword/book/sword main/java/org/crosswire/jsword/examples test/java/org/crosswire/jsword/book

dmsmith at crosswire.org dmsmith at crosswire.org
Tue Feb 21 05:56:16 MST 2006


Author: dmsmith
Date: 2006-02-21 05:55:43 -0700 (Tue, 21 Feb 2006)
New Revision: 1009

Added:
   trunk/jsword/src/main/java/org/crosswire/jsword/examples/ModToOsis.java
Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/gbf/GBFTags.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/BTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/BlockquoteTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CenterTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CitationTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/DivTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/FontTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ForeignTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ITag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/NoteTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/OlTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ScripRefTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SmallTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SupTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SyncTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ThTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/UTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/UlTag.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java
   trunk/jsword/src/test/java/org/crosswire/jsword/book/OsisTest.java
Log:
Updating to OSIS 2.1

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -148,6 +148,7 @@
     public static final String OSIS_ELEMENT_ITEM = "item"; //$NON-NLS-1$
     public static final String OSIS_ELEMENT_FOREIGN = "foreign"; //$NON-NLS-1$
     public static final String OSIS_ELEMENT_W = "w"; //$NON-NLS-1$
+    public static final String OSIS_ELEMENT_CHAPTER = "chapter"; //$NON-NLS-1$
     public static final String OSIS_ELEMENT_VERSE = "verse"; //$NON-NLS-1$
     public static final String OSIS_ELEMENT_CELL = "cell"; //$NON-NLS-1$
     public static final String OSIS_ELEMENT_DIV = "div"; //$NON-NLS-1$
@@ -163,22 +164,18 @@
 
     public static final String ATTRIBUTE_TEXT_OSISIDWORK = "osisIDWork"; //$NON-NLS-1$
     public static final String ATTRIBUTE_WORK_OSISWORK = "osisWork"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_VERSE_OSISID = "osisID"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_DIV_OSISID = "osisID"; //$NON-NLS-1$
+    public static final String OSIS_ATTR_OSISID = "osisID"; //$NON-NLS-1$
     public static final String OSIS_ATTR_SID = "sID"; //$NON-NLS-1$
     public static final String OSIS_ATTR_EID = "eID"; //$NON-NLS-1$
     public static final String ATTRIBUTE_W_LEMMA = "lemma"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_HI_TYPE = "type"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_Q_TYPE = "type"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_LIST_TYPE = "type"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_SEG_TYPE = "type"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_SEG_SUBTYPE = "subType"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_REFERENCE_OSISREF = "osisRef"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_NOTE_TYPE = "type"; //$NON-NLS-1$
+    public static final String OSIS_ATTR_TYPE = "type"; //$NON-NLS-1$
+    public static final String OSIS_ATTR_SUBTYPE = "subType"; //$NON-NLS-1$
+    public static final String OSIS_ATTR_REF = "osisRef"; //$NON-NLS-1$
     public static final String ATTRIBUTE_SPEAKER_WHO = "who"; //$NON-NLS-1$
     public static final String ATTRIBUTE_W_MORPH = "morph"; //$NON-NLS-1$
     public static final String ATTRIBUTE_OSISTEXT_OSISIDWORK = "osisIDWork"; //$NON-NLS-1$
-    public static final String ATTRIBUTE_DIV_LANG = "lang"; //$NON-NLS-1$
+    public static final String OSIS_ATTR_LANG = "xml:lang"; //$NON-NLS-1$
+    public static final String ATTRIBUTE_DIV_BOOK = "book"; //$NON-NLS-1$
 
     /**
      * Prefix for OSIS IDs that refer to Bibles
@@ -202,12 +199,12 @@
     {
     }
 
-    private static ObjectFactory factory = new ObjectFactory();
+    private static OSISFactory factory = new OSISFactory();
 
     /**
-     * An accessor for the ObjectFactory that creates OSIS objects
+     * An accessor for the OSISFactory that creates OSIS objects
      */
-    public static ObjectFactory factory()
+    public static OSISFactory factory()
     {
         return factory;
     }
@@ -215,7 +212,7 @@
     /**
      * A generic way of creating empty Elements of various types
      */
-    public static class ObjectFactory
+    public static class OSISFactory
     {
         /**
          * 
@@ -601,7 +598,7 @@
         if (ele.getName().equals(OSIS_ELEMENT_VERSE))
         {
             // If the element is an OSIS Verse then this is fairly easy
-            String osisid = ele.getAttributeValue(ATTRIBUTE_VERSE_OSISID);
+            String osisid = ele.getAttributeValue(OSIS_ATTR_OSISID);
 
             try
             {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/DefaultBookMetaData.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -202,7 +202,7 @@
      */
     public Document toOSIS()
     {
-        OSISUtil.ObjectFactory factory = OSISUtil.factory();
+        OSISUtil.OSISFactory factory = OSISUtil.factory();
         Element ele = factory.createTable();
         addRow(ele, "Initials", getInitials()); //$NON-NLS-1$
         addRow(ele, "Description", getFullName()); //$NON-NLS-1$
@@ -218,13 +218,13 @@
             return;
         }
 
-        OSISUtil.ObjectFactory factory = OSISUtil.factory();
+        OSISUtil.OSISFactory factory = OSISUtil.factory();
 
         Element rowEle = factory.createRow();
 
         Element nameEle = factory.createCell();
         Element hiEle = factory.createHI();
-        hiEle.setAttribute(OSISUtil.ATTRIBUTE_HI_TYPE, OSISUtil.HI_BOLD);
+        hiEle.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_BOLD);
         nameEle.addContent(hiEle);
         Element valueElement = factory.createCell();
         rowEle.addContent(nameEle);

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/gbf/GBFTags.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/gbf/GBFTags.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/gbf/GBFTags.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -26,7 +26,7 @@
 import org.crosswire.common.util.ClassUtil;
 import org.crosswire.jsword.book.DataPolice;
 import org.crosswire.jsword.book.OSISUtil;
-import org.crosswire.jsword.book.OSISUtil.ObjectFactory;
+import org.crosswire.jsword.book.OSISUtil.OSISFactory;
 import org.crosswire.jsword.passage.KeyFactory;
 import org.crosswire.jsword.passage.NoSuchKeyException;
 import org.crosswire.jsword.passage.Passage;
@@ -86,7 +86,7 @@
         public void updateOsisStack(LinkedList stack)
         {
             Element hi = OSIS_FACTORY.createHI();
-            hi.setAttribute(OSISUtil.ATTRIBUTE_HI_TYPE, OSISUtil.HI_BOLD);
+            hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_BOLD);
 
             Element current = (Element) stack.get(0);
             current.addContent(hi);
@@ -115,7 +115,7 @@
             try
             {
                 Passage ref = (Passage) KEY_FACTORY.getKey(refstr);
-                seg.setAttribute(OSISUtil.ATTRIBUTE_REFERENCE_OSISREF, ref.getOsisRef());
+                seg.setAttribute(OSISUtil.OSIS_ATTR_REF, ref.getOsisRef());
             }
             catch (NoSuchKeyException ex)
             {
@@ -182,7 +182,7 @@
         {
             Element current = (Element) stack.get(0);
             Element note = OSIS_FACTORY.createNote();
-            note.setAttribute(OSISUtil.ATTRIBUTE_NOTE_TYPE, OSISUtil.NOTETYPE_STUDY);
+            note.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.NOTETYPE_STUDY);
 
             current.addContent(note);
             stack.addFirst(note);
@@ -291,7 +291,7 @@
         public void updateOsisStack(LinkedList stack)
         {
             Element hi = OSIS_FACTORY.createHI();
-            hi.setAttribute(OSISUtil.ATTRIBUTE_HI_TYPE, OSISUtil.HI_ITALIC);
+            hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_ITALIC);
 
             Element current = (Element) stack.get(0);
             current.addContent(hi);
@@ -319,7 +319,7 @@
         {
             // LATER(joe): is div the right thing?
             Element seg = OSIS_FACTORY.createSeg();
-            seg.setAttribute(OSISUtil.ATTRIBUTE_SEG_TYPE, OSISUtil.SEG_JUSTIFYRIGHT);
+            seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.SEG_JUSTIFYRIGHT);
 
             Element current = (Element) stack.get(0);
             current.addContent(seg);
@@ -627,7 +627,7 @@
         public void updateOsisStack(LinkedList stack)
         {
             Element note = OSIS_FACTORY.createNote();
-            note.setAttribute(OSISUtil.ATTRIBUTE_NOTE_TYPE, OSISUtil.NOTETYPE_STUDY);
+            note.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.NOTETYPE_STUDY);
 
             Element current = (Element) stack.get(0);
             current.addContent(note);
@@ -710,7 +710,7 @@
         public void updateOsisStack(LinkedList stack)
         {
             Element hi = OSIS_FACTORY.createHI();
-            hi.setAttribute(OSISUtil.ATTRIBUTE_HI_TYPE, OSISUtil.HI_UNDERLINE);
+            hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_UNDERLINE);
 
             Element current = (Element) stack.get(0);
             current.addContent(hi);
@@ -726,5 +726,5 @@
     /**
      * To create OSIS DOM nodes.
      */
-    protected static final ObjectFactory OSIS_FACTORY = OSISUtil.factory();
+    protected static final OSISFactory OSIS_FACTORY = OSISUtil.factory();
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -46,7 +46,7 @@
      */
     public List toOSIS(Key key, String plain)
     {
-        OSISUtil.ObjectFactory factory = OSISUtil.factory();
+        OSISUtil.OSISFactory factory = OSISUtil.factory();
         Element ele = factory.createDiv();
 
         String[] lines = StringUtil.splitAll(plain, '\n');

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/BTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/BTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/BTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element hi = OSISUtil.factory().createHI();
-        hi.setAttribute(OSISUtil.ATTRIBUTE_HI_TYPE, OSISUtil.HI_BOLD);
+        hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_BOLD);
         ele.addContent(hi);
         return hi;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/BlockquoteTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/BlockquoteTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/BlockquoteTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element q = OSISUtil.factory().createQ();
-        ele.setAttribute(OSISUtil.ATTRIBUTE_Q_TYPE, OSISUtil.Q_BLOCK);
+        ele.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.Q_BLOCK);
         ele.addContent(q);
         return q;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CenterTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CenterTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CenterTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element seg = OSISUtil.factory().createSeg();
-        seg.setAttribute(OSISUtil.ATTRIBUTE_SEG_TYPE, OSISUtil.SEG_CENTER);
+        seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.SEG_CENTER);
         ele.addContent(seg);
         return seg;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CitationTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CitationTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CitationTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element q = OSISUtil.factory().createQ();
-        ele.setAttribute(OSISUtil.ATTRIBUTE_Q_TYPE, OSISUtil.Q_BLOCK);
+        ele.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.Q_BLOCK);
         ele.addContent(q);
         return q;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/DivTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/DivTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/DivTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -52,11 +52,11 @@
         if ("variant".equals(typeAttr)) //$NON-NLS-1$
         {
             Element seg = OSISUtil.factory().createSeg();
-            seg.setAttribute(OSISUtil.ATTRIBUTE_SEG_TYPE, OSISUtil.VARIANT_TYPE);
+            seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.VARIANT_TYPE);
             String classAttr = attrs.getValue("class"); //$NON-NLS-1$
             if (classAttr != null)
             {
-                seg.setAttribute(OSISUtil.ATTRIBUTE_SEG_SUBTYPE, OSISUtil.VARIANT_CLASS + classAttr);
+                seg.setAttribute(OSISUtil.OSIS_ATTR_SUBTYPE, OSISUtil.VARIANT_CLASS + classAttr);
             }
             ele.addContent(seg);
             return seg;

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/FontTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/FontTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/FontTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -71,7 +71,7 @@
         String type = buf.toString();
         if (type != null)
         {
-            seg.setAttribute(OSISUtil.ATTRIBUTE_SEG_TYPE, type);
+            seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, type);
         }
         else
         {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ForeignTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ForeignTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ForeignTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -52,7 +52,7 @@
         String lang = attrs.getValue("lang"); //$NON-NLS-1$
         if (lang != null)
         {
-            div.setAttribute(OSISUtil.ATTRIBUTE_DIV_LANG, lang);
+            div.setAttribute(OSISUtil.OSIS_ATTR_LANG, lang);
         }
 
         ele.addContent(div);

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ITag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ITag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ITag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element hi = OSISUtil.factory().createHI();
-        hi.setAttribute(OSISUtil.ATTRIBUTE_HI_TYPE, OSISUtil.HI_ITALIC);
+        hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_ITALIC);
         ele.addContent(hi);
         return hi;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/NoteTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/NoteTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/NoteTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element note = OSISUtil.factory().createNote();
-        note.setAttribute(OSISUtil.ATTRIBUTE_NOTE_TYPE, OSISUtil.NOTETYPE_STUDY);
+        note.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.NOTETYPE_STUDY);
         ele.addContent(note);
         return note;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/OlTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/OlTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/OlTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element list = OSISUtil.factory().createList();
-        ele.setAttribute(OSISUtil.ATTRIBUTE_LIST_TYPE, OSISUtil.LIST_ORDERED);
+        ele.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.LIST_ORDERED);
         ele.addContent(list);
         return list;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ScripRefTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ScripRefTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ScripRefTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -62,7 +62,7 @@
             {
                 Passage ref = (Passage) keyf.getKey(refstr);
                 String osisname = ref.getOsisRef();
-                reference.setAttribute(OSISUtil.ATTRIBUTE_REFERENCE_OSISREF, osisname);
+                reference.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname);
             }
             catch (NoSuchKeyException ex)
             {
@@ -90,7 +90,7 @@
         {
             Passage ref = (Passage) keyf.getKey(refstr);
             String osisname = ref.getOsisRef();
-            ele.setAttribute(OSISUtil.ATTRIBUTE_REFERENCE_OSISREF, osisname);
+            ele.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname);
         }
         catch (NoSuchKeyException ex)
         {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SmallTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SmallTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SmallTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element seg = OSISUtil.factory().createSeg();
-        seg.setAttribute(OSISUtil.ATTRIBUTE_SEG_TYPE, OSISUtil.SEG_SMALL);
+        seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.SEG_SMALL);
         ele.addContent(seg);
         return seg;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SupTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SupTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SupTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element seg = OSISUtil.factory().createSeg();
-        seg.setAttribute(OSISUtil.ATTRIBUTE_SEG_TYPE, OSISUtil.SEG_SUPERSCRIPT);
+        seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.SEG_SUPERSCRIPT);
         ele.addContent(seg);
         return seg;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SyncTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SyncTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SyncTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -138,7 +138,7 @@
         if ("Dict".equals(type)) //$NON-NLS-1$
         {
             Element div = OSISUtil.factory().createDiv();
-            div.setAttribute(OSISUtil.ATTRIBUTE_DIV_OSISID, "dict://" + value); //$NON-NLS-1$
+            div.setAttribute(OSISUtil.OSIS_ATTR_OSISID, "dict://" + value); //$NON-NLS-1$
             ele.addContent(div);
             return div;
         }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ThTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ThTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/ThTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -51,7 +51,7 @@
         ele.addContent(cell);
 
         Element hi = OSISUtil.factory().createHI();
-        hi.setAttribute(OSISUtil.ATTRIBUTE_HI_TYPE, OSISUtil.HI_BOLD);
+        hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_BOLD);
         cell.addContent(hi);
         return hi;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/UTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/UTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/UTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element hi = OSISUtil.factory().createHI();
-        hi.setAttribute(OSISUtil.ATTRIBUTE_HI_TYPE, OSISUtil.HI_UNDERLINE);
+        hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_UNDERLINE);
         ele.addContent(hi);
         return hi;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/UlTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/UlTag.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/UlTag.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -48,7 +48,7 @@
     public Element processTag(Element ele, Attributes attrs)
     {
         Element list = OSISUtil.factory().createList();
-        ele.setAttribute(OSISUtil.ATTRIBUTE_LIST_TYPE, OSISUtil.LIST_UNORDERED);
+        ele.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.LIST_UNORDERED);
         ele.addContent(list);
         return list;
     }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -161,7 +161,7 @@
                     VerseRange range = (VerseRange) it.next();
 
                     Element reading = OSISUtil.factory().createReference();
-                    reading.setAttribute(OSISUtil.ATTRIBUTE_REFERENCE_OSISREF, range.getOsisRef());
+                    reading.setAttribute(OSISUtil.OSIS_ATTR_REF, range.getOsisRef());
                     reading.addContent(range.getName());
 
                     Element item = OSISUtil.factory().createItem();

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -260,7 +260,7 @@
 
     public Element toOSIS()
     {
-        OSISUtil.ObjectFactory factory = OSISUtil.factory();
+        OSISUtil.OSISFactory factory = OSISUtil.factory();
 
         Element rowEle = factory.createRow();
 
@@ -390,7 +390,7 @@
         return copy;
     }
 
-    private List processLines(OSISUtil.ObjectFactory factory, String aValue)
+    private List processLines(OSISUtil.OSISFactory factory, String aValue)
     {
         List list = new ArrayList();
         String [] lines = StringUtil.splitAll(aValue, '\n');

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -149,7 +149,7 @@
      */
     public Element toOSIS()
     {
-        OSISUtil.ObjectFactory factory = OSISUtil.factory();
+        OSISUtil.OSISFactory factory = OSISUtil.factory();
         Element ele = factory.createTable();
         toOSIS(factory, ele, "BasicInfo", BASIC_INFO); //$NON-NLS-1$
         toOSIS(factory, ele, "LangInfo", LANG_INFO); //$NON-NLS-1$
@@ -560,7 +560,7 @@
     /**
      * Build an ordered map so that it displays in a consistent order.
      */
-    private void toOSIS(OSISUtil.ObjectFactory factory, Element ele, String aTitle, ConfigEntryType[] category)
+    private void toOSIS(OSISUtil.OSISFactory factory, Element ele, String aTitle, ConfigEntryType[] category)
     {
         Element title = null;
         for (int i = 0; i < category.length; i++)

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -116,7 +116,7 @@
         // If we get here then the text is not marked up with verse
         // In this case we add the verse markup.
         Element everse = OSISUtil.factory().createVerse();
-        everse.setAttribute(OSISUtil.ATTRIBUTE_VERSE_OSISID, key.getOsisID());
+        everse.setAttribute(OSISUtil.OSIS_ATTR_OSISID, key.getOsisID());
         div.addContent(everse);
         super.addOSIS(key, everse, osisContent);
     }

Added: trunk/jsword/src/main/java/org/crosswire/jsword/examples/ModToOsis.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/ModToOsis.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/ModToOsis.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -0,0 +1,149 @@
+package org.crosswire.jsword.examples;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.Iterator;
+
+import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookException;
+import org.crosswire.jsword.book.Books;
+import org.crosswire.jsword.book.OSISUtil;
+import org.crosswire.jsword.passage.BibleInfo;
+import org.crosswire.jsword.passage.Key;
+import org.crosswire.jsword.passage.NoSuchKeyException;
+import org.crosswire.jsword.passage.NoSuchVerseException;
+import org.crosswire.jsword.passage.Verse;
+
+public class ModToOsis
+{
+    /**
+     * The name of a Bible to find
+     */
+    private static final String BIBLE_NAME = "KJV"; //$NON-NLS-1$
+    private static final String BIBLE_RANGE = "Gen-Rev"; //$NON-NLS-1$
+
+    /**
+     * @param args
+     */
+    public static void main(String[] args)
+    {
+        Books books = Books.installed();
+        Book bible = books.getBook(BIBLE_NAME);
+        int lastBook = -1;
+        int lastChapter = -1;
+        StringBuffer buf = null;
+        
+        try
+        {
+            Key key = bible.getKey(BIBLE_RANGE);
+
+            // Get a verse iterator
+            Iterator iter = key.iterator();
+            while (iter.hasNext())
+            {
+                Verse verse = (Verse) iter.next();
+                String raw = bible.getRawData(verse);
+                String osisID = verse.getOsisID();
+
+                int currentBook = verse.getBook();
+                int currentChapter = verse.getChapter();
+                if (lastBook != currentBook)
+                {
+                    if (lastBook != -1)
+                    {
+                        if (currentChapter == 1)
+                        {
+                            buf.append("</").append(OSISUtil.OSIS_ELEMENT_CHAPTER).append(">\n"); //$NON-NLS-1$ //$NON-NLS-2$
+                        }
+                        buf.append("</").append(OSISUtil.OSIS_ELEMENT_DIV).append(">\n"); //$NON-NLS-1$ //$NON-NLS-2$
+                        Writer writer = new OutputStreamWriter(new FileOutputStream(BibleInfo.getOSISName(lastBook) + ".xml"), "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+                        writer.write(buf.toString());
+                        writer.close();
+                    }
+
+                    buf = new StringBuffer();
+
+                    buf.append('<').append(OSISUtil.OSIS_ELEMENT_DIV);
+                    buf.append(' ');
+                    buf.append(OSISUtil.OSIS_ATTR_TYPE).append("=\"").append(OSISUtil.ATTRIBUTE_DIV_BOOK); //$NON-NLS-1$
+                    buf.append("\" "); //$NON-NLS-1$
+                    buf.append(OSISUtil.OSIS_ATTR_OSISID).append("=\"").append(BibleInfo.getOSISName(currentBook));  //$NON-NLS-1$
+                    buf.append("\">\n"); //$NON-NLS-1$
+                }
+
+                if (lastBook != currentBook || lastChapter != currentChapter)
+                {
+                    if (currentChapter != 1)
+                    {
+                        buf.append("</").append(OSISUtil.OSIS_ELEMENT_CHAPTER).append(">\n"); //$NON-NLS-1$ //$NON-NLS-2$
+                    }
+                    buf.append('<').append(OSISUtil.OSIS_ELEMENT_CHAPTER);
+                    buf.append(' ');
+                    buf.append(OSISUtil.OSIS_ATTR_OSISID).append("=\"").append(BibleInfo.getOSISName(currentBook)).append('.').append(currentChapter);  //$NON-NLS-1$
+                    buf.append("\">"); //$NON-NLS-1$
+                }
+
+                /* Output the verse */
+                buf.append('<').append(OSISUtil.OSIS_ELEMENT_VERSE);
+                buf.append(' ');
+                buf.append(OSISUtil.OSIS_ATTR_OSISID).append("=\"").append(osisID);  //$NON-NLS-1$
+                buf.append("\" "); //$NON-NLS-1$
+                buf.append(OSISUtil.OSIS_ATTR_SID).append("=\"").append(osisID); //$NON-NLS-1$
+                buf.append("\"/>"); //$NON-NLS-1$
+                buf.append(raw);
+                buf.append('<').append(OSISUtil.OSIS_ELEMENT_VERSE);
+                buf.append(' ');
+                buf.append(OSISUtil.OSIS_ATTR_EID).append("=\"").append(osisID); //$NON-NLS-1$
+                buf.append("\"/>"); //$NON-NLS-1$               
+
+                if (lastChapter != currentChapter)
+                {
+                    lastChapter = currentChapter;
+                }
+
+                if (lastBook != currentBook)
+                {
+                    lastBook = currentBook;
+                }
+            }
+
+            buf.append("</").append(OSISUtil.OSIS_ELEMENT_CHAPTER).append(">\n"); //$NON-NLS-1$ //$NON-NLS-2$
+            buf.append("</").append(OSISUtil.OSIS_ELEMENT_DIV).append(">\n"); //$NON-NLS-1$ //$NON-NLS-2$
+            Writer writer = new OutputStreamWriter(new FileOutputStream(BibleInfo.getOSISName(lastBook) + ".xml"), "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+            writer.write(buf.toString());
+            writer.close();
+        }
+        catch (BookException e)
+        {
+            e.printStackTrace();
+        }
+        catch (NoSuchVerseException e)
+        {
+            e.printStackTrace();
+        }
+        catch (NoSuchKeyException e)
+        {
+            e.printStackTrace();
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            // XXX Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (FileNotFoundException e)
+        {
+            // XXX Auto-generated catch block
+            e.printStackTrace();
+        }
+        catch (IOException e)
+        {
+            // XXX Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+}

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/OsisTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/OsisTest.java	2006-02-21 12:52:04 UTC (rev 1008)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/OsisTest.java	2006-02-21 12:55:43 UTC (rev 1009)
@@ -54,7 +54,7 @@
         seg.addContent("In the beginning God created the heaven and the earth."); //$NON-NLS-1$
 
         Element verse = OSISUtil.factory().createVerse();
-        verse.setAttribute(OSISUtil.ATTRIBUTE_VERSE_OSISID, "Gen.1.1"); //$NON-NLS-1$
+        verse.setAttribute(OSISUtil.OSIS_ATTR_OSISID, "Gen.1.1"); //$NON-NLS-1$
         verse.addContent(seg);
 
         Element div = OSISUtil.factory().createDiv();



More information about the jsword-svn mailing list