Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAXOutputter should not fire NO_NAMESPACE delaration for attributes #60

rolfl opened this issue Jan 24, 2012 · 0 comments · May be fixed by karianna/jdom#1

SAXOutputter should not fire NO_NAMESPACE delaration for attributes #60

rolfl opened this issue Jan 24, 2012 · 0 comments · May be fixed by karianna/jdom#1


Copy link

rolfl commented Jan 24, 2012

Has anyone encountered this? It doesn't happen with JDOM 1.1.1, but it does happen with JDOM 1.1.2.

Vanilla XSLT transform:

<?xml version="1.0"?>
<xsl:transform version="1.0" xmlns:xsl="">
<xsl:template match="*|@*|text()">
<xsl:copy-of select="." />

Document with default namespace change and any attribute on the element: FAILS:

<?xml version="1.0" encoding="UTF-8"?>
<foo xmlns="">
<bar x="...">...</bar>

Document with default namespace change and no attribute on the element: WORKS:

<?xml version="1.0" encoding="UTF-8"?>
<foo xmlns="">
<bar >...</bar>

Here's the error:

org.jdom.IllegalAddException: The namespace xmlns="" could not be added as a namespace to "bar": The namespace prefix "" collides with the element namespace prefix
at org.jdom.Element.addNamespaceDeclaration(
at org.jdom.input.SAXHandler.transferNamespaces(
at org.jdom.input.SAXHandler.startElement(
at net.sf.saxon.event.ContentHandlerProxy.startContent(
at net.sf.saxon.event.NamespaceReducer.startContent(
at net.sf.saxon.event.ComplexContentOutputter.startContent(
at net.sf.saxon.tree.tiny.TinyElementImpl.copy(
at net.sf.saxon.expr.instruct.CopyOf.processLeavingTail(
at net.sf.saxon.expr.instruct.Template.applyLeavingTail(
at net.sf.saxon.trans.Mode.applyTemplates(
at net.sf.saxon.trans.TextOnlyCopyRuleSet.process(
at net.sf.saxon.trans.Mode.applyTemplates(
at net.sf.saxon.Controller.transformDocument(
at net.sf.saxon.Controller.transform(
at net.sf.saxon.s9api.XsltTransformer.transform(

I'm using this code fragment to tell Saxon9 to serialize to JDOM:

import net.sf.saxon.s9api.SAXDestination;
import org.jdom.input.SAXHandler;
import net.sf.saxon.s9api.Destination;

SAXHandler saxHandler = new SAXHandler();
Destination saxDestination = new SAXDestination(saxHandler);
xsltTransformer.setSource(new JDOMSource(document));

If this isn't a JDOM bug, then I guess it must be a Saxon one.


@rolfl rolfl closed this as completed in 1c453a9 Jan 25, 2012
rolfl added a commit that referenced this issue Jan 25, 2012
It is... by virtue of the new NamespaceStack which does 'the right thing'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

1 participant