XML Document Definition and its Elements
Added on 2019-09-16
6 Pages1607 Words364 Views
|
|
|
REPORTXML Document?ANS: XML (Extensible Markup Language). It is a language which was designed to transport the data andto store the data. It composed of elements and other markup code. One element can contain some other element. Along with element, markup it may contain some other like comment and processing Instruction.It consists of following elements:• XML Declaration• Document Type Declaration (DTD)• BodyXML Declaration: It is a piece of code which is used to identify this an XML document which may include version and encoding schemeDocument Type Declaration (DTD): DTD follows the xml document. It is used to validate the xml document. It contains some set of rules defined by the user.Body: Body contains the xml code which defines what this code is supposed to do. It works with the helpof element that element may contains some further element or may be some other informationWhat is Document Type Declaration?ANS: A Document type Definition contains some legal set of blocks that defines the structure of XML document. A DTD can be declared inside an XML document or can be declared in some other separate file based on its use naming is provided as Internal DTD or External DTDXML Document with an internal DTD
<?xml version="1.0"?><!DOCTYPE note [<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>]><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend</body></note>Where DOCTYPE note is use to represent the root element of the document,• Element note is also element of the root, this can be treated as the child of the root element currently itis representing the four other different element which is to, from, heading, body,• Element to defines the element of the type which can accept the data of type #PCDATA means that it can accept the data of type String• Element from is another element of the root element which also accept the of type #PCDATA
• Element heading is the element of the root which represent the heading of the root element• Element body is one another kind of element of the root element which also accept the type of #PCDATA Like in our Project we have use <?XML version="1.0" encoding=" UTF-8"?> declaration indicates that XML is of version 1 and it is using UTF-8 encoding scheme in the next upcoming line it is showing that this XML document is used to provide web stylesheetNow the body of the XML starts here which contain top most element carAccessoriesShop which contains further two elements first one is shopDetail and second one is carAccessories. First element shopDetail is used to provide the description of that shop and carAccessories is use to provide the details of car type. ShopDetail may contain further some element where each element is used to provide the detail of the shop like shopName, address, telephone, website, Image. shopName element represents the name of the shop; the address is use to represent the address of that shop, telephone contains the number of that businessman, the website provides the link of the website, the image is used to represent the logo of the business. Whatever rule we have discussed above is similarly explained in the DTD Document like <!ELEMENT carAccessoriesShop (shopDetail,carAccessories)> where carAccessoriesShop is contained two more element shopDetail, and carAccessories like that shopDetail contain further some other elementone of them is <!ELEMENT shopName (#PCDATA)> here shopName is one another element which can accept the value in XML and #PCDATA is telling what kind of value it can accept here it can accept String type of value.In the second element of carAccessingShop <carAccessories> is used in that some other 10 group of element and because it is more than one like this <!ELEMENT carAccessories (item+)> so we write item+ but if there is just 1 item we don’t need to mention it like in above case then in each item we need to specify what kind of item it is like the first item is given as <item type="batteryChargers"> in each data
End of preview
Want to access all the pages? Upload your documents or become a member.
Related Documents