Validating HAL device info files
Dave Malcolm
david at davemalcolm.demon.co.uk
Fri Jan 2 18:03:58 EET 2004
On Fri, 2004-01-02 at 12:51, David Zeuthen wrote:
> On Thu, 2004-01-01 at 21:43, Dave Malcolm wrote:
> > There didn't seem to be a DTD for HAL device info files, so I put one
> > together; you should find it attached. It's very much a first attempt -
> > I hacked it until it validated the example fdi file in the HAL 0.2
> > tarball - so it might need some refinement.
> >
> > I'll do a RelaxNG schema if anyone's interested.
>
> Thanks, I have put this in fdi/fdi.dtd in CVS. I've also made it install
> into $(datadir)/hal/fdi/fdi.dtd.
>
I put together a RELAX NG schema, you should find it attached.
It's "tighter" than the DTD since it allows only one of string, int, or
bool as attributes inside a <match> element, and tries to constrain
their values according to type, plus it constrains the content of a
<merge> based upon its type attribute.
It currently doesn't constrain the value of a <match> element's int
attribute. The parser in hald/device_info.c seems to use strtol so the
value can be expressed in hex, octal or decimal - the only current
example uses hex. I believe the rng file could express this using
pattern facets (I'm learning RELAX NG as I go along, hope it doesn't
show)
--
David Malcolm
www.conglomerate.org
-------------- next part --------------
<?xml version="1.0"?>
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
>
<start>
<element name="deviceinfo">
<attribute name="version">
<choice>
<value>0.1</value>
<value>0.2</value>
</choice>
</attribute>
<zeroOrMore>
<ref name="device"/>
</zeroOrMore>
</element>
</start>
<define name="device">
<element name="device">
<zeroOrMore>
<choice>
<ref name="match"/>
<ref name="merge"/>
</choice>
</zeroOrMore>
</element>
</define>
<define name="match">
<element name="match">
<attribute name="key"/>
<choice>
<attribute name="bool">
<data type="boolean"/>
</attribute>
<attribute name="int">
<data type="string"/>
</attribute>
<attribute name="string">
<text/>
</attribute>
</choice>
<zeroOrMore>
<choice>
<ref name="match"/>
<ref name="merge"/>
</choice>
</zeroOrMore>
</element>
</define>
<define name="merge">
<element name="merge">
<attribute name="key"/>
<choice>
<group>
<attribute name="type">
<value>string</value>
</attribute>
<text/>
</group>
<group>
<attribute name="type">
<value>int</value>
</attribute>
<data type="int"/>
</group>
<group>
<attribute name="type">
<value>bool</value>
</attribute>
<data type="boolean"/>
</group>
<group>
<attribute name="type">
<value>double</value>
</attribute>
<data type="double"/>
</group>
</choice>
</element>
</define>
</grammar>
More information about the xdg
mailing list