Subjects
Home
Xalan extension functions
Fomatting question serializing DOM with pretty print
xalan with pull parser
Cannot find the declaration
Apache Xalan drop support to run on JRE 1 1 x
Why does Doctype change processing of a document
Node set to XML string via Java extensions in Xalan J: possible?
Templates/Transformers + thread safety???
Problem evaluating xpath with muliple prefix with different namespace
remove an arbitrary attribute from xsl output
Xalan3 XSLT 2 0 XPath 2 0 support?
Problem using compiled translets with Xalan !!
Xalan and jstl 1 1 problem with transform tag
NullPointer in DOM2DTM getLocalName
URIResolvers base parameter with xsltc and cascaded imports
Performance problem for Xalan J on intel dual core
Standard libraries in JAXP?
Serializing a DOM tree to XML file, customize entities replacement
Library Conflict Involving BCEL Library
A question on how users are using <xsl:message >
Kevin Cormier as a new Apache Xalan J committer
Struggling to iterate over tokenized string
Xalan count() trouble
Problem with recursive xpath
Error when switching to java 1 5
document( ' ')
Problem with Xalan2 7 0 transformation
cr/lf options
entity encoded XML
can xalan transform 2 xml using one xslt?
Xalan J JIRA defect review Monday October 16, 2006 from 2:00 to 3:30 pm ED
xsl transform with cdata section elements
xslt parameters not expanded
Weird behavior of XPath evaluate()
How to avoid <xsl:message > instruction prints stylesheet file informations ?
Cannot find SimpleTransform subdirectory after installing Xalan J
recover from document not found exceptions
jdk1 5 and Xalan jar differences?
Performance Issue
Error/Bug adding floating point numbers
XPathAPI: eval exp using nodes with default namespace
modifying xalan to output invalid XML
NullPointerException
mege two separate xml nodes into one
Is this a XALAN document identification bug?
is StylesheetRoot really java io Serializable ?
transform() fails for DOMSource but succeeds for StreamSource
Thoughts on Transformer parameter passing
HELP, Xalan and jstl 1 1 problem with transformer
Problem with XPath namespace axis?
string utils:replace deleting search string if replacement string is an HTML
help with enumeration values pls
xalan 2 5 1 vs 2 7 performance question
How to insert/update in XML document
HTML Serialization and Handling of Ampersands in HREF Attributes
XHTML link tag stripping
SystemId Unknown; Line #24; Column #49; java lang NullPointerException
xpath text() help
Apostrophe problem with xalan 2 7 0
How to set variables in XML document?
Links
Home
Oracle database error code ...
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Lookup alternate inflections for headword in secondary file

Lookup alternate inflections for headword in secondary file

2003-05-15       - By Chris Loschen

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. I've asked the xsl-list
about the following error, and they've suggested
it might be a problem with xalan-j instead, and sent me to you.

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
&rarr;noise, fortune.</b></se2> <se2 type="variant">un/une. <b>&tilde;
tree</b> un arbre; <b>&tilde; chair</b> une chaise.</se2> <se2
type="variant">(<ctx><r>per</r></ctx>) <b>ten francs &tilde; kilo</b> dix
francs le kilo; <b>three times &tilde; 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
&tilde;</b> d&eacute;concert&eacute;.</se1></sg></e>
<e eid="e3"><hg><hw>abandon</hw> <pos>vt</pos></hg><sg><se1>abandonner.
&bull; <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</hw><hm>1</hm></se>
<se id="e2"><formg><form>a</form></formg><hw>a</hw><hm>2</hm></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="$inflection = 'alternate'">
                        <xsl:variable name="inflection_name"
select="concat($bilingual,'_alternate.xml')" />
                        <xsl:apply-templates
select="document($inflection_name,/)" />
                </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@(protected)
http://www.texterity.com/