[sword-devel] CzeCSP xref encoding error

Greg Hellings greg.hellings at gmail.com
Thu Apr 10 09:15:41 MST 2014


On Thu, Apr 10, 2014 at 11:11 AM, DM Smith <dmsmith at crosswire.org> wrote:

>
> On Apr 10, 2014, at 11:32 AM, Matěj Cepl <mcepl at redhat.com> wrote:
>
> On Thu, 2014-04-10 at 10:09 -0400, Karl Kleinpaste wrote:
>
> I got a Xiphos crash report this morning from someone using CzeCSP.  The
> error is that there are xref encoding glitches that Sword fails to
> parse, which cause Xiphos to crash when trying to process them.  Oops.
>
>
> I am the author of CzeCSP conversion into OSIS XML format. The problem
> is that I don’t have in my source texts anything to hang on other than a
> free text. I have absolutely no clue who to do the parsing in XSLT
> (which is what I used for XML-to-XML conversion) and I will have a
> really hard time to parse this free text in Python (but I may try
> eventually; it has been
> https://luther.ceplovi.cz/bugzilla/show_bug.cgi?id=180 for some time).
>
>
> In your xslt it is possible to call Java code. Here is how I do it using
> Xalan and JSword:
>  <xsl:stylesheet
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   version="1.0"
>   xmlns:jsword="http://xml.apache.org/xalan/java"
>   extension-element-prefixes="jsword">
> ...
>   <!-- Create a versification from which verse numbers are understood -->
>   <xsl:variable name="v11nf"
> select="jsword:org.crosswire.jsword.versification.system.Versifications.instance()"/>
>   <!-- Create a global key factory from which OSIS ids will be generated
> -->
>   <xsl:variable name="keyf"
> select="jsword:org.crosswire.jsword.passage.PassageKeyFactory.instance()"/>
>   <!-- Create a global number shaper that can transform 0-9 into other
> number systems. -->
>   <xsl:variable name="shaper"
> select="jsword:org.crosswire.common.icu.NumberShaper.new()"/>
> ...
>   <xsl:template match="verse" mode="print-notes">
>     <xsl:if test=".//note[not(@type) or not(@type = 'x-strongsMarkup')]">
>       <xsl:variable name="versification"
> select="jsword:getVersification($v11nf, $v11n)"/>
>       <xsl:variable name="passage" select="jsword:getValidKey($keyf,
> $versification, @osisID)"/>
>       <a href="#{substring-before(concat(@osisID, ' '), ' ')}">
>         <xsl:value-of select="jsword:getName($passage)"/>
>       </a>
>       <xsl:apply-templates select=".//note" mode="print-notes" />
>       <div><xsl:text>&#160;</xsl:text></div>
>     </xsl:if>
>   </xsl:template>
> ...
> </xsl:stylesheet>
>
> I invoke xalan.jar (or what is embedded in java), with jsword jar in the
> classpath, to do the transformation.
>
> The syntax is particular to xalan. There is a different syntax for saxon.
> Haven't tried it though.
>
> 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.
>

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.

--Greg


>
>
> However, I don't see anything in
>
> http://img.forministry.com/7/7B/7BB51FB8-84B3-4FF3-939ED473FA90A632/DOC/OSIS2_1UserManual_06March2006_-_with_O%27Donnell_edits.PDFwhich 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.
>
>
> A proper reference in OSIS is wrapped in <reference osisRef="the OSIS
> reference">the text reference</reference>
> A cross reference not is <note type="crossReference">one or more cross
> references</note>
>
> It is these two things together that produce the reference.
>
> Basically, the reference element says to ignore the text reference and use
> the osis reference instead.
>
>
> So as I said, the crash is fixed.  But I believe the example above is
> bad due to this target error.  Am I correct?
>
> $ mod2imp CzeCSP | grep '>v\.' | wc
>   2434  117012 1539356
>
>
> Of course it just documents how difficult it is to require from all
> modules to produce perfect parseable code in the conent of <note>.
>
> Blessings,
>
> Matěj
>
> --
> http://www.ceplovi.cz/matej/, Jabber: mcepl at ceplovi.cz
> GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
>
> Two things fill the heart with renewed and increasing awe and
> reverence the more often and the more steadily that they are
> meditated on: the starry skies above me and the moral law inside
> me.
>    -- Immanuel Kant: Critique of Practical Reason
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page
>
>
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20140410/0b506995/attachment-0001.html>


More information about the sword-devel mailing list