Re: [xml] xmllint and namespaces



On Fri, Oct 11, 2002 at 02:00:57PM +0200, Stefan Kost wrote:
Hi hi,

I am sure this has been aksed bevor but wasn't succesful in the mail-archive.
I've just tried to use

xmllint --noout --valid test.xml

on test.xml :

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE giml SYSTEM "/opt/gitk/share/gitk/giml.dtd">
<giml:giml xmlns:giml="http://gitk.sourceforge.net/";>
   <giml:context/>
</giml:giml>

a fragment of the dtd :

<!ELEMENT giml (context+)>
<!ELEMENT context (#PCDATA)>

and get the following output:

test.xml:6: validity error: Element giml content doesn't follow the DTD
Expecting (context)+, got (giml:context )
</giml:giml>

this looks to me as libxml2 would like me to put the name space into the dtd, 
which I don't belive is the right thing to do.

  Well it is ... 
  Validation happens before namespace recognition.
You must use the QName in the DTD as seens in the instance:

<!DOCTYPE giml:giml SYSTEM "/opt/gitk/share/gitk/giml.dtd">
<giml:giml xmlns:giml="http://gitk.sourceforge.net/";>
    <giml:context/>
</giml:giml>

and 

<!ELEMENT giml:glim (glim:context+)>
<!ELEMENT giml:context (#PCDATA)>

and don't forgot to add xmlns:giml as part of 
<!ATTLIST giml:glim

Or use the default namespace 
   <giml xmlns="http://gitk.sourceforge.net/";>
      <context/>
   </giml>

and keep your DTD as-is

  And please make sure you use the latests versions of libxml2

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]