[
Lists Home |
Date Index |
Thread Index
]
- From: Peter Murray-Rust <peter@ursus.demon.co.uk>
- To: "XML Developers' List" <xml-dev@ic.ac.uk>
- Date: Mon, 20 Jul 1998 22:33:36
At 07:32 20/07/98 -0400, David Megginson wrote:
>How should SAX support namespaces? I can think of three options:
I am really pleased this subject has been raised because I think that it's
critical to solve it at the SAX level. I have been waiting for syntactic
guidance until the next Namespace draft is released, but playing with the
abstract ideas in JUMBO2. So far it's been going quite well.
I have layered this on top of SAX and have created two classes:
Namespace
UniversalName
Every namespace generating event (a PI in the 1998May revision) can
generate a Namespace. The event has to be checked for uniqueness of prefix
(but no uniqueness of ns). These Namespaces can be retrieved by prefix from
an ElementName. The ElementNames generate a UniversalName which for
convenience inside the program I hold as nsString+SEPARATOR+localName. (The
spec suggest an ordered pair - if we can find a SEPARATOR which is
guaranteed not to occur in a URN it just makes it a bit easier (this is
DavidM's #2 but with something other than COLON). [It never sees the light
of day, anyway].
The Universal name is the thing which should be independent of document
instance syntax. I use it primarily for mapping to Java classes and - in
the absence of the rest of the world agreeing on how to do this - I have
temporised with a PI of the form:
<?jumbo:namespace ns="http://xml-cml.org" prefix="CML"
java="jumbo.cml.%sNode">
where localPart (with initial capitalises letter) replaces %s. Thus
CML:Molecule is mapped to jumbo.cml.MoleculeNode. When a common mechanism
is agreed this PI can be disabled.
The problem I face is with other specs (especially XPointer). These will
have to be revised to fit namespaces, since I think relying on a prefix in
a given document may be very dangerous. Thus I'd like to be able to search
for <CML:Molecule> in a document using XPointer but cannot rely on the
'CML'. [I know that some people say XPointer shouldn't be used for such
'searches' but my will is weak.] The XPointer spec will have to read
something like:
descendant(2,%universalName{[http://xml-cml%SEPARATOR]?Molecule})
where the [...]? means optional and the %universalName operator means 'use
the UniversalName (which may or may not have a prefix according to what the
document author decided). This will then cater for a document like:
<?xml:namespace ns="http://xml-cml.org" prefix="CML"?>
<?xml:namespace ns="http://xml-cml.org" prefix="ChemML"?>
<CML>
<ChemML:Molecule>
<ATOMS>...</ATOMS>
</ChemML:Molecule>
</CML>
This might appear perverse but all three elements types can 'belong to the
CML DTD'. [I am not invoking scoping.] In a multiauthor document I think
it's quite possible that we shall see:
<P>, <HTML:P> and <H:P> all referring to the HTML paragraph element.
I also pass over the rather hairy problem of validating DTDs.
I wonder whether namespace-aware DTD software has to add defaults on the
basis of Universal names and not element types. Thus:
<?xml:namespace ns="http://xml-cml.org" prefix="CML"?>
<?xml:namespace ns="http://xml-cml.org" prefix="ChemML"?>
<!DOCTYPE CML [
<!ATTLIST CML:Molecule title CDATA #FIXED "A molecule">
]>
<CML>
<ChemML:Molecule>...</ChemML>
</CML>
What attributes does the <ChemML:Molecule> element have??
By tackling this at the SAX level we have a really wonderful opportunity to
help ensure that ambiguities are as few as possible. I suspect that some
exciting areas will arise - this is new territory!
FWIW I am very pleased with what can be done with namespaces :-)
P.
Peter Murray-Rust, Director Virtual School of Molecular Sciences, domestic
net connection
VSMS http://www.nottingham.ac.uk/vsms, Virtual Hyperglossary
http://www.venus.co.uk/vhg
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)
|