CS 6795 Semantic Web Techniques

Lab 1


Create your own XML DTD and XSD


Consider these examples of XML documents for clause sets consisting of zero or more facts f (Prolog: f.) and zero or more 'backward' rules c <- p (Prolog: c :- p.), in any order ("myurl" will be replaced as explained below):

<?xml version="1.0" standalone="no"?>
<!DOCTYPE clauses SYSTEM "myurl">
    <fact> f </fact>
    <rule> <conc> c </conc> <prem> p </prem> </rule>
<?xml version="1.0" standalone="no"?>
<!DOCTYPE clauses SYSTEM "myurl">
    <rule> <conc> c1 </conc> <prem> p1 </prem> </rule>
    <fact> f1 </fact>
    <rule> <conc> c2 </conc> <prem> p2 </prem> </rule>
    <fact> f2 </fact>
    <fact> f3 </fact>


Inductively complete this XML DTD (overwrite the "..." lines) for such clause sets:


<!ELEMENT clauses   (................)>
<!ELEMENT rule   (................)>
<!ELEMENT fact    (#PCDATA)>
<!ELEMENT ........    (................)>
<!ELEMENT ........    (................)>

Put a file containing (just) your completed DTD somewhere in your personal Web space under a URL of your choice, here called "myurl".

Validate the above document examples and other ones online:
> Go to



> Paste in the examples and replace "myurl" at

Source code

> Hit the 'Validate' button
> You should basically get:
The Document is valid.

You can now experiment with variations of the original XML DTD and document examples.


If you reformulate the original XML DTD into an XML Schema Definition (XSD), W3C's XSV Validator for XML Schema at http://www.w3.org/2001/03/webdata/xsv can be employed instead.

You can do this DTD-XSD reformulation in analogy to the reformulation of the Country Address example in the Lecture Notes. For getting familiar with XSV, you can experiment with the example’s uploaded XSD instance and schema here:


Just copy & edit these to work your way from the <address> example to the <clauses> example.


Maintained by Harold Boley