<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 10, 2014 at 11:11 AM, DM Smith <span dir="ltr">&lt;<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div class=""><div>On Apr 10, 2014, at 11:32 AM, Matěj Cepl &lt;<a href="mailto:mcepl@redhat.com" target="_blank">mcepl@redhat.com</a>&gt; wrote:</div>
<br><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.  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.  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" target="_blank">https://luther.ceplovi.cz/bugzilla/show_bug.cgi?id=180</a> for some time).<br></blockquote><div><br></div></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"> &lt;xsl:stylesheet</div><div style="margin:0px;font-size:11px;font-family:Monaco">  xmlns:xsl=&quot;<a href="http://www.w3.org/1999/XSL/Transform" target="_blank">http://www.w3.org/1999/XSL/Transform</a>&quot;</div>
<div style="margin:0px;font-size:11px;font-family:Monaco">  version=&quot;1.0&quot;</div><div style="margin:0px;font-size:11px;font-family:Monaco">  xmlns:jsword=&quot;<a href="http://xml.apache.org/xalan/java" target="_blank">http://xml.apache.org/xalan/java</a>&quot;</div>
<div style="margin:0px;font-size:11px;font-family:Monaco">  extension-element-prefixes=&quot;jsword&quot;&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">  &lt;!-- Create a versification from which verse numbers are understood --&gt;</div><div style="margin:0px">  &lt;xsl:variable name=&quot;v11nf&quot; select=&quot;jsword:org.crosswire.jsword.versification.system.Versifications.instance()&quot;/&gt;</div>
<div style="margin:0px">  &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">  &lt;xsl:variable name=&quot;<span style="text-decoration:underline">keyf</span>&quot; select=&quot;jsword:org.crosswire.jsword.passage.PassageKeyFactory.instance()&quot;/&gt;</div>
<div style="margin:0px">  &lt;!-- Create a global number shaper that can transform 0-9 into other number systems. --&gt;</div><div style="margin:0px">  &lt;xsl:variable name=&quot;shaper&quot; select=&quot;jsword:org.crosswire.common.icu.NumberShaper.new()&quot;/&gt;</div>
<div style="margin:0px;min-height:15px">...</div><div style="margin:0px;min-height:15px"><div style="margin:0px">  &lt;xsl:template match=&quot;verse&quot; mode=&quot;print-notes&quot;&gt;</div><div style="margin:0px">    &lt;xsl:if test=&quot;.//note[not(@type) or not(@type = &#39;x-strongsMarkup&#39;)]&quot;&gt;</div>
<div style="margin:0px">      &lt;xsl:variable name=&quot;versification&quot; select=&quot;jsword:getVersification($v11nf, $v11n)&quot;/&gt;</div><div style="margin:0px">      &lt;xsl:variable name=&quot;passage&quot; select=&quot;jsword:getValidKey($keyf, $versification, @osisID)&quot;/&gt;</div>
<div style="margin:0px">      &lt;a href=&quot;#{substring-before(concat(@osisID, &#39; &#39;), &#39; &#39;)}&quot;&gt;</div><div style="margin:0px">        &lt;xsl:value-of select=&quot;jsword:getName($passage)&quot;/&gt;</div>
<div style="margin:0px">      &lt;/a&gt;</div><div style="margin:0px">      &lt;xsl:apply-templates select=&quot;.//note&quot; mode=&quot;print-notes&quot; /&gt;</div><div style="margin:0px">      &lt;div&gt;&lt;xsl:text&gt;&amp;#160;&lt;/xsl:text&gt;&lt;/div&gt;</div>
<div style="margin:0px">    &lt;/xsl:if&gt;</div><div style="margin:0px">  &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&#39;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&#39;s glory.</div></div></div></blockquote><div><br></div><div>
If not, it is also possible to do this with Python and the full swig bindings using something like xsltproc.py which can be found around places where the lxml and libxslt Python bindings are located.</div><div><br></div><div>
--Greg</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class=""><div><br></div><blockquote type="cite"><br>
However, I don&#39;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" target="_blank">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></div>A proper reference in OSIS is wrapped in &lt;reference osisRef=&quot;the OSIS reference&quot;&gt;the text reference&lt;/reference&gt;</div><div>A cross reference not is &lt;note type=&quot;crossReference&quot;&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"><div class=""><br><blockquote type="cite">So as I said, the crash is fixed.  But I believe the example above is<br>bad due to this target error.  Am I correct?<br><br>$ mod2imp CzeCSP | grep &#39;&gt;v\.&#39; | wc<br>
   2434  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/" target="_blank">http://www.ceplovi.cz/matej/</a>, Jabber: <a href="mailto:mcepl@ceplovi.cz" target="_blank">mcepl@ceplovi.cz</a><br>GPG Finger: 89EF 4BC6 288A BF43 1BAB  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>    -- Immanuel Kant: Critique of Practical Reason<br>
</div><div class="">_______________________________________________<br>sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" target="_blank">sword-devel@crosswire.org</a><br><a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page</div></blockquote></div><br></div><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" target="_blank">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br></blockquote></div><br></div></div>