You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Peter Davis <pd...@attbi.com> on 2002/03/12 06:11:38 UTC
Bug with namespaces in key() names?
Hey all, I think I've found a bug when using the key() function on a key-name
that is a QName. Unfortunately, I'm having a really hard time recreating it
in a minimal version; it only seems to happen in the context of my very large
stylesheet. It also seems to be related to my use of xsl:import, as the
place where this occurs is about 4 import-levels down, and two or three of
those upper levels also declare the offending namespace. If I don't import
the offending stylesheet and use it alone, the bug doesn't happen.
I can't really post my whole application, as a lot of it is proprietary. But
here are the lines that seem to be causing the problem directly:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:doc="http://foo.com/namespace" xmlns="http://foo.com/output">
<xsl:key name="doc:element.type" match="doc:element" use="@type"/>
...
<xsl:for-each
select="//doc:element[count(key('doc:element.type', @type)[1] | .) = 1]">
...
</xsl:for-each>
</xsl:stylesheet>
According to the error, it says that "doc" must resolve to a namespace.
Obviously, it is (see the xmlns:doc="..."). If I take out the 'doc:' prefix
from the key names, it works fine.
Here is the top portion of the stack trace:
javax.xml.transform.TransformerException: java.lang.RuntimeException: Prefix
must resolve to a namespace: doc
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1226)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:638)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1088)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1066)
at org.apache.xalan.xslt.Process.main(Process.java:865)
Caused by: java.lang.RuntimeException: Prefix must resolve to a namespace: doc
at org.apache.xml.utils.QName.<init>(QName.java:328)
at org.apache.xalan.templates.FuncKey.execute(FuncKey.java:116)
at org.apache.xpath.Expression.asIterator(Expression.java:273)
at
org.apache.xpath.axes.FilterExprWalker.setRoot(FilterExprWalker.java:162)
at
org.apache.xpath.axes.WalkingIterator.reset(WalkingIterator.java:110)
at
org.apache.xpath.axes.LocPathIterator.setRoot(LocPathIterator.java:373)
at
org.apache.xpath.axes.LocPathIterator.asIterator(LocPathIterator.java:267)
at
org.apache.xpath.axes.UnionPathIterator.setRoot(UnionPathIterator.java:132)
at
org.apache.xpath.axes.UnionPathIterator.asIterator(UnionPathIterator.java:510)
at org.apache.xpath.functions.FuncCount.execute(FuncCount.java:92)
at org.apache.xpath.operations.Operation.execute(Operation.java:143)
at
org.apache.xpath.axes.PredicatedNodeTest.executePredicates(PredicatedNodeTest.java:307)
at
org.apache.xpath.axes.PredicatedNodeTest.acceptNode(PredicatedNodeTest.java:438)
at
org.apache.xpath.axes.WalkingIteratorSorted.setRoot(WalkingIteratorSorted.java:212)
at
org.apache.xpath.axes.LocPathIterator.asIterator(LocPathIterator.java:267)
at
org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:357)
... forever :)
I'm really sorry I can't give you a better example to let you recreate it
yourselves -- I tried :). Thanks to anyone who has a clue about what could
be going wrong. Your help is much appreciated. In the meantime, I'll be
using Saxon :(
--
Peter Davis
You have the capacity to learn from mistakes. You'll learn a lot today.