<html>
<body>
Actually, I haven't since I reasoned this wasn't necessary.<br><br>
The only case when the current code would produce the expected output
while the patched code would not, is if attQName contains both prefix and
name while attLocalName is the empty string. I figured that if such a
parser exists, it is erroneous and it shouldn't be JDOMs responsibility
to handle this. But maybe I'm wrong here?<br><br>
If I'm wrong, is there a particular set of parser that should be tested
("the parsers")?<br><br>
/Mattias Jiderhamn<br><br>
At 2005-11-21 18:48, you wrote:<br>
<blockquote type=cite class=cite cite="">Have you tested it w/ the
various parsers?<br><br>
-jh-<br><br>
Mattias Jiderhamn wrote:<br><br>
<blockquote type=cite class=cite cite="">Here is a patch (against the CVS
head) that fixes the issue:<br>
Index: src/java/org/jdom/input/SAXHandler.java<br>
===================================================================<br>
RCS file:
/home/cvspublic/jdom/src/java/org/jdom/input/SAXHandler.java,v<br>
retrieving revision 1.71<br>
diff -u -r1.71 SAXHandler.java<br>
--- src/java/org/jdom/input/SAXHandler.java 11
Dec 2004 02:18:55 -0000 1.71<br>
+++ src/java/org/jdom/input/SAXHandler.java 11
Nov 2005 08:04:54 -0000<br>
@@ -560,7 +560,11 @@<br>
continue;<br>
}<br>
- if
(!attQName.equals(attLocalName)) {<br>
+ if
("".equals(attLocalName)) { // "Namespace processing is
not being performed"<br>
+
attribute = factory.attribute(attQName, atts.getValue(i),<br>
+
attType);<br>
+
}<br>
+ else
if (!attQName.equals(attLocalName)) {<br>
String attPrefix = attQName.substring(0,
attQName.indexOf(":"));<br>
Namespace attNs = Namespace.getNamespace(attPrefix,<br>
atts.getURI(i));<br><br>
At 2005-11-10 10:53, you wrote:<br><br>
<blockquote type=cite class=cite cite="">Hi list.<br>
I am having trouble using the XSL transformer of Caucho Resin 3 (
<a href="http://www.caucho.com/resin-3.0" eudora="autourl">
http://www.caucho.com/resin-3.0</a>) together with JDOM. The problem
occurs when using attributes without namespace and outputting to a
JDOMResult. On the one hand this worked fine with Resin 2, on the other
hand Resin 3 seems to follow the specification more closely, so I'm not
quite sure whether the problem lies with Resin or JDOM.<br><br>
The point of problem is in org.jdom.input.SAXHandler.startElement(). Here
it is assumed that the local name of the attribute is equal to the QName,
if no namespace/prefix is used. (Line numbers from 1.0 release)<br><br>
536: if
(!attQName.equals(attLocalName)) {<br>
537:
String attPrefix = attQName.substring(0,
attQName.indexOf(":"));<br><br>
This works fine with Resin 2 and Xalan.<br><br>
Although the documentation for org.xml.sax.Attributes.getLocalName() (see
http://java.sun.com/j2se/1.5.0/docs/api/org/xml/sax/Attributes.html#getLocalName(int
)) says<br><br>
Returns: The local name, or the empty string if Namespace
processing is not being performed, or null if the index is out of
range.<br><br>
So Resin 3 returns the emtpy string in this case, which causes
"java.lang.StringIndexOutOfBoundsException: String index out of
range: -1" on line 537 above. Below you will find a self contained
example.<br><br>
So, does JDOM need to take into account that the local name can be blank?
Or is this a bug with Resin 3?<br><br>
<br><br>
----------------------------<br><br>
import org.jdom.transform.JDOMResult;<br>
import org.jdom.transform.JDOMSource;<br>
import org.jdom.Element;<br><br>
import javax.servlet.http.HttpServlet;<br>
import javax.servlet.http.HttpServletRequest;<br>
import javax.servlet.http.HttpServletResponse;<br>
import javax.servlet.ServletException;<br>
import javax.xml.transform.TransformerFactory;<br>
import javax.xml.transform.Transformer;<br>
import javax.xml.transform.stream.StreamSource;<br>
import java.io.IOException;<br>
import java.io.StringReader;<br><br>
public class XslProblemServlet extends HttpServlet {<br>
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {<br>
try {<br>
TransformerFactory transformerFactory =
TransformerFactory.newInstance();<br>
StreamSource streamSource = new
StreamSource(new StringReader(<br>
"<?xml
version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
+<br>
"<xsl:stylesheet version=\"1.0\"
xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
+<br>
"
<xsl:template match=\"/\">\n" +<br>
" <bar><child
myAttribute=\"myValue\" /></bar>\n" +<br>
"
</xsl:template>\n" +<br>
"</xsl:stylesheet>"));<br>
Transformer transformer =
transformerFactory.newTransformer(streamSource);<br><br>
JDOMSource source = new JDOMSource(new
org.jdom.Document(new Element("foo")));<br>
JDOMResult result = new JDOMResult();<br>
transformer.transform(source,
result);<br>
}<br>
catch(Exception ex) {<br>
throw new ServletException(ex);<br>
}<br>
}<br>
}</blockquote><br>
_______________________________________________<br>
To control your jdom-interest membership:<br>
<a href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com" eudora="autourl">
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a>
<br>
</blockquote>
<x-sigsep><p></x-sigsep>
<br><br>
Mattias Jiderhamn<br>
Expert Systems<br><br>
<i> Mail</i>:
<a href="mailto:mattias.jiderhamn@expertsystem.se">
mattias.jiderhamn@expertsystem.se</a> <br>
<i> Web</i>:
<a href="http://www.expertsystem.se/">www.expertsystem.se</a> <br>
<i> Skype</i>: <a href="callto://mattiasj78">mattiasj78<br>
</a></body>
</html>