Stylus Studio XML Editor

Table of contents

Appendices

5 Using Qualified Names

Using Qualified Names

In XML documents conforming to this specification, element names are given as [qualified names] , as follows:

Element Names
[12]   STag   ::=   '<' [QName] (S Attribute)* S? '>'
[13]   ETag   ::=   '</' [QName] S? '>'
[14]   EmptyElemTag   ::=   '<' [QName] (S Attribute)* S? '/>'

An example of a qualified name serving as an element name:

  <!-- the 'price' element's namespace is http://ecommerce.example.org/schema -->
  <edi:price xmlns:edi='http://ecommerce.example.org/schema' units='Euro'>32.18</edi:price>

Attributes are either [namespace declarations] or their names are given as [qualified names] :

Attribute
[15]   Attribute   ::=    [NSAttName] Eq AttValue
| [QName] Eq AttValue

An example of a qualified name serving as an attribute name:

<x xmlns:edi='http://ecommerce.example.org/schema'>
  <!-- the 'taxClass' attribute's namespace is http://ecommerce.example.org/schema -->
  <lineItem edi:taxClass="exempt">Baby food</lineItem>
</x>
Prefix Declared

The namespace prefix, unless it is xml or xmlns, MUST have been declared in a [namespace declaration] attribute in either the start-tag of the element where the prefix is used or in an ancestor element (i.e. an element in whose content the prefixed markup occurs). Furthermore, the attribute value in the innermost such declaration MUST NOT be an empty string.

This constraint may lead to operational difficulties in the case where the namespace declaration attribute is provided, not directly in the XML document entity, but via a default attribute declared in an external entity. Such declarations may not be read by software which is based on a non-validating XML processor. Many XML applications, presumably including namespace-sensitive ones, fail to require validating processors. If correct operation with such applications is required, namespace declarations MUST be provided either directly or via default attributes declared in the internal subset of the DTD.

Element names and attribute names are also given as qualified names when they appear in declarations in the DTD:

Qualified Names in Declarations
[16]   doctypedecl   ::=   '<!DOCTYPE' S [QName] (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
[17]   elementdecl   ::=   '<!ELEMENT' S [QName] S contentspec S? '>'
[18]   cp   ::=   ( [QName] | choice | seq) ('?' | '*' | '+')?
[19]   Mixed   ::=   '(' S? '#PCDATA' (S? '|' S? [QName] )* S? ')*'
| '(' S? '#PCDATA' S? ')'
[20]   AttlistDecl   ::=   '<!ATTLIST' S [QName] [AttDef] * S? '>'
[21]   AttDef   ::=   S ( [QName] | [NSAttName] ) S AttType S DefaultDecl

add Note that DTD-based validation is not namespace-aware in the following sense: a DTD constrains the elements and attributes that may appear in a document by their uninterpreted names, not by (namespace name, local name) pairs. To validate a document that uses namespaces against a DTD, the same prefixes must be used in the DTD as in the instance. A DTD may however indirectly constrain the namespaces used in a valid document by providing #FIXED values for attributes that declare namespaces.