<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"><<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>></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 <<a href="mailto:mcepl@redhat.com" target="_blank">mcepl@redhat.com</a>> 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"> <xsl:stylesheet</div><div style="margin:0px;font-size:11px;font-family:Monaco"> xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform" target="_blank">http://www.w3.org/1999/XSL/Transform</a>"</div>
<div style="margin:0px;font-size:11px;font-family:Monaco"> version="1.0"</div><div style="margin:0px;font-size:11px;font-family:Monaco"> xmlns:jsword="<a href="http://xml.apache.org/xalan/java" target="_blank">http://xml.apache.org/xalan/java</a>"</div>
<div style="margin:0px;font-size:11px;font-family:Monaco"> extension-element-prefixes="jsword"></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"> <!-- Create a versification from which verse numbers are understood --></div><div style="margin:0px"> <xsl:variable name="v11nf" select="jsword:org.crosswire.jsword.versification.system.Versifications.instance()"/></div>
<div style="margin:0px"> <!-- Create a global key factory from which OSIS <span style="text-decoration:underline">ids</span> will be generated --></div><div style="margin:0px"> <xsl:variable name="<span style="text-decoration:underline">keyf</span>" select="jsword:org.crosswire.jsword.passage.PassageKeyFactory.instance()"/></div>
<div style="margin:0px"> <!-- Create a global number shaper that can transform 0-9 into other number systems. --></div><div style="margin:0px"> <xsl:variable name="shaper" select="jsword:org.crosswire.common.icu.NumberShaper.new()"/></div>
<div style="margin:0px;min-height:15px">...</div><div style="margin:0px;min-height:15px"><div style="margin:0px"> <xsl:template match="verse" mode="print-notes"></div><div style="margin:0px"> <xsl:if test=".//note[not(@type) or not(@type = 'x-strongsMarkup')]"></div>
<div style="margin:0px"> <xsl:variable name="versification" select="jsword:getVersification($v11nf, $v11n)"/></div><div style="margin:0px"> <xsl:variable name="passage" select="jsword:getValidKey($keyf, $versification, @osisID)"/></div>
<div style="margin:0px"> <a href="#{substring-before(concat(@osisID, ' '), ' ')}"></div><div style="margin:0px"> <xsl:value-of select="jsword:getName($passage)"/></div>
<div style="margin:0px"> </a></div><div style="margin:0px"> <xsl:apply-templates select=".//note" mode="print-notes" /></div><div style="margin:0px"> <div><xsl:text>&#160;</xsl:text></div></div>
<div style="margin:0px"> </xsl:if></div><div style="margin:0px"> </xsl:template></div><div>...</div></div></div><div><div style="margin:0px;font-size:11px;font-family:Monaco"></xsl:stylesheet></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></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'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 <note> 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 <reference osisRef="the OSIS reference">the text reference</reference></div><div>A cross reference not is <note type="crossReference">one or more cross references</note></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 '>v\.' | 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 <note>.<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>