[PATCH] XML validity of kcfg files

Frans Englich frans.englich at telia.com
Wed Nov 3 00:24:38 GMT 2004


On Saturday 30 October 2004 20:48, Christian Mueller wrote:

This big thread is funny. Here we are, in general bright people -- but most of 
all web browser developers who knows everything about and loathe weird XML 
formats(and what is the matter with all those who can't write valid HTML?). 
But the lead in the thread have been; "Should we really validate?, "What 
for?," "schemas can only be used for validation", "gui editors for format X 
are mutually exclusive with schema for format X", etc.

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).


Cheers,

		Frans

-------------- next part --------------
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:kcfg="http://www.kde.org/standards/kcfg/1.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.w3.org/2001/XMLSchema 
			    http://www.w3.org/2001/XMLSchema.xsd"
	targetNamespace="http://www.kde.org/standards/kcfg/1.0"
	elementFormDefault="qualified" >
    
    <xsd:annotation>
        <xsd:documentation>
            
            Copyright (c) 2003 Cornelius Schumacher <schumacher at kde.org>
            Copyright (c) 2003 Waldo Bastian <bastian at kde.org>
            Copyright (c) 2003 Zack Rusin <zack at kde.org>
            Copyright (c) 2004 Frans Englich <frans.englich at telia.com>
            
            Permission to use, copy, modify and distribute this DTD
            and its accompanying documentation for any purpose and without fee
            is hereby granted in perpetuity, provided that the above copyright
            notice and this paragraph appear in all copies.  The copyright
            holders make no representation about the suitability of the DTD for
            any purpose. It is provided "as is" without expressed or implied
            warranty.
            
        </xsd:documentation>
    </xsd:annotation>
    <xsd:annotation>
        <xsd:documentation>
            
            A Schema for KDE's KConfigXT XML format. It is similar to the DTD
            found at:
            
            http://www.kde.org/standards/kcfg/1.0/kcfg.xsd
            
            Documents valid against the Schema version are backwards compatible
            to the DTD. Validating against the Schema instead of the DTD is
            recommended, since the former provides better validation.
            
        </xsd:documentation>
    </xsd:annotation>
    
    <xsd:attributeGroup name="datatype">
        <xsd:attribute name="type">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="String"/>
                    <xsd:enumeration value="StringList"/>
                    <xsd:enumeration value="Font"/>
                    <xsd:enumeration value="Rect"/>
                    <xsd:enumeration value="Size"/>
                    <xsd:enumeration value="Color"/>
                    <xsd:enumeration value="Point"/>
                    <xsd:enumeration value="Int"/>
                    <xsd:enumeration value="Uint"/>
                    <xsd:enumeration value="Bool"/>
                    <xsd:enumeration value="Double"/>
                    <xsd:enumeration value="DateTime"/>
                    <xsd:enumeration value="Int64"/>
                    <xsd:enumeration value="UInt64"/>
                    <xsd:enumeration value="IntList"/>
                    <xsd:enumeration value="Enum"/>
                    <xsd:enumeration value="Path"/>
                    <xsd:enumeration value="Password"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:attributeGroup>
    
    <xsd:complexType name="choice">
        <xsd:all>
            <xsd:element name="label" type="xsd:string"/>
            <xsd:element name="whatsthis" type="xsd:string"/>
        </xsd:all>
        <xsd:attribute name="name" type="xsd:string"/>
    </xsd:complexType>
    
    <xsd:complexType name="choices">
        <xsd:sequence>
            <xsd:element name="choice" type="kcfg:choice" maxOccurs="unbounded" />
        </xsd:sequence>
    </xsd:complexType>
    
    <xsd:complexType name="parameter">
        <xsd:sequence>
            <xsd:element maxOccurs="unbounded" name="values"/>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string"/>
        <xsd:attributeGroup ref="kcfg:datatype"/>
        <xsd:attribute name="max" type="xsd:positiveInteger"/>
    </xsd:complexType>
    
    <xsd:complexType name="entry">
        <xsd:all>
            <xsd:element name="parameter" minOccurs="0" type="kcfg:parameter"/>
            <xsd:element name="label" minOccurs="0" type="xsd:string"/>
            <xsd:element name="whatsthis" minOccurs="0" type="xsd:string"/>
            <xsd:element name="choices" type="kcfg:choices"/>
            <xsd:element name="code" minOccurs="0" type="xsd:string"/>
            <xsd:element name="default" type="xsd:string"/>
            
            <xsd:element name="min" minOccurs="0" >
                <xsd:complexType>
                    <xsd:simpleContent>
                        <xsd:extension base="xsd:integer">
                            <xsd:attribute name="code" type="xsd:boolean"/>
                        </xsd:extension>
                    </xsd:simpleContent>
                </xsd:complexType>
            </xsd:element>
            
            <xsd:element name="max" minOccurs="0">
                <xsd:complexType>
                    <xsd:simpleContent>
                        <xsd:extension base="xsd:integer">
                            <xsd:attribute name="code" type="xsd:boolean"/>
                        </xsd:extension>
                    </xsd:simpleContent>
                </xsd:complexType>
            </xsd:element>
            
        </xsd:all>
        <xsd:attribute name="name" type="xsd:string"/>
        <xsd:attribute name="key" use="optional" type="xsd:string"/>
        <xsd:attribute name="hidden" use="optional" type="xsd:boolean"/>
        <xsd:attributeGroup ref="kcfg:datatype"/>
    </xsd:complexType>
    
    <xsd:element name="kcfg">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="include" maxOccurs="unbounded" type="xsd:string"/>
                <xsd:element name="kcfgfile" type="xsd:string"/>
                <xsd:element name="group" maxOccurs="unbounded" >
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="entry" type="kcfg:entry" maxOccurs="unbounded"/>
                        </xsd:sequence>
                        <xsd:attribute name="name" type="xsd:string"/>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>



More information about the kde-core-devel mailing list