Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] DOMOutputter and namespace aware Documents

Ortwin Glück

2006-05-23

Replies:

Hi,

Is there a way to make DOMOutputter create a namespace aware DOM? I need
this so I can schema validate it. I am using Xerces 2.6 via JAXP. See
comments in this issue report for explanations:
http://issues.apache.org/jira/browse/XERCESJ-1163?page=all


The problem is that my JDOM elements are in NO_NAMESPACE. And the
validation uses a noNamespaceSchemaLocation. That's perfectly legal.

But with elements not in a namespace I get a DOM without namespace
support! This prevent schema validation.

See line 251 in DOMOutputter:

        if (element.getNamespace() == Namespace.NO_NAMESPACE) {
          // No namespace, use createElement
          domElement =
domDoc.createElement(element.getQualifiedName());
        }
        else {
          domElement = domDoc.createElementNS(
                            element.getNamespaceURI(),
                            element.getQualifiedName());
        }


There should be a way to tell DOMOutputter to call createElementNS even
if I use NO_NAMESPACE.

Any hint would be greatly appreciated.

Ortwin
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.