Archive of UserLand's first discussion group, started October 5, 1998.

Re: XML Namespaces difficulty

Author:Ken MacLeod
Posted:8/30/2000; 9:31:55 AM
Topic:cam?
Msg #:20545 (In response to 20508)
Prev/Next:20544 / 20546

That's very good, I love hearing about tuples, sets, and operators. Given that definition, I would only ask whether the NamespaceURI part is ever implied by context, rather than stated explicitly?

It's best that we seperate logical model (as defined in XML Information Set) from serialization model (as defined in Namespaces in XML).

In the logical model (what one would see in a tree or from a parser [not in "keep the serialization as-is" mode]), no, NamespaceURI is never implied by context, it is always explicit. In the serialization, one can default the namespace for unqualified names by using a standalone "xmlns=" declaration (ie. without the prefix).

    dc = "http://purl.org/dc/elements/1.1/"

doc.title doc.description doc.(dc, 'source')

What default namespace qualifies the symbols 'title' and 'description' above?

If an element or attribute name does not have a namespace, then NamespaceURI is null. (In the serialization, this means any element or attribute name not in the scope of a default namespace declaration, "xmlns=".)

The example looks like code in some language I assume is not XML. Often code in procedural languages is less ambiguous than encodings in declarative languages.

My bad. My example code actually does hide an ambiguity of my design: I convert XML to "real" application objects, like EMail messages, MP3 headers, or HTML page. Since the object above, 'doc', itself possibly has a namespace (defined by its class), those attributes may be in the namespace of the object. They may also have a null NamespaceURI. Unqualified (accessing without the tuple form), I would treat (null, 'title') the same as ('URI-of-doc-class', 'title'). The example would be synonomous with this:

    dc = "http://purl.org/dc/elements/1.1/"

doc.(null, 'title') doc.(null, 'description') doc.(dc, 'source')

and this:

    dc = "http://purl.org/dc/elements/1.1/"
    doc_ns = "URI-of-doc-class"

doc.(doc_ns, 'title') doc.(doc_ns, 'description') doc.(dc, 'source')

(Aside, that code most closely resembles code I've written in Python, where it's really: doc[(dc, 'source')].)




This page was archived on 6/13/2001; 4:56:24 PM.

© Copyright 1998-2001 UserLand Software, Inc.