Re: [xml] DTD validation & namespaces
- From: Daniel Veillard <veillard redhat com>
- To: "Keim, Markus" <markus_keim ordat com>
- Cc: "libxml2 mailing List (E-Mail)" <xml gnome org>
- Subject: Re: [xml] DTD validation & namespaces
- Date: Wed, 26 Nov 2003 11:31:16 -0500
On Wed, Nov 26, 2003 at 02:24:55PM +0100, Keim, Markus wrote:
Hello Daniel, hello all,
well, i know that's a long-winded topic, but i hope my actual
question is rather basic.
I've read the 'namespaces' part of the libxml2 online docs
and skimmed through the mailing archives, i'd guess two points
could be put out:
- DTD validation for documents that uses prefixes and
different namespaces is problematic
yes but it's not specific to libxml(2), it's due to the fact that
namespaces were added to XML after the main spec was released ,
and as a result XML-1.0 and DTD validation are ignorant of namespaces.
- DTD validation for documents with a default namespace,
declared on the root element should be possible using
libxml2
DTD validation of documents with namespaces are possible.
You must define the prefixes in the DTD exactly as you will find them
in the instance, that's all.
I've done my first attempts at walking in that direction
by validating a simple document using xmllint (v2.6.1)
(well, to be honest i've tried it first with my application,
but i've checked it with xmllint):
============================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY>
]>
<foo xmlns="http://foo.acme.com/" />
============================================================
Using "--valid", i get an validation error:
~>xmllint --valid --noout foo.xml
foo.xml:5: element foo: validity error : No declaration for
attribute xmlns of element foo
<foo xmlns="http://foo.acme.com/" />
^
that's normal,
Using "--postvalid", the document validates.
that's an error, but I can't reproduce it with the currnet code
paphio:~/XML -> xmllint --valid --noout tst.xml
tst.xml:5: element foo: validity error : No declaration for attribute xmlns of element foo
<foo xmlns="http://foo.acme.com/" />
^
paphio:~/XML -> xmllint --postvalid --noout tst.xml
tst.xml:5: element foo: validity error : No declaration for attribute xmlns of element foo
Document tst.xml does not validate
paphio:~/XML -> cat tst.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY>
]>
<foo xmlns="http://foo.acme.com/" />
paphio:~/XML ->
Or is it actually necessary to declare "xmlns" as attribute
for the root element?
that's necessary.
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]