On Apr 22, 2004, at 11:23 AM, Gareth Reakes wrote:


Hi,

How does it possibly know what prefix to use?

There is an algorithm in the DOM specs it uses. It looks to see if there
is an appropriate one else makes one up (simplification). Take a look if
you want more info.

Ok, but if I want an explicit one, I don't see any way to do that other than setting my elements with their prefix already set.


Besides, the
documentation seems to indicate that a prefix should be supplied as
part of the qualifiedName (since, technically, that would include the
namespace, that seems logical to me).  The documentation says: The
'NAMESPACE_ERR' exception is thrown "...if the qualifiedName has a
prefix and the namespaceURI is null", which seems to indicate that
prefixes are expected in the qualifiedName field.

The important part is "if the qualifiedName has a prefix and the
namespaceURI is null". In the XML world you cannot bind a prefix to the
null namespace so you cannot give a prefix to an element/attr if it has no
namespace. You can give a namespace to an ele/attr and not give it a
prefix. Try out a few examples and serialize them if this is not clear.

I understand why you can't give a prefix if there's no namespaceURI - that makes perfect sense. I was just extending that conclusion to mean that a prefix was expected if a namespaceURI was specified. Apparently that is not the case, but I'm not sure I completely understand that, because I don't really want DOM choosing my namespace qualifier in a random way. Is it not expected that the user will want to explicitly set their namespace qualifier, rather than having it chosen for them?


--
Nick


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to