Introduction
XML or Extensible markup language is a way of encoding documents in such a format that is platform independent. The fact is that it is widely used by different servers to connect and transfer data between each other. It has a lot of other uses such as backing up data.
Document Type Definition
DTD is used to define the type of the particular document. Such a document should contain elements, attributes, entities, & notations used in the XML that this dtd is defining. In other words, the DTD sets the rules that the XML file must follow & in the case that the XML markup doesn't follow the rules, the XML file is tagged as invalid.
XML Schema Definition
This type of schema definition, does the same job as the previously mentioned DTD but it brings alot of advantages over the other schema languages, here is a list of such advantages:
- It's more direct - it doesn't require any intermediate processing using a parser.
- Auto schema creation
- It uses XML Format unlike other schema languages
- Can specify data types for attributes and elements
Here's an example of an XSD schema definition:
Schema Declaration:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">Element:
<xsd:element name="Student"
minOccurs="0"
maxOccurs="unbounded">
Attributes:
<xs:attribute name="myattribute" type="string"/>XPath
Is used to define parts of an XML document and makes up a large part of an XSLT document. It also contains a set of functions to navigate an XML document and these could be found in XQuery and XPointer.
XSLT
Xslt is a document that defines styles for xml documents. For example one can convert an XML document into an XHTML one only with the use of XSLT.
TASK
The task for this week is to first write an XML document and test it in an XML validator which can be found here. So I set myself to write a short XML document which was tested in this validator, the test resulted in no errors. Here is a sample code of the XML document and a screenshot showing the testing process & result.
The second task was to make our own DTD and validate the XML we created against it. As explained before, DTD sets the rule for the XML data provided and if the XML doesn't follow the rules set out in the DTD it will be tagged as invalid. Here's a screenshot of this test:
<?xml version="1.0"?>
<student id = "4343433M">
<name>Jack the ripper</name>
<project_title>Developement</project_title>
<category>PHP</category>
<abstract>Its a project</abstract>
<date_submitted>02-10-99</date_submitted>
</student>
<student id = "4343433M">
<name>Jack the ripper</name>
<project_title>Developement</project_title>
<category>PHP</category>
<abstract>Its a project</abstract>
<date_submitted>02-10-99</date_submitted>
</student>
The second task was to make our own DTD and validate the XML we created against it. As explained before, DTD sets the rule for the XML data provided and if the XML doesn't follow the rules set out in the DTD it will be tagged as invalid. Here's a screenshot of this test:


0 comments:
Post a Comment