[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [Q] How should SAX support Namespaces?

  • From: Peter Murray-Rust <peter@u...>
  • To: "XML Developers' List" <xml-dev@i...>
  • Date: Mon, 20 Jul 1998 22:33:36

sax xml namespaces
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@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.