Joerg Heinicke wrote:
On 26.08.2007 16:07 Uhr, Grzegorz Kossakowski wrote:
Are these valid xml files?:
Nit-picking: None of them is valid as there is nothing to validate
against like a DTD or a schema. You can only talk about well-formedness.
yep, sorry for that - I mix it all the time.
<root>
<foo:foo xmlns:foo="http://foo.org/1.0">
</foo:foo>
<!-- namespaced element outside namespace declaration -->
<foo:foo>
</foo:foo>
</root>
If the second one is valid we have to keep all declared namespaces till
the end of xml file (gets worse for xmls with jx:imports).
Second file is valid XML but second "foo" element is in the same
namespace as root element (empty
namespace) and it's full name is "foo:foo". Lack of namespace
declaration makes prefix meaningless
and part of element's name (if prefix is attached to the namespace
it's part of element's name also).
That's not correct. This one is not well-formed, it should result in a
"undeclared namespace prefix"-exception.
ok, int this case cocoon template behaves properly:
<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<foo:foo xmlns="http://foor.org/bar/1.0">
<something/>
</foo:foo>
<foo:foo>
<something/>
</foo:foo>
</root>
raises an SAXParseException.
what about this one:
<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<foo:foo xmlns="http://foo.org/bar/1.0">
<something/>
</foo:foo>
<foo:foo xmlns="http://muu.org/foo/2.0">
<something/>
</foo:foo>
</root>
I get also org.xml.sax.SAXParseException: The prefix "foo" for element
"foo:foo" is not bound.
this works properly (switched default namespace to foo namespace):
<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<foo:foo xmlns:foo="http://foo.org/bar/1.0">
<something/>
</foo:foo>
<foo:foo xmlns:foo="http://muu.org/foo/2.0">
<something/>
</foo:foo>
</root>
--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.