[PATCH] XML validity of kcfg files

Frans Englich frans.englich at telia.com
Wed Nov 3 06:19:53 GMT 2004


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





More information about the kde-core-devel mailing list