[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/filter/osis s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Tue May 24 18:12:37 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/filter/osis
In directory www.crosswire.org:/tmp/cvs-serv11115/java/jsword/org/crosswire/jsword/book/filter/osis

Modified Files:
	OSISFilter.java 
Log Message:
Fixed a problem of character entity references causing a parsing error.

Index: OSISFilter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/filter/osis/OSISFilter.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** OSISFilter.java	17 May 2005 00:43:17 -0000	1.17
--- OSISFilter.java	25 May 2005 01:12:35 -0000	1.18
***************
*** 31,35 ****
  import org.crosswire.jsword.book.OSISUtil;
  import org.crosswire.jsword.book.filter.Filter;
- import org.crosswire.jsword.book.filter.FilterException;
  import org.crosswire.jsword.passage.Key;
  import org.jdom.Document;
--- 31,34 ----
***************
*** 51,55 ****
       * @see org.crosswire.jsword.book.filter.Filter#toOSIS(org.crosswire.jsword.book.filter.BookDataListener, java.lang.String)
       */
!     public List toOSIS(Key key, String plain) throws FilterException
      {
          DataPolice.setKey(key);
--- 50,54 ----
       * @see org.crosswire.jsword.book.filter.Filter#toOSIS(org.crosswire.jsword.book.filter.BookDataListener, java.lang.String)
       */
!     public List toOSIS(Key key, String plain)
      {
          DataPolice.setKey(key);
***************
*** 57,61 ****
          try
          {
!             ele = parse(plain);
          }
          catch (Exception ex1)
--- 56,60 ----
          try
          {
!             ele = parse(XMLUtil.cleanAllEntities(plain));
          }
          catch (Exception ex1)
***************
*** 64,99 ****
                                "\non: " + plain); //$NON-NLS-1$
  
!             // Attempt to fix broken entities, that could be a low damage
!             // way to fix a broken input string
!             String cropped = XMLUtil.cleanAllEntities(plain);
  
              try
              {
!                 ele = parse(cropped);
              }
              catch (Exception ex2)
              {
!                 log.warn("Could not fix it by cleaning entities: " + ex2.getMessage()); //$NON-NLS-1$
! 
!                 // So just try to strip out all XML looking things
!                 String shawn = XMLUtil.cleanAllTags(cropped);
  
                  try
                  {
!                     ele = parse(shawn);
                  }
!                 catch (Exception ex3)
                  {
!                     log.warn("Could not fix it by cleaning tags: " + ex3.getMessage()); //$NON-NLS-1$
! 
!                     try
!                     {
!                         ele = OSISUtil.factory().createP();
!                         ele.addContent(plain);
!                     }
!                     catch (Exception ex4)
!                     {
!                         log.warn("no way. say it ain't so! " + ex4.getMessage()); //$NON-NLS-1$
!                     }
                  }
              }
--- 63,85 ----
                                "\non: " + plain); //$NON-NLS-1$
  
!             // So just try to strip out all XML looking things
!             String shawn = XMLUtil.cleanAllTags(plain);
  
              try
              {
!                 ele = parse(shawn);
              }
              catch (Exception ex2)
              {
!                 log.warn("Could not fix it by cleaning tags: " + ex2.getMessage()); //$NON-NLS-1$
  
                  try
                  {
!                     ele = OSISUtil.factory().createP();
!                     ele.addContent(plain);
                  }
!                 catch (Exception ex4)
                  {
!                     log.warn("no way. say it ain't so! " + ex4.getMessage()); //$NON-NLS-1$
                  }
              }



More information about the jsword-svn mailing list