[DAS2] XML namespaces

Lincoln Stein lstein at cshl.edu
Wed Mar 15 10:49:40 EST 2006


I have just finished adding XML namespace support to the early-version Perl 
DAS2 client. BTW, if a namespace tag is reused in an inner scope with a 
different 

	<das:name xmlns:das="http://foo.bar/das" />
		<das:first>Andrew</das:first>
		<das:middle xmlns:das="http://addresses.com/address/2.0">K.</das:middle>
                <das:last>Dalke</das:last>
          </das:name>

I put middle into namespace http://addresses.com/address/2.0 and put first and 
last into namespace http://foo.bar.das.

This is the correct scoping behavior, right?

Lincoln

On Wednesday 15 March 2006 15:05, Andrew Dalke wrote:
> I mentioned this yesterday but am doing it again as its own email.
> This is a quick tutorial on XML namespaces.
>
> The DAS spec uses XML namespaces.  XML didn't start with namespaces.
> They were added later.  Older parsers, like SAX 1.0, did not understand
> namespaces.  Newer ones, like SAX 2.0, do.
>
> By default a document does not have a namespace.  For example,
>
> <person name="Andrew" />
>
> has no namespace.
>
> To declare a default namespace use the 'xmlns' attribute.  All
> attributes which start 'xml' or are in the 'xml:' namespace are
> reserved.
>
> <person name="Andrew" xmlns="http://www.biodas.org/" />
>
> This is the name 'person' in the namespace 'http://www.biodas.org/'.
> The namespace is an opaque identifer.  It leverages URIs in part
> because it's much easier to guarantee uniqueness.
>
> The combination of (namespace, tag name) is unique.  The tag
> name is also called the "local name".
>
> That's to distinguish it from a "qualified name", also called
> a "qname".  These look like
>
> <abc:person name="Andrew" xmlns:abc="http://www.biodas.org/" />
>
> This element has identical meaning to the previous element
> using the default namespace.  It's qname is 'abc:person' but
> the full name is the tuple of
>
>     ("http://www.biodas.org/", "person")
>
> For notational convenience this is sometimes written in Clark
> notation, as
>    {http://www.biodas.org}person
>
>    Element                                     Clark notation
> <person />                                      person
> <person xmlns="" />                             {}person
>                             ("empty namespace" is different than "no
> namespace")
>
> <person xmlns="http://biodas.org/" />
> {http://biodas.org/}person
> <das:person xmlns:das="http://biodas.org/" />
> {http://biodas.org/}person
> <X:person xmlns:X="http://biodas.org/" />
> {http://biodas.org/}person
>
> The prefix used doesn't matter.  Only the combination of
>    (namespace, local name)
> is important.  The Clark notation string captures that as a single
> string,
> which is much easier when doing comparisons.
>
> For example, if you try the dasypus verifier at
>
> http://cgi.biodas.org:8080/verify?url=http://das.biopackages.net/das/
> genome/yeast/S228C/feature?inside=chr1/0:1000&doctype=features
>
> one of the output messages is
>
> Expected element '{http://www.biodas.org/ns/das/genome/2.00}FEATURES'
> but
> got '{http://www.biodas.org/ns/das/2.00}FEATURELIST' at byte 113, line
> 3, column 2
>
> This shows the Clark name for the elements, indicating that the root
> element has a different namespace and local name from what Dasypus
> expects.
>
> 					Andrew
> 					dalke at dalkescientific.com
>
> _______________________________________________
> DAS2 mailing list
> DAS2 at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/das2

-- 
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
FOR URGENT MESSAGES & SCHEDULING, 
PLEASE CONTACT MY ASSISTANT, 
SANDRA MICHELSEN, AT michelse at cshl.edu (516 367-5008)



More information about the DAS2 mailing list