<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Thanks! I'll stick with 1.1.1 if this isn't easily fixed.<br>
<br>
Leigh.<br>
<br>
On 01/24/2012 03:34 PM, Rolf Lear wrote:
<blockquote cite="mid:4F1F4020.2050006@tuis.net" type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="MS Exchange Server version
6.5.7036.0">
<title>Re: [jdom-interest] JDOM 1.1.2 / Saxon 9.4.0.1: namespace
xmlns="" could not be added as a namespace</title>
<!-- Converted from text/plain format -->
<p><font size="2">Hi Leigh.</font>
</p>
<p><font size="2">I have tracked down the issue. It comes from
this change I made here:</font>
</p>
<p><font size="2"><a moz-do-not-send="true"
href="https://github.com/hunterhacker/jdom/commit/f026e89780b3259fa049fd223ceaacfee16fce65">https://github.com/hunterhacker/jdom/commit/f026e89780b3259fa049fd223ceaacfee16fce65</a></font>
</p>
<p><font size="2">So, The Saxon code is getting the event fired
from the JDOMSource....</font>
<br>
<font size="2">... which in turn is breaking the Saxon side of
things ... gigo.</font>
</p>
<p><font size="2">In essence I traded one bug for another.</font>
</p>
<p><font size="2">The original bug was that namespaces used by
Attributes were being </font>
<br>
<font size="2">'missed' in the SAX Event stream, but now that
they are checked, we need </font>
<br>
<font size="2">to ensure that the no-namespace namespace is
excluded.</font>
</p>
<p><font size="2">It is an easy fix, but a slower process to get
JDOM 1.1.3 out.</font>
</p>
<p><font size="2">Rolf</font>
</p>
<p><font size="2">On 24/01/2012 4:13 PM, Leigh L Klotz Jr wrote:</font>
<br>
<font size="2">> Thanks, Rolf. This is more than enough
analysis on your part. I</font>
<br>
<font size="2">> appreciate it.</font>
<br>
<font size="2">> Leigh.</font>
<br>
<font size="2">></font>
<br>
<font size="2">> On 01/24/2012 12:30 PM, Rolf Lear wrote:</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> Hi Leigh.</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> I am at my office so I can't debug this
issue right now... and</font>
<br>
<font size="2">>> additionally I have not played with
Saxon XSLT code.</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> but, inspecting the JDOM 1.1.2 code it
is 'clear' that the Saxon code</font>
<br>
<font size="2">>> triggered the following Sax 'events':</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> ...</font>
<br>
<font size="2">>> // maybe some other
startPrefixMapping(..., ...);</font>
<br>
<font size="2">>> startPrefixMapping("", ""); // indicate
that the "" prefix is linked to</font>
<br>
<font size="2">>> the "" URI</font>
<br>
<font size="2">>> startElement("<a moz-do-not-send="true"
href="http://example.com/foo">http://example.com/foo</a>",
"bar", "bar", attributes);</font>
<br>
<font size="2">>> ...</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> This is a broken chain of SAX events....
it is indicating that the ""</font>
<br>
<font size="2">>> prefix maps to "" (xmlns=""), but then
loads the element in the foo</font>
<br>
<font size="2">>> namespace xmlns="<a
moz-do-not-send="true" href="http://example.com/foo">http://example.com/foo</a>"</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> In the particular examples you cite
there should be exactly one</font>
<br>
<font size="2">>> startPrefixMapping("", "") call per
document and it should happen before</font>
<br>
<font size="2">>> the 'document' start element (or will it
be zero calls for "","" since it</font>
<br>
<font size="2">>> is assumed... I forget).</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> when the new element processes the
'additional' namespace xmlns="" it</font>
<br>
<font size="2">>> finds that the element itself has the ""
prefix, but it is mapped to a</font>
<br>
<font size="2">>> different URI. Hence the exception.</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> Now, as to why this is different in
1.1.2 vs. 1.1.1 I am not sure.... and</font>
<br>
<font size="2">>> that in itself is suspicious....</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> If you have the code in hand you can
more easily debug the issue...</font>
<br>
<font size="2">>> (easier than me right now...).</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> I can load it up in a few hours time and
inspect it too. I suspect that</font>
<br>
<font size="2">>> the issue is a Saxon one, but then why
the difference between 1.1.1 and</font>
<br>
<font size="2">>> 1.1.2 ... I am not sure.</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> Rolf</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>></font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> On Tue, 24 Jan 2012 11:26:41 -0800,
Leigh L Klotz Jr</font>
<br>
<font size="2">>> <a class="moz-txt-link-rfc2396E" href="mailto:leigh.klotz@xerox.com"><leigh.klotz@xerox.com></a> wrote:</font>
<br>
<font size="2">>> > Has anyone encountered this? It
doesn't happen with JDOM 1.1.1, but it</font>
<br>
<font size="2">>> > does happen with JDOM 1.1.2.</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > Vanilla XSLT transform:</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > <?xml version="1.0"?></font>
<br>
<font size="2">>> > <xsl:transform version="1.0"</font>
<br>
<font size="2">>> > xmlns:xsl="<a
moz-do-not-send="true"
href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</a>"></font>
<br>
<font size="2">>> > <xsl:template
match="*|@*|text()"></font>
<br>
<font size="2">>> > <xsl:copy-of select="." /></font>
<br>
<font size="2">>> > </xsl:template></font>
<br>
<font size="2">>> > </xsl:transform></font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > Document with default namespace
change and any attribute on the</font>
<br>
<font size="2">>> element:</font>
<br>
<font size="2">>></font>
<br>
<font size="2">>> > FAILS:</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > <?xml version="1.0"
encoding="UTF-8"?></font>
<br>
<font size="2">>> > <description></font>
<br>
<font size="2">>> > <foo xmlns="<a
moz-do-not-send="true" href="http://example.com/foo">http://example.com/foo</a>"></font>
<br>
<font size="2">>> > <bar x="...">...</bar></font>
<br>
<font size="2">>> > </foo></font>
<br>
<font size="2">>> > </description></font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > Document with default namespace
change and no attribute on the element:</font>
<br>
<font size="2">>> > WORKS:</font>
<br>
<font size="2">>> > <?xml version="1.0"
encoding="UTF-8"?></font>
<br>
<font size="2">>> > <description></font>
<br>
<font size="2">>> > <foo xmlns="<a
moz-do-not-send="true" href="http://example.com/foo">http://example.com/foo</a>"></font>
<br>
<font size="2">>> > <bar >...</bar></font>
<br>
<font size="2">>> > </foo></font>
<br>
<font size="2">>> > </description></font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > Here's the error:</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > org.jdom.IllegalAddException: The
namespace xmlns="" could not be added</font>
<br>
<font size="2">>> > as a namespace to "bar": The
namespace prefix "" collides with the</font>
<br>
<font size="2">>> > element namespace prefix</font>
<br>
<font size="2">>> > at
org.jdom.Element.addNamespaceDeclaration(Element.java:363)</font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>>
org.jdom.input.SAXHandler.transferNamespaces(SAXHandler.java:714)</font>
<br>
<font size="2">>> > at
org.jdom.input.SAXHandler.startElement(SAXHandler.java:563)</font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>>
net.sf.saxon.event.ContentHandlerProxy.startContent(ContentHandlerProxy.java:366)</font><br>
<font size="2">>></font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>>
net.sf.saxon.event.NamespaceReducer.startContent(NamespaceReducer.java:192)</font><br>
<font size="2">>></font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>>
net.sf.saxon.event.ComplexContentOutputter.startContent(ComplexContentOutputter.java:583)</font><br>
<font size="2">>></font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>> >
net.sf.saxon.tree.tiny.TinyElementImpl.copy(TinyElementImpl.java:350)</font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>> >
net.sf.saxon.expr.instruct.CopyOf.processLeavingTail(CopyOf.java:510)</font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>> >
net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:212)</font>
<br>
<font size="2">>> > at
net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1032)</font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>>
net.sf.saxon.trans.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:58)</font><br>
<font size="2">>></font>
<br>
<font size="2">>> > at
net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1020)</font>
<br>
<font size="2">>> > at
net.sf.saxon.Controller.transformDocument(Controller.java:1957)</font>
<br>
<font size="2">>> > at
net.sf.saxon.Controller.transform(Controller.java:1803)</font>
<br>
<font size="2">>> > at</font>
<br>
<font size="2">>> >
net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:430)</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > I'm using this code fragment to
tell Saxon9 to serialize to JDOM:</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > import
net.sf.saxon.s9api.SAXDestination;</font>
<br>
<font size="2">>> > import
org.jdom.input.SAXHandler;</font>
<br>
<font size="2">>> > import
net.sf.saxon.s9api.Destination;</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > SAXHandler saxHandler = new
SAXHandler();</font>
<br>
<font size="2">>> > Destination saxDestination = new
SAXDestination(saxHandler);</font>
<br>
<font size="2">>> > xsltTransformer.setSource(new
JDOMSource(document));</font>
<br>
<font size="2">>> >
xsltTransformer.setDestination(saxDestination);</font>
<br>
<font size="2">>> > xsltTransformer.transform();</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > If this isn't a JDOM bug, then I
guess it must be a Saxon one.</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> > Leigh.</font>
<br>
<font size="2">>> ></font>
<br>
<font size="2">>> >
_______________________________________________</font>
<br>
<font size="2">>> > To control your jdom-interest
membership:</font>
<br>
<font size="2">>> > <a moz-do-not-send="true"
href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a></font>
<br>
<font size="2">>></font>
<br>
<font size="2">></font>
</p>
</blockquote>
<br>
</body>
</html>