Why not PIs for namespace declarations?

Rick Jelliffe ricko at allette.com.au
Fri Dec 24 14:13:23 GMT 1999


 From: Arjun Ray <aray at q2.net>

>Yes.  There are only two natural scoping constructs in XML: elements
and
>marked sections.

I think there were three scopes in XML:
    * element over content
    * element over attribute
    * entities (e.g. documents)

If we need element scope (either over content or over attributes) then
elements are the appropriate mechanism to produce the effect.

If we need document scope for semantics that are particular to
a document type, then again elements are appropriate.

If we need document scope independent of the document type,
or parsed-entity scope, then PIs are appropriate.

If we need a point only, and the point is related to the document
type, then an element is appropiate.

If we need a point, and the point is related to the main document
type and we have a schema that will not be disrupted by the presence of
elements from another namespace, then an empty element from
another namespace is appropriate. (In SGML, we can use
global inclusions for this, too.)

If we have a point, and that point is unrelated to the main document
type, and we are using DTDs or are processing using XPaths or
their equivalent that may fall over if the element structure contains
elements in unexpected places, then PIs are appropriate.

So I think the xmlns was a good call, even though I originally
stronly supported PIs.  Once it was decided that namespaces
should have some element scope (to allow easier cut-and-paste without
needing to add explicit namespace prefixes everywhere), then
PIs became inappropriate for them.

Unfortunately, it has greatly complicated XML.  Working through
my recent confusion on XSL and namespaces, I have been shocked that
namespaces represent a third stream independent of content or
attributes.  I had thought they were merely a construct built on
top of attributes, but it seems that the way some W3C specs have
used them is to keep them in splendid isolation from other attributes.

So we have PIs that are deemed not PIs (i.e., XML header) and
attributes that are deemed not attributes (i.e., namespace attributes).
What is next: elements that are not elements?  (I suppose this is
what XInclude is.)

So now we have 4 scopes in XML

I think there were three scopes in XML:
    * element over content
    * element over attribute
    * entities (e.g. documents)
    * namespace

And the XML Schema may allow some other scoping to, based on supertype.

Since all these scopes hang off the basic element graph, none of them
provide
a substitute for PIs when the rare set of events above are met. One good
use of
a PI is this: many C/C++ editors save their settings in a comment at the
bottom
of the document. In XML documents one could use comments or PIs to
append
arbitrary settings at the end of a document.  I think PIs are the better
choice
for that.

Rick


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list