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

Upload 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 and edit the examples at “Enter the Markup to validate:” like here for myurl  =  http://www.cs.unb.ca/~boley/cs6795swt/country-address.dtd  (already uploaded - on the course site - for convenience):
<?xml version="1.0" standalone="no"?>
<!DOCTYPE address SYSTEM "http://www.cs.unb.ca/~boley/cs6795swt/country-address.dtd">
<name>Xaver M. Linde</name>
<street>Wikingerufer 7</street>
<town>10555 Berlin</town>


> Hit the 'Check' button
> You should basically get:

This document was successfully checked … .

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