[jdom-interest] Attribute names and namespaces in JDOM

Murray Altheim Murray.Altheim at eng.sun.com
Wed Oct 4 12:33:40 PDT 2000


alan.quinton at autodesk.com wrote:
> 
> Is it correct for attribute names with no prefix to get associated with 
> the value of the "xmlns=" in the first element of the document?
> 
> I have a schema like:
> 
> <xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema" 
>             targetNamespace="http://www.w3.org/namespace/"
>             xmlns="http://www.w3.org/namespace/">
>    <!-- data types -->
>    <xsd:simpleType name="BaselineShiftValueType" base="xsd:string"/>
> </xsd:schema>
> 
> and when I call element.getAttribute("name") on the xsd:simpleType 
> element this throws a NoSuchAttribute exception. This seems incorrect
> to me...specifically that the "" prefix should be associated with a
> URI for attribute names. If it is correct it seems inconvenient. Am 
> I totally off the mark here?

Sorry to take so long to get back to you.

The 'name' attribute on <xsd:simpleType> is scoped to its element and
is therefore in the "http://www.w3.org/1999/XMLSchema" namespace. 
Unprefixed attributes are always scoped to their elements. You'll note
that in Section 5.2 of XML Namespaces "[...] default namespaces do not
apply directly to attributes."
 
Murray

[*] http://www.w3.org/TR/REC-xml-names/#defaulting
...........................................................................
Murray Altheim, SGML/XML Grease Monkey     <mailto:altheim&#64;eng.sun.com>
XML Technology Center
Sun Microsystems, 1601 Willow Rd., MS UMPK17-102, Menlo Park, CA 94025

      In the evening
      The rice leaves in the garden
      Rustle in the autumn wind
      That blows through my reed hut.  -- Minamoto no Tsunenobu



More information about the jdom-interest mailing list