Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Q: Pretty printing of namespaces

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: Wolfgang Hoschek <whoschek AT lbl.gov>, xom-interest AT lists.ibiblio.org
  • Cc:
  • Subject: Re: [XOM-interest] Q: Pretty printing of namespaces
  • Date: Mon, 29 Sep 2003 21:42:32 -0400

At 4:59 PM -0700 9/29/03, Wolfgang Hoschek wrote:
In order to have XML docs easily human readable, I'm trying to remove as much namespace clutter as possible from third-party XML documents autogenerated and merged from multiple sources.

Does anyone know rules and/or code that removes redundant namespace declarations in XML documents, either by strictly retaining semantics or by slighly relaxing them?

Possibly by reusing prefixes already declared "further up", by moving common namespace declarations into parent elements, by renaming prefixes that refer to the same namespace, by removing prefixes that refer to the default namespace, etc. This seems to be not so trivial.


This is hard but doable. However, what moves it from hard to not completely possible is that you may encounter namespace prefixes in element content and attribute values. Then again you may not. (Think XSLT or schemas). This severely limits how much generic rewriting you can do without a deep knowledge of the document's semantics. This is really a flaw in the design of namespaces in XML. :-(
--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA




Archive powered by MHonArc 2.6.24.

Top of Page