You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Chris P. McCabe" <ch...@choicehotels.com> on 2000/07/19 20:48:49 UTC

Xalan-J bug in xsl:key

I am experiencing a problem with using xsl:key that only shows up when I
have multiple threads processing stylesheets at the same time.  Each
thread has its own instance of XSLTProcessor, but is sharing in-memory
instances of compiled stylesheets (StylesheetRoot).
I am running a script that processes the same stylesheets over and over
again with the same data, and normally the xsl:key works fine, but
occasionally I get the following error and traceback:  (the name of the
xsl:key is 'input')

XSL Error: There is no xsl:key declaration for input!

        at
org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1676)
        at
org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1581)
        at
org.apache.xalan.xslt.XSLTEngineImpl.getNodeSetByKey(XSLTEngineImpl.java:2895)

        at
org.apache.xalan.xpath.xml.XMLParserLiaisonDefault.getNodeSetByKey(XMLParserLiaisonDefault.java:1709)

        at org.apache.xalan.xpath.FuncKey.execute(FuncKey.java:128)
        at org.apache.xalan.xpath.Function.execute(Function.java:115)
        at org.apache.xalan.xpath.XPath.executeFunction(XPath.java:1271)

        at org.apache.xalan.xpath.XPath.execute(XPath.java:1380)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:1354)
        at org.apache.xalan.xpath.XPath.execute(XPath.java:311)
        at org.apache.xalan.xslt.ElemChoose.execute(ElemChoose.java:118)

        at
org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElement.java:659)

        at
org.apache.xalan.xslt.XSLTEngineImpl.createResultTreeFrag(XSLTEngineImpl.java:2095)

        at
org.apache.xalan.xslt.VariableStack.pushParams(VariableStack.java:244)
        at
org.apache.xalan.xslt.ElemApplyTemplates.execute(ElemApplyTemplates.java:167)

        [rest of traceback deleted]

  This occurs in both Xalan 1.0.1 and 1.1.

  Anyone know what might be going on, or if this is a known problem?

  Chris

--
Chris McCabe
Choice Hotels International
chris_mccabe@choicehotels.com



Re: Xalan-J bug in xsl:key

Posted by "Chris P. McCabe" <ch...@choicehotels.com>.
Well, I tracked this bug down a little, and found that if I synchronize
around the creation of the KeyTable in the getNodeSetByKey method of
Stylesheet, the problem goes away.  I wasn't able to figure out why this
fixes the problem, but it does seem to do it.  At first I synchronized
the entire getNodeSetByKey method, which fixed the problem.  Then I
tried sync'ing only the XSLTEngineImpl that is passed in to make sure
that DIDN'T fix the problem (since it should not be shared between
threads anyway), and the problem came back.   After sync'ing the
Stylesheet around different parts of the method, I narrowed it down to
the creation of the KeyTable, and then instead of sync'ing the entire
Stylesheet, I added a member variable and used that to synchronize with,
and the problem is still fixed.  Which would indicate that the problem
is in building a KeyTable for 2 different XSLTEngineImpl objects at the
same time for the same StylesheetRoot.  Now the real question is why?
Maybe it will be more obvious to someone that understands the code
better than I do.  Let me know if you think it is something I am doing
wrong.

Here is the actual code I changed:  (m_sync_obj is declared as:  Object
m_sync_obj = new Object();)

KeyTable kt = null;
synchronized (m_sync_obj)  {
  kt = new KeyTable(doc, doc, nscontext, name, m_keyDeclarations,
                             tcontext.m_parserLiaison);
}



"Chris P. McCabe" wrote:

> I am experiencing a problem with using xsl:key that only shows up when
> I have multiple threads processing stylesheets at the same time.  Each
> thread has its own instance of XSLTProcessor, but is sharing in-memory
> instances of compiled stylesheets (StylesheetRoot).
> I am running a script that processes the same stylesheets over and
> over again with the same data, and normally the xsl:key works fine,
> but occasionally I get the following error and traceback:  (the name
> of the xsl:key is 'input')
>
> XSL Error: There is no xsl:key declaration for input!
>
>         at
> org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1676)
>         at
> org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1581)
>         at
> org.apache.xalan.xslt.XSLTEngineImpl.getNodeSetByKey(XSLTEngineImpl.java:2895)
>
>         at
> org.apache.xalan.xpath.xml.XMLParserLiaisonDefault.getNodeSetByKey(XMLParserLiaisonDefault.java:1709)
>
>         at org.apache.xalan.xpath.FuncKey.execute(FuncKey.java:128)
>         at org.apache.xalan.xpath.Function.execute(Function.java:115)
>         at
> org.apache.xalan.xpath.XPath.executeFunction(XPath.java:1271)
>         at org.apache.xalan.xpath.XPath.execute(XPath.java:1380)
>         at org.apache.xalan.xpath.XPath.execute(XPath.java:1354)
>         at org.apache.xalan.xpath.XPath.execute(XPath.java:311)
>         at
> org.apache.xalan.xslt.ElemChoose.execute(ElemChoose.java:118)
>         at
> org.apache.xalan.xslt.ElemTemplateElement.executeChildren(ElemTemplateElement.java:659)
>
>         at
> org.apache.xalan.xslt.XSLTEngineImpl.createResultTreeFrag(XSLTEngineImpl.java:2095)
>
>         at
> org.apache.xalan.xslt.VariableStack.pushParams(VariableStack.java:244)
>
>         at
> org.apache.xalan.xslt.ElemApplyTemplates.execute(ElemApplyTemplates.java:167)
>
>         [rest of traceback deleted]
>
>   This occurs in both Xalan 1.0.1 and 1.1.
>
>   Anyone know what might be going on, or if this is a known problem?
>
>   Chris
>
> --
> Chris McCabe
> Choice Hotels International
> chris_mccabe@choicehotels.com
>
>

--
Chris McCabe
Choice Hotels International
chris_mccabe@choicehotels.com