You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Elliotte Harold <el...@metalab.unc.edu> on 2004/09/05 17:16:42 UTC
Bug in JavaDoc for gExpandedNameTable.getType?
I've written some code which accesses Xalan purely through published
APIs, specifically javax.xml.transform.sax.SAXSource. However a likely
bug in my code is causing an ArrayIndexOutOfBoundsException deep inside
Xalan, specifically at
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Vector.elementAt(Vector.java:434)
at
org.apache.xml.dtm.ref.ExpandedNameTable.getType(ExpandedNameTable.java:295)
at
org.apache.xml.dtm.ref.DTMDefaultBase.getNodeType(DTMDefaultBase.java:1662)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2025)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1213)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:668)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
at nu.xom.xslt.XSLTransform.transform(XSLTransform.java:378)
... 17 more
I'm pretty sure it's my bug that's causing this exception, not yours.
However it would be helpful in tracking down my bug if I could
understand what your class is doing. Looking at the JavaDoc for
ExpandedNameTable.getType I see that this method, "Given an
expanded-name ID, return the local name ID." That sounds funny,
especially since there's a getLocalNameID method that has the exact same
description.
I suspect the JavaDoc is off here, and this is a copy-paste error from
the getLocalNameID method. If my hypothesis is correct, someone should
probably fix the JavaDoc. However, in the meantime, I would appreciate
it greatly if someone could explain to m what the getType() method is
actually doing. Is it looking for an attribute type? Knowing this would
assist me greatly in tracking down my own bug. Thanks!
--
Elliotte Rusty Harold
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
Re: Bug in JavaDoc for gExpandedNameTable.getType?
Posted by Joseph Kesselman <ke...@us.ibm.com>.
>FYI, I've managed to track down and eliminate the bugs in my code
>that were causing this and several other exceptions deep inside
>Xalan. My comment about the incorrect JavaDoc still stands, though.
Yeah, cut-and-paste errors. At some point, in someone's Copious Spare Time,
a real review of the Javadoc would be a good thing; there's plenty of room
for improvement.
>Xalan is not particularly robust against a misbehaving SAX XMLReader
>...
>it might be worth somebody's time to figure out how to harden
>Xalan against these sorts of attacks, whether malicious or unintentional.
There's a trade-off here: Hardening (at least to the point of making errors
more diagnostically useful) does cost some CPU cycles. I *think* we could
afford it... but I think we'd want to be careful about designing it
efficiently.
My own inclination is actually to say that the hardening layer ought ot be
a SAXFilter itself, which would be plugged in when folks don't trust their
XMLReader and left out when you know you're working with one that is
robust. The overhead of a filter is a bit higher than a built-in check, but
this would let us continue to avoid overhead when not needed. And a
hardening SAXFilter would be a usefully reusable chunk of code.
Beware of trying to build every possible feature into a single codebase.
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
Re: Bug in JavaDoc for gExpandedNameTable.getType?
Posted by Elliotte Rusty Harold <el...@metalab.unc.edu>.
FYI, I've managed to track down and eliminate the bugs in my code
that were causing this and several other exceptions deep inside
Xalan. My comment about the incorrect JavaDoc still stands, though.
One thing I noticed while hunting these bugs: Xalan is not
particularly robust against a misbehaving SAX XMLReader (which is
what I had). Little inconsistencies like calling startPrefixMapping()
for the xml prefix or calling startPrefixMapping("", "") for a root
element in no namespace cause Xalan to vomit up various runtime
exceptions. I'm not sure what would happen with a filter that
mismatched start and end-tags, or something equally evil. At some
point, it might be worth somebody's time to figure out how to harden
Xalan against these sorts of attacks, whether malicious or
unintentional.
--
Elliotte Rusty Harold
elharo@metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
Re: Bug in JavaDoc for gExpandedNameTable.getType?
Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Elliotte,
Elliotte Harold <el...@metalab.unc.edu> wrote on 09/05/2004 11:16:42 AM:
> I've written some code which accesses Xalan purely through published
> APIs, specifically javax.xml.transform.sax.SAXSource. However a likely
> bug in my code is causing an ArrayIndexOutOfBoundsException deep inside
> Xalan, specifically at
>
> Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
[Traceback removed. HZ]
> I'm pretty sure it's my bug that's causing this exception, not yours.
> However it would be helpful in tracking down my bug if I could
> understand what your class is doing. Looking at the JavaDoc for
> ExpandedNameTable.getType I see that this method, "Given an
> expanded-name ID, return the local name ID." That sounds funny,
> especially since there's a getLocalNameID method that has the exact same
> description.
>
> I suspect the JavaDoc is off here, and this is a copy-paste error from
> the getLocalNameID method.
[Remainder of message removed. HZ]
You're right that the JavaDoc is incorrect. I believe that method is
supposed to return the type of DTM node that is represented by that
expanded type ID: one of ATTRIBUTE_NODE, TEXT_NODE, ELEMENT_NODE, et al.
See
http://xml.apache.org/xalan-j/apidocs/org/apache/xml/dtm/DTM.html#ATTRIBUTE_NODE
and related declarations.
Thanks,
Henry
------------------------------------------------------------------
Henry Zongaro Xalan development
IBM SWS Toronto Lab T/L 969-6044; Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org