[jdom-interest] Special XMLOutputter which omits namespaces?
jhunter at xquery.com
Tue May 18 09:22:50 PDT 2004
No, there's no support for that output feature in XMLOutputter. You're
basically wanting to output XML with a different semantic meaning than
it really has in memory, so naturally that's something we didn't include
and aren't likely to.
We also aren't likely to make the method protected either because
protected methods are part of the public API so were we to do that, we'd
have to keep the method always in the future in order to maintain
backward compatibility. We don't want to promise anyone that the
outputter internals will always behave the same way. Since the code is
open, you can easily enough solve your problem without requiring the API
to keep the exact same internal implementation.
Guillaume Berche wrote:
> I've been pretty happy with JDom b8 except for the special need that I have
> to output some XML fragment without including the namespace prefixes in each
> element. The use-case for this is that I obtain a JDom tree from an XML
> document using Xerces with schema validation on. I obtain a valid JDom tree
> with the proper namespaces. I then want to dump a part of that tree without
> specifying the namespace of each element.
> I had looked at various threads on this list a while ago and concluded the
> best way for me to do this was to create a new "NoNameSpaceXMLOutputter"
> based on the org.jdom.output.XMLOutputter and just modify the behavior of
> the private "void printNamespace(Namespace ns, Writer out,
> NamespaceStack namespaces)" method, to have it return immediately, and not
> insert namespaces element prefixes.
> I wonder whether as part of the beta 10, there is better way of using JDom
> than duplicating the XMLOutputter code. I briefly looked at the new
> org.jdom.output.Format class but could not find something corresponding to
> my need.
> I realize this may be a specific need and may not justify extension in the
> Format mechanism for the 1.0, but it may be interesting to support wider
> subclassing of the org.jdom.output.XMLOutputter class by having some of its
> methods now be exposed as "protected" instead of "private". So for the final
> 1.0, I'd then advocate for the "void printNamespace(Namespace ns, Writer
> out, NamespaceStack namespaces)" method, so my NoNameSpaceXMLOutputter class
> would simply override this method instead of having to duplicate the whole
> Thanks for your help and for this great library!
> To control your jdom-interest membership:
More information about the jdom-interest