<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
(&quot;the parsers&quot;)?<br><br>
&nbsp; /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&nbsp;&nbsp;&nbsp;&nbsp; 11
Dec 2004 02:18:55 -0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.71<br>
+++ src/java/org/jdom/input/SAXHandler.java&nbsp;&nbsp;&nbsp;&nbsp; 11
Nov 2005 08:04:54 -0000<br>
@@ -560,7 +560,11 @@<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
continue;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
(!attQName.equals(attLocalName)) {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
(&quot;&quot;.equals(attLocalName)) { // &quot;Namespace processing is
not being performed&quot;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
attribute = factory.attribute(attQName, atts.getValue(i),<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
attType);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else
if (!attQName.equals(attLocalName)) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String attPrefix = attQName.substring(0,
attQName.indexOf(&quot;:&quot;));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Namespace attNs = Namespace.getNamespace(attPrefix,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
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:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
(!attQName.equals(attLocalName)) {<br>
537:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String attPrefix = attQName.substring(0,
attQName.indexOf(&quot;:&quot;));<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>
&nbsp;&nbsp; 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
&quot;java.lang.StringIndexOutOfBoundsException: String index out of
range: -1&quot; 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>
&nbsp; protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {<br>
&nbsp;&nbsp;&nbsp; try {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TransformerFactory transformerFactory =
TransformerFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StreamSource streamSource = new
StreamSource(new StringReader(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&lt;?xml
version=\&quot;1.0\&quot; encoding=\&quot;ISO-8859-1\&quot;?&gt;\n&quot;
+<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&quot;&lt;xsl:stylesheet version=\&quot;1.0\&quot;
xmlns:xsl=\&quot;http://www.w3.org/1999/XSL/Transform\&quot;&gt;\n&quot;
+<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&nbsp;
&lt;xsl:template match=\&quot;/\&quot;&gt;\n&quot; +<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&quot;&nbsp;&nbsp;&nbsp; &lt;bar&gt;&lt;child
myAttribute=\&quot;myValue\&quot; /&gt;&lt;/bar&gt;\n&quot; +<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&nbsp;
&lt;/xsl:template&gt;\n&quot; +<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&quot;&lt;/xsl:stylesheet&gt;&quot;));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Transformer transformer =
transformerFactory.newTransformer(streamSource);<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JDOMSource source = new JDOMSource(new
org.jdom.Document(new Element(&quot;foo&quot;)));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JDOMResult result = new JDOMResult();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transformer.transform(source,
result);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; catch(Exception ex) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new ServletException(ex);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp; }<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>
&nbsp; Mattias Jiderhamn<br>
&nbsp; Expert Systems<br><br>
<i>&nbsp; Mail</i>:
<a href="mailto:mattias.jiderhamn@expertsystem.se">
mattias.jiderhamn@expertsystem.se</a> <br>
<i>&nbsp; Web</i>:
<a href="http://www.expertsystem.se/">www.expertsystem.se</a> <br>
<i>&nbsp; Skype</i>: <a href="callto://mattiasj78">mattiasj78<br>
</a></body>
</html>