[PATCH] XML validity of kcfg files

Benjamin Meyer ben at meyerhome.net
Sat Nov 20 01:15:54 GMT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 03 November 2004 1:19 am, Frans Englich wrote:
> On Wednesday 03 November 2004 02:22, Cornelius Schumacher wrote:
> > On Wednesday 03 November 2004 01:24, Frans Englich wrote:
> > > Anyway, attached is an XML Schema version for the KConfigXT format,
> > > most of it is written but could use some polishing, and tighter
> > > validation can also be done. If someone wants to do anything with it,
> > > or in the future will do fancy stuff, it is here in the archives(I'll
> > > not push it).
> >
> > Looks nice, but it failed to validate korganizer.kcfg for me. After
> > adding a default namespace declaration to the kcfg file xmllint fails
> > with an "Element kcfg content check failed" error. Is this due to the
> > ordering constraints? Is there a better tool for validating XML files
> > against XML schemas?
>
> We can't blame xmllint for barfing, but it sure is lousy at it :) It
> doesn't tell what was wrong, only a line number and the element(I filed a
> bug report on libxml2). It barfed because the kcfg files was better at
> following the format than the Schema :) This is now fixed, and a handful of
> random kcfg files validates(including korganizer.kcfg AFAICT), but it
> surely still has its quirks.
>
> The Schema can be a pretty good way to "encourage" practices. For example,
> entries should have the label element, and by making it mandatory(I
> haven't) people will hopefully take notice and write those descriptions(and
> Benjamin's test scripts makes the bugs visible). Since it's voluntary to
> switch to the Schema, this is now the chance to tighten the format without
> breaking backwards compatibility(if one wants to do that).
>
> It's also possible to tighten validation much more, just one takes the time
> to think about it(for example, elements containing code, can be tested with
> a regexp such that it doesn't end with a semicolon, and hence save people
> from scratching their heads when the build fails).
>
> I committed it, such that it is under revision control:
>
> CVS commit by englich:
> The XML Schema version of the DTD for the KConfigXT format. When it is
> stable we can place a copy in www/
>
> The documentation(in the file) has an example of how a proper XML document
> declaration should look like. Then, one can validate the KConfigXT file
> with `xmllint --noout --schema kdelibs/kdecore/kconfig_compiler/kcfg.xsd
> foo.kcfg`.
>
>   A            kcfg.xsd   1.1
>
>
> Cheers,
>
> 		Frans

I took a closer look at the xsd today.

When using the documetion included in the file xmllint complains about the 
missing dtd. 

./korganizer.kcfg:5: validity error : Validation failed: no DTD found !
      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >

When I add the dtd in  then it has other issues:

"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
  <kcfgfile name="korganizerrc"/>..."

./korganizer.kcfg:6: element kcfg: validity error : No declaration for 
attribute xmlns of element kcfg
      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
                                                      ^
./korganizer.kcfg:6: element kcfg: validity error : No declaration for 
attribute xmlns:xsi of element kcfg
      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
                                                      ^
./korganizer.kcfg:6: element kcfg: validity error : No declaration for 
attribute schemaLocation of element kcfg
      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >

So what is the proper way to validate the xml files?

- -Benjamin Meyer

- -- 
aka icefox
Public Key: http://www.icefox.net/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFBnprO1rZ3LTw38vIRAreYAJ9kHaS8V1DNKsEEJQX9LobSeS+iuACglWAW
N1qVu9yeZs738sxtWGnAAmg=
=+/Xz
-----END PGP SIGNATURE-----




More information about the kde-core-devel mailing list