<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 10, 2014, at 11:32 AM, Matěj Cepl &lt;<a href="mailto:mcepl@redhat.com">mcepl@redhat.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Thu, 2014-04-10 at 10:09 -0400, Karl Kleinpaste wrote:<br><blockquote type="cite">I got a Xiphos crash report this morning from someone using CzeCSP. &nbsp;The<br>error is that there are xref encoding glitches that Sword fails to<br>parse, which cause Xiphos to crash when trying to process them. &nbsp;Oops.<br></blockquote><br>I am the author of CzeCSP conversion into OSIS XML format. The problem<br>is that I don’t have in my source texts anything to hang on other than a<br>free text. I have absolutely no clue who to do the parsing in XSLT<br>(which is what I used for XML-to-XML conversion) and I will have a<br>really hard time to parse this free text in Python (but I may try<br>eventually; it has been<br><a href="https://luther.ceplovi.cz/bugzilla/show_bug.cgi?id=180">https://luther.ceplovi.cz/bugzilla/show_bug.cgi?id=180</a> for some time).<br></blockquote><div><br></div>In your xslt it is possible to call Java code. Here is how I do it using Xalan and JSword:</div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp;&lt;xsl:stylesheet</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</a>"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; version="1.0"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; xmlns:jsword="<a href="http://xml.apache.org/xalan/java">http://xml.apache.org/xalan/java</a>"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; extension-element-prefixes="jsword"&gt;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">...</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><div style="margin: 0px;">&nbsp;&nbsp;&lt;!-- Create a versification from which verse numbers are understood --&gt;</div><div style="margin: 0px;">&nbsp; &lt;xsl:variable name="v11nf" select="jsword:org.crosswire.jsword.versification.system.Versifications.instance()"/&gt;</div><div style="margin: 0px;">&nbsp; &lt;!-- Create a global key factory from which OSIS <span style="text-decoration: underline">ids</span> will be generated --&gt;</div><div style="margin: 0px;">&nbsp; &lt;xsl:variable name="<span style="text-decoration: underline">keyf</span>" select="jsword:org.crosswire.jsword.passage.PassageKeyFactory.instance()"/&gt;</div><div style="margin: 0px;">&nbsp; &lt;!-- Create a global number shaper that can transform 0-9 into other number systems. --&gt;</div><div style="margin: 0px;">&nbsp; &lt;xsl:variable name="shaper" select="jsword:org.crosswire.common.icu.NumberShaper.new()"/&gt;</div><div style="margin: 0px; min-height: 15px;">...</div><div style="margin: 0px; min-height: 15px;"><div style="margin: 0px;">&nbsp;&nbsp;&lt;xsl:template match="verse" mode="print-notes"&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &lt;xsl:if test=".//note[not(@type) or not(@type = 'x-strongsMarkup')]"&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &nbsp; &lt;xsl:variable name="versification" select="jsword:getVersification($v11nf, $v11n)"/&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &nbsp; &lt;xsl:variable name="passage" select="jsword:getValidKey($keyf, $versification, @osisID)"/&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &nbsp; &lt;a href="#{substring-before(concat(@osisID, ' '), ' ')}"&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:value-of select="jsword:getName($passage)"/&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &nbsp; &lt;/a&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &nbsp; &lt;xsl:apply-templates select=".//note" mode="print-notes" /&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &nbsp; &lt;div&gt;&lt;xsl:text&gt;&amp;#160;&lt;/xsl:text&gt;&lt;/div&gt;</div><div style="margin: 0px;">&nbsp; &nbsp; &lt;/xsl:if&gt;</div><div style="margin: 0px;">&nbsp; &lt;/xsl:template&gt;</div><div>...</div></div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&lt;/xsl:stylesheet&gt;</div></div><div><br></div><div>I invoke xalan.jar (or what is embedded in java), with jsword jar in the classpath, to do the transformation.</div><div><br></div><div>The syntax is particular to xalan. There is a different syntax for saxon. Haven't tried it though.</div><div><br></div><div>There are Java bindings for the SWORD library. Troy can give more on this. They might dig deep enough to expose the SWORD parser in all of it's glory.</div><div><br></div><blockquote type="cite"><br>However, I don't see anything in<br><a href="http://img.forministry.com/7/7B/7BB51FB8-84B3-4FF3-939ED473FA90A632/DOC/OSIS2_1UserManual_06March2006_-_with_O%27Donnell_edits.PDF">http://img.forministry.com/7/7B/7BB51FB8-84B3-4FF3-939ED473FA90A632/DOC/OSIS2_1UserManual_06March2006_-_with_O%27Donnell_edits.PDF</a> which would indicate that content of &lt;note&gt; should be anything else than a plain text, so I am afraid it is a bug libsword if it requires something else than it has right to expect.<br></blockquote><div><br></div>A proper reference in OSIS is wrapped in &lt;reference osisRef="the OSIS reference"&gt;the text reference&lt;/reference&gt;</div><div>A cross reference not is &lt;note type="crossReference"&gt;one or more cross references&lt;/note&gt;</div><div><br></div><div>It is these two things together that produce the reference.</div><div><br></div><div>Basically, the reference element says to ignore the text reference and use the osis reference instead.</div><div><br></div><div><blockquote type="cite"><br><blockquote type="cite">So as I said, the crash is fixed. &nbsp;But I believe the example above is<br>bad due to this target error. &nbsp;Am I correct?<br><br>$ mod2imp CzeCSP | grep '&gt;v\.' | wc<br> &nbsp;&nbsp;2434 &nbsp;117012 1539356<br></blockquote><br>Of course it just documents how difficult it is to require from all<br>modules to produce perfect parseable code in the conent of &lt;note&gt;.<br><br>Blessings,<br><br>Matěj<br><br>-- <br><a href="http://www.ceplovi.cz/matej/">http://www.ceplovi.cz/matej/</a>, Jabber: <a href="mailto:mcepl@ceplovi.cz">mcepl@ceplovi.cz</a><br>GPG Finger: 89EF 4BC6 288A BF43 1BAB &nbsp;25C3 E09F EF25 D964 84AC<br><br>Two things fill the heart with renewed and increasing awe and<br>reverence the more often and the more steadily that they are<br>meditated on: the starry skies above me and the moral law inside<br>me.<br> &nbsp;&nbsp;&nbsp;-- Immanuel Kant: Critique of Practical Reason<br>_______________________________________________<br>sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org">sword-devel@crosswire.org</a><br><a href="http://www.crosswire.org/mailman/listinfo/sword-devel">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br>Instructions to unsubscribe/change your settings at above page</blockquote></div><br></body></html>