![if !IE]> <![endif]>
An XML element is everything from (including) the element's start tag to (including) the element's end tag. An element can contain:
- other elements
- Or a mix of all of the above...
XML vocabulary is used to define - element and attribute names
- element content
- Semantics of elements and attributes
Some of the xml vocabularies are XHTML, RSS, XSL, DTD, and Schema
Document Type Definition purpose is to define the structure of an XML document. It defines the structure with a list of defined elements in the xml document.
<!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>
Where PCDATA refers parsed character data. In the above xml document the elements to, from, heading, body carries some text, so that, these elements are declared to carry text in DTD file.
This definition file is stored with .dtd extension.
It is an alternative to DTD to define the structure of an XML document. <xs:element name="note">
<xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence>
This definition file is stored with .xsl extension.
XML DTD vs XML Schema:
The schema has more advantages over DTD. A DTD can have two types of data in it, namely the CDATA and the PCDATA. The CDATA is not parsed by the parser whereas the PCDATA is parsed. In a schema you can have primitive data types and custom data types like you have used in programming.
Two types of XML parsers:
– Validating Parser
• It requires document type declaration
• It generates error if document does not
– Conform with DTD and
– Meet XML validity constraints
– Non-validating Parser
• It checks well-formedness for xml document
• It can ignore external DTD
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.