[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Namespace: what's the correct usage?
- From: David Carlisle <davidc@nag.co.uk>
- To: marting@develop.com
- Date: Sun, 20 May 2001 09:30:51 +0100
Your last paragraph conjures up all sorts of great images! I don't really
anticipate the stuff I generate being used in other documents as most of it
is transient messages. Either way the xmlns='' of the parent will help
protect the child elements from subversive forces ;-)
No the xmlns="" just makes explicit that these elements are not
"protected" by a namespace. You are losing all the value of the
namespace rec in giving a possibility of generating unique element
names.
for example an XPath of //x:parent will only match your parent
element if x: is bound to your namespace, but your child elements
are just in with the general mess so are matched with //child
an XPath that might have been intended for some completely different
document type. The whole point of the namespace REC is to avoid such
acidental clashes and have each element name unambiguously tied to its
namespace.
There is a local scoping happening but it is the bindings of prefixes
(or non-prefix) to namespaces that is scoped. Your use of the unprefixed
element names to mean the namespace of the most recently declared prefix
is completely at odds with the interpretation specified in the namespace
rec.
why add xmlns="" to the parent and not xmlns="the namespace of the parent"
If you did the latter, your instance documents would look more or less
the same, with no prefixes on the children, and your elements would all
be in the same namespace, which is a lot more natural.
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp