7

I'm aware of the default namespace in XML, e.g. declare xmlns="xxx" for an element, and this namespace will apply to all children without a prefix. My question is, if instead of xmlns="...", xmlns:pre="..." is declared in the element, are unprefixed child elements still associated with the namespace of the parent?

Here is an example:

<?xml version="1.0" ?>
<srv:tutorial xmlns:srv='http://www.w3resource.com/server-side-tutorial'>
    <name>php</name>
    <name>asp</name>
    <name>jsp</name>
</srv:tutorial>

What is the namespace of the three inner name elements?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Brett
  • 165
  • 6

1 Answers1

5

All the three inner 'name' elements belong to the 'default' or 'empty' namespace, not the namespace prefixed with 'srv'.

Alfred Xiao
  • 1,758
  • 15
  • 16
  • 2
    There is no empty NS. That does not exist. And here, there is no default NS. Thus they don't belong to any NS. – Ludovic Kuty Oct 30 '14 at 20:05
  • By 'default' and 'empty', I meant `logically` they are in `that` namespace which of course is not a legitimate namespace. For our reference, we can take a look at http://www.w3.org/TR/1999/REC-xml-names-19990114/#ns-breakdown, exampling a RESERVATION containing SEAT and DEPARTURE which are very similar to our case. – Alfred Xiao Apr 03 '15 at 11:14