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

DM Smith (JIRA) jira at crosswire.org
Thu Mar 10 07:29:03 MST 2011


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

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

The fix for the reported problem is rather simple:
Change:
parent.addContent(ele.getChildren());
with
parent.addContent(ele.removeChildren());

Note: the original code was wrong, even if it worked. getChildren returns only the Element content, thus no direct Text children. It should have been ele.getContent();

This fix shows another problem. ThML is defined as xml, but PILGRIMS is sloppy in having <br> rather than <br/>. I'm working on this problem.

I suspect that there are <p> rather than <p>...</p> too.

Adding the trapping of the exception was easy. JDom defines three different IllegalArgumentExceptions, so these needed to be caught. I also found it was good to trap RuntimeException, and am in the process of seeing what is causing that.

However trapping exceptions also showed a different problem: stripping out the xml markup left words without intervening spaces.


> 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