<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Thanks, Rolf. This is more than enough analysis on your part. I
appreciate it.<br>
Leigh.<br>
<br>
On 01/24/2012 12:30 PM, Rolf Lear wrote:
<blockquote cite="mid:268d84b06cc20c3cbbe72dbec85d1672@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 -->
<br>
<p><font size="2">Hi Leigh.</font>
</p>
<p><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>
</p>
<p><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>
</p>
<br>
<p><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>
</p>
<br>
<p><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>
</p>
<p><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>
</p>
<p><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>
</p>
<p><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>
</p>
<p><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>
</p>
<p><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>
</p>
<p><font size="2">Rolf</font>
</p>
<br>
<br>
<p><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 element:</font>
</p>
<p><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">> 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">> 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">> 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">> 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>
</p>
</blockquote>
<br>
</body>
</html>