XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
A Namespace Proposal

I've been thinking about the various namespace ideas that have appeared on 
the list, in particular Michael Kay's proposal for namespaces, but also 
trying to make sure it works for Amy's automated XML1.0 to XML??? converter 
principle, without requiring heuristics to map things like 
http://www.w3.org/1999/XSL/Transform to org.w3c.www.1999.XSL.Transform.  I 
think this is important because a parser ideally wants to present 
http://www.w3.org/1999/XSL/Transform to higher layers rather than 
org.w3c.www.1999.XSL.Transform in this case.

So here goes:

Namespaces SHOULD use the reversed domain name form, e.g. 
org.example.schema.  For compatibility with XML 1.0, namespaces MAY use the 
URI form via setting up namespace aliases which is discussed later in the 
proposal.

An element or attribute name has the form:

name = ( (namespace | namespace_alias ) ":" )? local_name

e.g.: org.example.schema:my_name

The namespace used in an element's name becomes the active namespace and is 
applied to all of its children that don't themselves have an explicitly 
specified namespace.  Thus, in:

<org.example.schema:foo>
    <bar/>
</org.example.schema:foo>

'bar' is in the org.example.schema namespace and the example is equivalent 
to:

<org.example.schema:foo>
    <org.example.schema:bar/>
</org.example.schema:foo>

To set no namespace, leave the namespace part of the name empty, but include 
the ':' that separates the namespace from the local name, for example: 
<:foo/>

For compatibility with XML 1.0, an attribute name without a namespace or 
namespace_alias is always in the empty namespace, as opposed to the active 
namespace.  Thus for an attribute the name 'foo' is always equivalent to 
':foo'.

To allow compatibility with XML 1.0, and to a lesser degree brevity, 
namespace aliases maybe setup.  This is done using 'magic' PIs that have the 
name 'xml:nsalias' which contain multiple attributes in which the name of 
the attribute specifies an alias name and the value of the attribute 
specifies the namespace name.  These PIs are primarily intended for the 
parser and in general are not presented to the application.

Thus:

<?xml:nsalias xsl="http://www.w3.org/1999/XSL/Transform"; ?>

establishes "xsl" as an alias of "http://www.w3.org/1999/XSL/Transform";.

XML alias mappings exist from the point at which they are defined until the 
end of the XML document.  (In other words, there is a single namespace alias 
mapping repository that is not aware of the element nesting.)  Aliases 
SHOULD NOT be reassigned from one namespace to another.

A namespace alias must match XML's NCName production.  To reduce the 
potential for conflicts with explicit namespaces, namespace aliases SHOULD 
NOT contain the '.' character.

Wherever an aliases character sequence matches the prefix of an element or 
attribute name, the namespace of the element or attribute becomes that of 
the namespace associated with the alias.

For example, if the above alias is set up:

    xsl:stylesheet

is conceptually equivalent to:

    http://www.w3.org/1999/XSL/Transform:stylesheet

although of course the latter is not a valid XML name.

As in the case of specifying the namespace directly (e.g. 
org.example.schema:foo), the namespace associated with the namespace alias 
becomes the active namespace.

A namespace alias may also be used in the interests of brevity, for example 
the following is equivalent to the earlier example:

<?xml:nsalias s="org.example.schema"?>
<s:foo>
    <bar/>
</s:foo>

Any thoughts?

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS