Introduction
HTML mixes content data and makes it difficult to present the same data and standardize presentation across multiple sets of data. XML organize information into tree-like structures with each item of information representing a leaf. The advantage of using XML in preference to proprietary format is when information is structured. The XML is turned to standardize the representation of information in respective areas.
XML Document
- <?xml version = "1.0" encoding = "ISO-8859-1" ?>
- < starfleet >
- < title >
- Startship
- </ title>
- < starship name = "USS Enterprise" sn = "NCC-1701" >
- < class name = "Constitution" />
- < captain > Jack sparrow
- < /captain>
- </ starship>
- <starship name = "USS Enterprise" sn = "NCC-1701-D" >
- < class name = "Galaxy " />
- < captain> Jean </captain>
- < /starship>
- < /starfleet>
The above code has standard and the character set used in the document and tags are closed in ending tag and the tag reflect the logical structure of data. XML documents contain processing instructions for the application and comments and document type. To verify the validity of xml documents and to communicate their structure to others by possibility of specifying in a separate document. The main method used to specify document structures are the XML, DTD and XML schemes.
XML DTDs
DTD is developed for XML predecessor and standard generalized markup language and the syntax of the DTD is shown below. It defines the start fleet element consist of a title element and starship element. Attribute type has many possible values and enumeration of all strings available.
- <! ELEMENT starfleet ( title,starship*) >
- <! ELEMENT title (#PCDATA) >
- <! ELEMENT starshp (class , captain)>
- <! ATTLIST
- starship name CDATA #REQUIRED
- sn CDATA #REQUIRED >
- <! ELEMENT class EMPTY >
- <! ATTLIST class name CDATA #REQUIRED >
- <! ELEMENT captain (#PCDATA) >
XML Schemes
It is used to store, handle, and style schemes like an XML document. W3C describes the standardized XML schemes in three document and is complicated. The starfleet element has an attribute to contain other elements. When applied to attribute, default supplies the value of optional attribute and the fixed constraint forces an attribute value and define a vale in an XML document and must match a fixed value assigned in the schema.
- <?xml version = "1.0" encoding = "ISO-8859-1" ?>
- <xsd:schema
- xmlns:xsd = ""http:
- <xsd : annotation >
- <xsd : documentation xml:lang = "en" >
- Schema
- </xsd : documentation >
- </xsd : annotation >
- <xsd : element name = "starfleet" >
- <xsd : complexType >
- <xsd : sequence >
- <xsd : element name = "title" type = "xsd:string" maxOccurs = "1" />
- <xsd:element name = "startship" type = "ShipType" maxOccurs = "unbounded" / >
- </xsd : sequence >
- </xsd : complexType >
- </xsd : element>
- <xsd:complexType name = "ShipType" >
- <xsd : all >
- <xsd : element name = "class" type = "ClassType" minOccurs = "1" />
- <xsd : element name = "captain" type = "xsd : string" minOccurs = "1" /></xsd : all>
- <xsd : attribute name = "name" type = "xsd:string" use = "required" />
- <xsd : attribute name = "sn" type = "xsd:string" use = "required" /></xsd : complexType >
- <xsd : attribute name = "name" type = "xsd : string" use = "required" /></xsd : complexType >
- </xsd : schema >
Simple Type
Simple type is used to modify already defined type wthout adding attribute or other elements. Whitespace and pattern attributes is used and attributes like length and minLength is possible. The replace is used to line feed, tab characters are replaced with simple spaces and collapse is used to leading and trainling spaces are removed and sequences of multiple spaces are collapsed into single spaces.
- < xsd : simpleType name = "myString" >
- < xsd : restriction base = "xsd:string" >
- < xsd : maxLength value = "32" >
- </xsd : restriction >
- </xsdLsimpleType >
Complex Type
Complex type has additional options and it has three models namely sequence, all, the choice is used to group the elements.
Sequence - Elements appeared in a specified sequence.
All - one element listed and appear in a specified sequence.
Choice - Elements are mutually exclusive.
- <xsd : sequence >
- <xsd : choice >
- <xsd : element name = "no" />
- <xsd : all>
- <xsd : element name = "yes" / ></xsd :all>
- </xsd : choice>
- <xsd : element name = "name" /></xsd : sequence >