Welcome to WebmasterWorld Guest from 126.96.36.199
Forum Moderators: httpwebwitch
<?xml version = "1.0" encoding = "UTF-8"?>
<root xmlns:a="AAA" >
<www xmlns:b="BBB" />
< #*$! xmlns:c="CCC">
not sure why #*$!> comes up, it should be x x x
and </ x x x.
XML Namespaces are a big pain in the patootie.
Here is a very useful (and verbose) XML namespace FAQ [rpbourret.com].
You need to define your namespace as a valid URI (not necessarily URL) format.
Here are a couple of examples:
<rootelem xmlns="http://www.example.com" xmlns:misc="http://www.example.com/misc">
the question asks the five elements on lines 06 to 10 are local-name z. i need to identify the URI of the namespace of the element or why the element is not in a namespace.
my first thought was
line 6: <a:z /> is AAA
line 7: <b:z /> is BBB
line 8: <c:z /> is CCC
line 9: <d:z /> is DDD
but im not sure. any ideas please.
line 9: <d:z /> is DDD
I'm also not sure that this is legal in XML:
< x xx xmlns:c="CCC">
</ x xx>
Spaces aren't allowed in element names.
At first blush, I would look askance at any exercise that says that a space as the first character of an XML element name is OK [w3.org].
That namespace FAQ [rpbourret.com] is very, very good. I will be the first to admit that I am no namespace expert, but I haven't seen a namespace xmlns attribute [rpbourret.com] described in anything other than URI form [en.wikipedia.org]. But then, you learn something new every day, and I would be interested in learning a bit more about this. It sounds like XML is actually a bit more flexible than I'd thought.
This means either a valid URL, or some other URI scheme [w3.org]. You can use the URN [w3.org] scheme, but the URN is supposed to be registered, sort of like a domain name. This is why the URL form is the most popular. It guarantees a unique namespace. Namespace declarations need to be globally unique.
Also, a namespace, as declared by the xmlns "attribute," applies to an element, and all its descendants. That's why declaring a namespace in <www will not apply to the subsequent <b:z element, as the <www element has been closed. The only namespaces that apply to the elements are the ones declared in <root and the <#*$! element (It turns into a stream of gibberish because WebmasterWorld has these rather annoying filters on its content, and I guess it thinks that you want to cuss).
Namespaces cannot be legally declared as "AAA" etc., because that is not valid URI form.
I sincerely hope that this helps you out.
[edited by: cmarshall at 12:33 pm (utc) on Aug. 10, 2007]
for arguments sake would line 6 AAA and line 8 CCC if it was well formed with proper URI. would 7 and 9 not be in a namespace because they are closed off.
That is correct. FAQ [rpbourret.com] says that the scope of a namespace is the element on which it is declared (using the xmlns declarator) and the descendants of the element.
what happens to the <z /> on line 10, does it have a URI and would it be the root URI.
That is in the default namespace. It either has no namespace, or, if you declare a default namespace [rpbourret.com], it is in that namespace.