Hi all!
I'm trying to use the key and document functions to match some alternative
inflections from one source file with the
appropriate main headword in my main source file. (Thanks to all the people
on the list who have kindly helped me
get this far, and also to Michael Kay, from whom I've copied liberally (2nd
ed., p. 502-3).)
I've run into an error I haven't been able to make sense of yet, and I'm
hoping someone here will know. The error reads
(Location of error unknown)XSLT error (javax.xml.transform.Transformer
Exception): java.lang.ArrayIndexOutOfBoundsException: 5182 >= 5182
I'm running xalan-java 2.5, and this is a slightly shortened version of the
command line:
java org.apache.xalan.xslt.Process -in
/inbox/13248/xmlin/English-French_Dictionary.xml -xsl
~/bin/xslt/oro2oeb4dak.xsl
-out /inbox/13248/lit/English-French_Dictionary-dak.html -param
bilingual english -param inflectiono alternate
(all in one line of course)
Following are samples of my input data and my stylesheet:
main source file fragment:
<?xml version="1.0" encoding="us-ascii"?>
<!DOCTYPE OPR PUBLIC "-//xxx//DTD xxx//" "Oro-v315.dtd">
<OPR>
<letter value="A">
<e eid="e1" etype="feature"><hg><hw>a</hw>
<pos>determiner</pos></hg><sg><se1><b>an</b> avant voyelle ou h muet. <se2
type="usage">For expressions such as <b>make a noise, make a fortune
→noise, fortune.</b></se2> <se2 type="variant">un/une. <b>˜
tree</b> un arbre; <b>˜ chair</b> une chaise.</se2> <se2
type="variant">(<ctx><r>per</r></ctx>) <b>ten francs ˜ kilo</b> dix
francs le kilo; <b>three times ˜ day</b> trois fois par jour.</se2>
<se2 type="note">When talking about what people do or are, <b>a</b> is not
translated into French: <b>she's a teacher</b> <i>elle est professeur;</i>
<b>he's a widower</b> <i>il est veuf</i>.</se2></se1></sg></e>
<e eid="e2"><hg><hw>aback</hw> <pos>adv</pos></hg><sg><se1><b>taken
˜</b> déconcerté.</se1></sg></e>
<e eid="e3"><hg><hw>abandon</hw> <pos>vt</pos></hg><sg><se1>abandonner.
• <pos>n</pos> abandon <pos>m.</pos></se1></sg></e>
...
</letter>
...
</OPR>
english_alternate.xml fragment:
<?xml version="1.0" encoding="us-ascii"?>
<!DOCTYPE OPR PUBLIC "-//xxx//DTD xxx//" "Oro-v315.dtd">
<inflections>
<se
id="e1"><formg><form>a</form><form>a's</form><form>A</form><form>A's</form></formg><hw>a<hm>1</hm></hw></se>
<se id="e2"><formg><form>a</form></formg><hw>a<hm>2</hm></hw></se>
<se id="e3"><formg><form>aback</form></formg><hw>aback</hw></se>
<se
id="e4"><formg><form>abandon</form><form>abandoned</form><form>abandoning</form><form>abandons</form></formg><hw>abandon</hw></se>
...
</inflections>
XSL (in part):
<xsl:param name="bilingual" select="'title'" />
<xsl:param name="inflection" select="'regular'" />
<xsl:key name="entry-by-hw" match="se" use="concat(hw,'-',hm)" />
<xsl:variable name="alternate-inflections">
<xsl:choose>
<xsl:when test="$bilingual = 'english' and $inflection =
'alternate'">
<xsl:apply-templates
select="document('/inbox/13248/xmlin/english_alternate.xml')" />
</xsl:when>
<xsl:when test="$bilingual = 'foreign' and $inflection =
'alternate'">
<xsl:apply-templates
select="document('/inbox/13248/xmlin/foreign_alternate.xml')" />
</xsl:when>
<xsl:otherwise />
</xsl:choose>
</xsl:variable>
<xsl:template ...
...
<xsl:if test="$inflection = 'alternate'">
<xsl:variable name="current_hw"
select="concat(ancestor::e/hg/hw[1],'-',ancestor::e/hg/hom[1])" />
<xsl:for-each select="$alternate-inflections">
<xsl:variable name="match"
select="key('entry-by-hw',$current_hw)" />
<xsl:for-each select="$match/formg/form">
<xsl:choose>
<xsl:when test=". = ancestor::e/hw" />
<xsl:otherwise>
<tei-ms:orth><object
class="hidden"><xsl:apply-templates select="." /></object></tei-ms:orth>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
...
</xsl:template>
Any suggestions? Thank you very much!
--Chris
----------------------------------------------------------------------------------------
Texterity ~ XML and PDF ePublishing Services
----------------------------------------------------------------------------------------
Chris Loschen, XML Developer
Texterity, Inc.
144 Turnpike Road
Southborough, MA 01772 USA
tel: +1.508.804.3033
fax: +1.508.804.3110
email: loschen(_at_)texterity(_dot_)com
http://www.texterity.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list