[jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/filter/thml s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Mon May 23 16:38:21 MST 2005
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/filter/thml
In directory www.crosswire.org:/tmp/cvs-serv32603/java/jsword/org/crosswire/jsword/book/filter/thml
Modified Files:
SyncTag.java DivTag.java
Log Message:
Fixed a strongs and robinsons ThML problem
Index: SyncTag.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/filter/thml/SyncTag.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** SyncTag.java 17 May 2005 00:43:15 -0000 1.9
--- SyncTag.java 23 May 2005 23:38:19 -0000 1.10
***************
*** 22,32 ****
package org.crosswire.jsword.book.filter.thml;
import org.crosswire.jsword.book.DataPolice;
import org.crosswire.jsword.book.OSISUtil;
import org.jdom.Element;
import org.xml.sax.Attributes;
/**
! * THML Tag to process the sync element.
*
* @see gnu.gpl.License for license details.
--- 22,43 ----
package org.crosswire.jsword.book.filter.thml;
+ import java.util.List;
+
import org.crosswire.jsword.book.DataPolice;
import org.crosswire.jsword.book.OSISUtil;
+ import org.jdom.Content;
import org.jdom.Element;
+ import org.jdom.Text;
import org.xml.sax.Attributes;
/**
! * THML Tag to process the sync element. A sync tag is always empty and
! * immediately follows what it marks. With types of Strongs and morph
! * these are to become w elements that surround the word that they modify.
! * This requires that we find the last text element and surround it with
! * a w element. If the last text element is already surrounded with a w
! * element then this is added to it. As a simplifying assumption, we will
! * assume that the text element is not contained by anything except perhaps
! * by a w element.
*
* @see gnu.gpl.License for license details.
***************
*** 55,76 ****
if ("Strongs".equals(type)) //$NON-NLS-1$
{
! Element w = OSISUtil.factory().createW();
! w.setAttribute(OSISUtil.ATTRIBUTE_W_LEMMA, OSISUtil.LEMMA_STRONGS + value);
! ele.addContent(w);
! return w;
}
! if ("Dict".equals(type)) //$NON-NLS-1$
{
! Element div = OSISUtil.factory().createDiv();
! div.setAttribute(OSISUtil.ATTRIBUTE_DIV_OSISID, "dict://" + value); //$NON-NLS-1$
! ele.addContent(div);
! return div;
}
! if ("morph".equals(type)) //$NON-NLS-1$
{
Element div = OSISUtil.factory().createDiv();
! div.setAttribute(OSISUtil.ATTRIBUTE_DIV_OSISID, "morph://" + value); //$NON-NLS-1$
ele.addContent(div);
return div;
--- 66,143 ----
if ("Strongs".equals(type)) //$NON-NLS-1$
{
! List siblings = ele.getContent();
! int size = siblings.size();
! if (size == 0)
! {
! return null;
! }
! Content lastEle = (Content) siblings.get(size - 1);
! if (lastEle instanceof Text)
! {
! Element w = OSISUtil.factory().createW();
! w.setAttribute(OSISUtil.ATTRIBUTE_W_LEMMA, OSISUtil.LEMMA_STRONGS + value);
! siblings.set(size - 1, w);
! w.addContent(lastEle);
! }
! else if (lastEle instanceof Element)
! {
! Element wEle = (Element) lastEle;
! if (wEle.getName().equals(OSISUtil.OSIS_ELEMENT_W))
! {
! StringBuffer buf = new StringBuffer();
! String strongsAttr = wEle.getAttributeValue(OSISUtil.ATTRIBUTE_W_LEMMA);
! if (strongsAttr != null)
! {
! buf.append(strongsAttr);
! buf.append(' ');
! }
! buf.append(OSISUtil.LEMMA_STRONGS);
! buf.append(value);
! wEle.setAttribute(OSISUtil.ATTRIBUTE_W_LEMMA, buf.toString());
! }
! }
! return null;
}
! if ("morph".equals(type)) //$NON-NLS-1$
{
! List siblings = ele.getContent();
! int size = siblings.size();
! if (size == 0)
! {
! return null;
! }
! Content lastEle = (Content) siblings.get(size - 1);
! if (lastEle instanceof Text)
! {
! Element w = OSISUtil.factory().createW();
! w.setAttribute(OSISUtil.ATTRIBUTE_W_MORPH, OSISUtil.MORPH_ROBINSONS + value);
! siblings.set(size - 1, w);
! w.addContent(lastEle);
! }
! else if (lastEle instanceof Element)
! {
! Element wEle = (Element) lastEle;
! if (wEle.getName().equals(OSISUtil.OSIS_ELEMENT_W))
! {
! StringBuffer buf = new StringBuffer();
! String strongsAttr = wEle.getAttributeValue(OSISUtil.ATTRIBUTE_W_MORPH);
! if (strongsAttr != null)
! {
! buf.append(strongsAttr);
! buf.append(' ');
! }
! buf.append(OSISUtil.MORPH_ROBINSONS);
! buf.append(value);
! wEle.setAttribute(OSISUtil.ATTRIBUTE_W_MORPH, buf.toString());
! }
! }
! return null;
}
! if ("Dict".equals(type)) //$NON-NLS-1$
{
Element div = OSISUtil.factory().createDiv();
! div.setAttribute(OSISUtil.ATTRIBUTE_DIV_OSISID, "dict://" + value); //$NON-NLS-1$
ele.addContent(div);
return div;
Index: DivTag.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/filter/thml/DivTag.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** DivTag.java 17 May 2005 00:43:15 -0000 1.7
--- DivTag.java 23 May 2005 23:38:19 -0000 1.8
***************
*** 48,51 ****
--- 48,66 ----
public Element processTag(Element ele, Attributes attrs)
{
+ // See if there are variant readings e.g. WHNU Mat 1.9
+ String typeAttr = attrs.getValue("type"); //$NON-NLS-1$
+ if ("variant".equals(typeAttr)) //$NON-NLS-1$
+ {
+ Element seg = OSISUtil.factory().createSeg();
+ seg.setAttribute(OSISUtil.ATTRIBUTE_SEG_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);
+ }
+ ele.addContent(seg);
+ return seg;
+ }
+
Element div = OSISUtil.factory().createDiv();
ele.addContent(div);
More information about the jsword-svn
mailing list