Create XML document instances to conform to
the given DTD definitions, two for each. Note that these are really simple
Include the DTD to the XML document (as an internal subset of the structure). The beginning of the file looks like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE seat [ <!ELEMENT seat (person?) >
<!ELEMENT person (#PCDATA)>
a) <!ELEMENT seat ( person?) >
b) <!ELEMENT course ( number, (teacher | assistant+), (credit | non-credit )) >
c) <!ELEMENT farm (farmer+, (dog* | cat?), pig*, (goat | sheep )?, (hen+| goose*) )>
Save and test with a browser, for example IE.
Why is the following document instance not valid if the DTD is like the DTD here? Make the necessary corrections and indicate your corrections by a comment.
In an earlier exercise you created a phone book XML markup. Create now a DTD for it or for the curriculum XML. Use The W3 on-line validator is located on http://validator.w3.org/ to validate it. Make the DTD internal for the validator. Note also, that it requires that each element is explicitly defined like below:
Or use http://codeplot.com to create and validate xml files.
<!ELEMENT sense (definition, example*)>
<!ELEMENT definition (#PCDATA)>
<!ELEMENT example (#PCDATA)>
If you use an XML editor like the one that comes with Visual Studio, it does the validation during editing.
Create an XML document instance with your own data to conform to
the given schema. Use any editor of your preference, for example Eclipse. The schema is called contacts.xsd. Add at least 3 people to it.
Your XML document instance might look something like this: example.
Modify the schema and add a gender attribute (required) that can have two possible values: male and female.
Note that the contact can have only one phone number according to the schema definition. Change it so that there can be more than one phone number, as well as an email address and possibly also a Web-site. Modify your document instance accordingly.
One validator is www.validome.org.
another validator: http://www.corefiling.com/opensource/schemaValidate.html
another validator: http://www.utilities-online.info/xsdvalidation/
Or use Eclipse or http://codeplot.com to create and validate xml files.
Now try to create a schema for the phonebook or restaurant menu that you drafted earlier. Does this change the original design? You can try the Visual Studio .NET Schema generator by opening the XML file in Visual Studio and select XML and Create schema, but note that the resulting schema needs tuning.Check the validity.
|Created by: Jaana Holvikivi Updated: 31.3.2015|