[jdom-interest] Special XMLOutputter which omits namespaces?

Guillaume Berche guillaume.berche at eloquant.com
Tue May 18 23:43:03 PDT 2004


Hi Jason,

Thanks for your answer. I understand your position given that my need is
pretty specific. Would making the method package-protected (so overrideable
but not exposed publicly) a reasonnable alternative to your concern about
making it protected?

Cheers,

Guillaume.

> -----Original Message-----
> From: Jason Hunter [mailto:jhunter at xquery.com]
> Sent: mardi 18 mai 2004 18:23
> To: Guillaume Berche
> Cc: jdom-interest at jdom.org
> Subject: Re: [jdom-interest] Special XMLOutputter which omits
> namespaces?
>
>
> Hi Guillaume,
>
> 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.
>
> -jh-
>
> Guillaume Berche wrote:
>
> > Hello,
> >
> > 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
> > class.
> >
> > Thanks for your help and for this great library!
> >
> > Regards,
> >
> > Guillaume.
> >
> >
> > _______________________________________________
> > To control your jdom-interest membership:
> >
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
>






More information about the jdom-interest mailing list