[jsword-devel] [JIRA] Commented: (JS-173) Error reading GenBook (Pilgrim's Progress)

DM Smith (JIRA) jira at crosswire.org
Wed Mar 9 07:01:43 MST 2011


    [ http://www.crosswire.org/bugs/browse/JS-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14082#comment-14082 ] 

DM Smith commented on JS-173:
-----------------------------

The problem is in the code:
        Element parent = ele.getParentElement();
        parent.removeContent(ele);
        parent.addContent(ele.getChildren());
It throws an IllegalAddException (a RuntimeException) on the third line.
The fix is straightforward, it needs to be something like:

for each child in ele.getChildren
do
 ele.removeContent(child)
 parent.addContent(child);
done

The other problem is that ThMLFilter.parse does not trap the exception. The intention of toOSIS is to always return the text in the entry, even if it looks ugly. So it needs to trap all exceptions.

I should have a fix for both soon.

> Error reading GenBook (Pilgrim's Progress)
> ------------------------------------------
>
>                 Key: JS-173
>                 URL: http://www.crosswire.org/bugs/browse/JS-173
>             Project: JSword
>          Issue Type: Bug
>          Components: o.c.jsword.book.filter.thml
>    Affects Versions: 1.6.1
>         Environment: Windows and Android
>            Reporter: Martin Denham
>            Assignee: DM Smith
>
> I think this is a JSword error, unless I am doing something wrong.  I am getting an Exception when trying to read Pilgrim's Progress and have a simple way to reproduce it.
> Here is my test.  The only custom bit below is my getBook method.  The error occurs on the getSAXEventProvider line
> 	Book book = getBook("Pilgrim");
> 	Key key = book.getKey("THE FIRST STAGE");
> 	BookData data = new BookData(book, key);		
> 	SAXEventProvider osissep = data.getSAXEventProvider();
> Here is the StackTrace:
> org.jdom.IllegalAddException: The Content already has an existing parent "seg"
> 	at org.jdom.ContentList.add(ContentList.java:209)
> 	at org.jdom.ContentList.add(ContentList.java:131)
> 	at org.jdom.ContentList.addAll(ContentList.java:283)
> 	at org.jdom.ContentList.addAll(ContentList.java:253)
> 	at org.jdom.Element.addContent(Element.java:827)
> 	at org.crosswire.jsword.book.filter.thml.IgnoreTag.processContent(IgnoreTag.java:53)
> 	at org.crosswire.jsword.book.filter.thml.CustomHandler.endElement(CustomHandler.java:164)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
> 	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
> 	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
> 	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
> 	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
> 	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
> 	at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
> 	at org.crosswire.jsword.book.filter.thml.THMLFilter.parse(THMLFilter.java:154)
> 	at org.crosswire.jsword.book.filter.thml.THMLFilter.cleanParse(THMLFilter.java:109)
> 	at org.crosswire.jsword.book.filter.thml.THMLFilter.toOSIS(THMLFilter.java:70)
> 	at org.crosswire.jsword.book.sword.SwordGenBook.getOsisIterator(SwordGenBook.java:129)
> 	at org.crosswire.jsword.book.BookData.getOsisContent(BookData.java:157)
> 	at org.crosswire.jsword.book.BookData.getOsisFragment(BookData.java:100)
> 	at org.crosswire.jsword.book.BookData.getSAXEventProvider(BookData.java:113)
> 	at net.bible.service.sword.SwordApiTest.testReadPilgrimsProgress(SwordApiTest.java:128)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the jsword-devel mailing list