to the main page about the tutorial  THE XML REVOLUTION  -  TECHNOLOGIES FOR THE FUTURE WEB back up next

Namespace declarations

Namespaces are declared by special attributes and associated prefixes:

<... xmlns:foo="http://www.w3.org/TR/xhtml1">
  ...
  <foo:head>...</foo:head>
  ...
</...>

xmlns:prefix="URI" declares a namespace with a prefix and a URI:

For backward compatibility and simplicity, unprefixed element names are assigned a default namespace: WidgetML with namespaces:

<widget xmlns="http://www.widget.org"
        xmlns:xhtml="http://www.w3.org/TR/xhtml1"
        type="gadget">
  <head size="medium"/>
  <big><subwidget ref="gizmo"/></big>
  <info>
    <xhtml:head>
      <xhtml:title>Description of gadget</xhtml:title>
    </xhtml:head>
    <xhtml:body>
      <xhtml:h1>Gadget</xhtml:h1>
      A gadget contains a big gizmo
    </xhtml:body>
  </info>
</widget>

back COPYRIGHT © 2000-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH next