Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Higher level namespace declarations for compactness

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Ed Davies <edavies AT nildram.co.uk>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Higher level namespace declarations for compactness
  • Date: Fri, 22 Sep 2006 15:35:27 +0100

The javadoc for Element addNamespaceDeclaration says:

This is only necessary when prefixes are used in element content and
attribute values, as in XSLT and the W3C XML Schema Language. Do not use this method to declare prefixes for element and attribute names.

I have a strong urge to use this method to declare a namespace on an
element when the namespace will not be used by that element itself. It
will, however, be used on a large number of attributes of contained
elements. The advantage of declaration on the top level element is
simply compactness of the file - avoiding duplication of the namespace
declaration on each of the child elements.

The particular case I have is the generation of SVG documents where
I want to add annotations to the SVG drawing elements indicating
which objects in my data model they are associated with. Avoiding
the repeated namespace declaration saves about 25% on the file size.

Obviously, it shouldn't make any difference to the meaning of the
file (as there is no use of QNames in content here).

Am I right to ignore the advice quoted above or is there a better
way to achieve this effect?

Ed.






Archive powered by MHonArc 2.6.24.

Top of Page