Answer:<\/strong><\/span><\/p>\n<?xml version = \"1.0\"?>\r\n<message date=\"7\/6\/2014\">\r\n<sender> Mohit <\/sender>\r\n<receiversXreceiver> Amit <\/receiver>\r\n<receiver> Saurabh <\/receiver> <\/receivers>\r\n<text> Submitted Successfully <\/text>\r\n<\/message><\/pre>\n<\/p>\n
Question 8.<\/strong><\/span> Write the procedure to link a stylesheet with an XML document.
\nAnswer:\u00a0<\/strong><\/span>Using CSS with an XML Document<\/strong>
\nTo link an XML document with a stylesheet perform the following steps:<\/p>\n\n- Create an XML document and save it as a file with the .xml extension.<\/li>\n
- Create a stylesheet and save it as a file with the .css , extension.<\/li>\n
- Link both the files in the XML document by using the PI.
\n<?xml-stylesheet href = “test.css” type = “text\/css”?><\/li>\n<\/ol>\ne.g. The following is the CSS document: \r\nPeople\r\n{\r\nbackground-color : light green; \r\ndisplay : block; \r\npadding : 5px; \r\nfont-family : arial;\r\n}\r\nPerson\r\n{\r\nbackground-color : pink; \r\nborder : 2px solid black; \r\ndisplay : block; \r\nmargin-bottom : 5px;\r\nName\r\n{\r\nfont-family : bold; \r\ndisplay : block;\r\n}\r\nBirthdate \r\n{\r\ndisplay : block;\r\n}\r\nEyes\r\n{\r\ndisplay : block;\r\n}\r\nNow, save it as test.css\r\nThe following is the XML document:\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<?xml-stylesheet type = \"text\/css\" href = \"test.css\"?>\r\n<People>\r\n<Person>\r\n<Name>A<\/Name>\r\n<Birthdate>Jan 24, 1987<\/Birthdate>\r\n<Eyes>Blue<\/Eiyes>\r\n<\/Person>\r\n<Person>\r\n<Name>B<\/Name>\r\n<Birthdate>Dec 15, 2009<\/Birthdate>\r\n< Eyes >Brown<\/Eyes >\r\n<\/Person>\r\n<\/People>\r\nNow, save it as test1.xml<\/pre>\nQuestion 9.<\/strong><\/span> What do you mean by Processing Instructions (PI)?
\nAnswer:\u00a0<\/strong><\/span>PI can be used to pass information to applications in such a way that escapes most XML rules. Its main use is of linking to an XML stylesheet in the prolog of an XML document. Processing instructions do not have to follow much internal syntax, it can include markup characters without escaping them and can appear anywhere in the document.
\n<\/p>\nQuestion 10.<\/strong><\/span> Explain child elements with an example.
\nAnswer:<\/strong><\/span> The elements nested inside other elements are called child elements.
\nConsider the following code:<\/p>\n<\/p>\n
Question 11.<\/strong><\/span> Write the full form of\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0CBSE 2014<\/strong><\/p>\n\n- XML<\/li>\n
- DTD<\/li>\n
- SGML<\/li>\n
- CSS<\/li>\n<\/ol>\n
Answer:<\/strong><\/span> Full form of given terms are as follows:<\/p>\n\n- XML extensible Markup Language<\/li>\n
- DTD Document Type Declaration<\/li>\n
- SGML Standardised Generalised Markup Language<\/li>\n
- CSS Cascading Style Sheet<\/li>\n<\/ol>\n
Long Answer Type I Questions\u00a0 [5 Marks each]<\/strong><\/span><\/p>\nQuestion 1.\u00a0<\/strong><\/span>Explain two softwares which are used to validate XML documents.
\nAnswer:\u00a0<\/strong><\/span>Two important software that validate or process XML documents are as follows:<\/p>\n\n- XML Validator<\/strong> are the software packages that check the XML document as per the specified DTD and give you feedback about the document.
\nSome XML validators are as follows:
\n(a) W3C XML Validator
\n(b) Tidy
\n(c) XML. com\u2019s
\n(d) Brown University<\/li>\n- XML Parsers<\/strong> are the software packages, which are part of bigger applications that provide XML support.
\nThe role of an XML parser is to dissect a valid XML document to obtain actual data from the XML document. Some XML parsers are as follows:
\n(a) SAXfSimple API for XML)
\n(b) Expat
\n(c) LT-XML etc.<\/li>\n<\/ol>\nQuestion 2.\u00a0<\/strong><\/span>Write an XML document that marks up the following data:
\nAll these must be rendered. Use attribute to make the data more informative.
\n
\nAnswer:<\/strong><\/span><\/p>\n<?xml version = \"1.0\" encoding=\"UTF-8\" standalone = \"yes\"?>\r\n<employees>\r\n<employee EmpID = \"e001\">\r\n<Name> Raj Kumar <\/Name>\r\n<City> Delhi <\/City><\/employee>\r\n<employee EmpID=\"e002\">\r\n<Name> Pankaj <\/Name>\r\n<Ci ty> Mumbai <\/City><\/employee>\r\n<employee EmpID=\"e003\">\r\n<Name> Rahul Sharma <\/Name>\r\n<City> Delhi <\/City> <\/employee>\r\n<employee EmpID=\"e004\">\r\n<Name> Praveen <\/Name>\r\n<City> Noida <\/City><\/employee>\r\n<\/employees><\/pre>\nQuestion 3.\u00a0<\/strong><\/span>Compare XML with similar type of other languages.
\nAnswer:<\/strong><\/span><\/p>\n1. Comparing XML and SGML<\/strong><\/p>\n\n\n\nXML<\/strong><\/td>\nSGML<\/strong><\/td>\n<\/tr>\n\nXML is a markup language.<\/td>\n | SGML is a meta language used to define and describe generic markup language.<\/td>\n<\/tr>\n | \nIt does not include complex and optional features of SGML.<\/td>\n | It is complex and requires overheads to use it.<\/td>\n<\/tr>\n | \nXML allows creation of new \u00a0tags to describe and present \u00a0your data.<\/td>\n | It is an ISO standard for specifying a set of tags,<\/td>\n<\/tr>\n | \nXML allows data validation.<\/td>\n | SGML does not allow data validation.<\/td>\n<\/tr>\n | \nIt describes the data and transfers data between applications.<\/td>\n | It allows you to define and create platform-independent files.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n 2. Comparing HTML and XML<\/strong><\/p>\n\n\n\nHTML<\/strong><\/td>\nXML<\/strong><\/td>\n<\/tr>\n\nHTML tags are predefined.<\/td>\n | XML tags are not predefined.<\/td>\n<\/tr>\n | \nHTML is case insensitive.<\/td>\n | XML is case sensitive.<\/td>\n<\/tr>\n | \nHTML is markup language that creates the form and appearance of the Web page.<\/td>\n | XML is neither a programming nor a presentation language.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n 3. Comparing EDI and XML<\/strong><\/p>\n\n\n\nEDI<\/strong><\/td>\nXML<\/strong><\/td>\n<\/tr>\n\nEDI (Electronic Data Interchange) is a collection of standards, formats and file layout.<\/td>\n | XML is an emerging standard designed to simplify Web-based E-Commerce transactions between computer application.<\/td>\n<\/tr>\n | \nEDI enables highly secure document exchanges.<\/td>\n | XML document typically needs to be encrypted to maintain security level.<\/td>\n<\/tr>\n | \nEDI documents are sent via private and relatively expensive Value Added Networks (VANs).<\/td>\n | XML documents are generally sent via the Internet.<\/td>\n<\/tr>\n | \nEDI does not processes low transaction values.<\/td>\n | XML processes relatively low transaction values.<\/td>\n<\/tr>\n | \nEDI allows companies to exchange electronic documents quickly between their trading partners.<\/td>\n | XML allows you to create custom tags to present your document in a structured format.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n Question 4.\u00a0<\/strong><\/span>Consider the following XML document. \nCheck this for well- formedness.<\/p>\n<Employees><FirstName> Ambrish\r\n<MiddleName> Kumar<\/FirstName>\r\n<\/MiddleName>\r\n<lastname> Garg <\/LastName>\r\n<\/Employees><\/pre>\nAnswer:<\/strong><\/span><\/p>\nThe above XML document is not well-formed. \nThe document suffers from two errors which are as follows:<\/p>\n \n- Improper nesting<\/strong> The MiddleName element is opened inside the FirstName element, yet MiddleName is not closed before the FirstName element is closed.<\/li>\n
- Mismatched cases of start and end tags<\/strong> The tag <lastname> is closed with <\/LastName>, which is incorrect. XML is case sensitive, thus the end tag of <lastname> should be <\/lastname>.<\/li>\n<\/ol>\n
Question 5.\u00a0<\/strong><\/span>Explain the structure of XML document. \nAnswer:\u00a0<\/strong><\/span>Structure of XML- File\/Document<\/strong> \nEvery XML document includes both physical and logical structure which are as follows:<\/p>\n1. Physical Structure<\/strong> \nIt contains the actual data used in a document. The basic storage unit called entity<\/strong>, each of which may refer to other entities. An entity has a name and content. It contains references to other entities. There is a special entity called document entity<\/strong> or root<\/strong>, that serves as a main storage unit. XML processor always start document processing from that unit. \nWe have three classifications of entities, these are as follows:<\/p>\n\n- Internal and External Entities<\/strong>
\nFor internal entity, there is no separate physical storage object and the content of the entity is given in the declaration. It contained inside the document. If the entity is not internal, then it is an external entity.<\/li>\n- General and Parameter Entities<\/strong>
\nGeneral entities are entities which are used within the document content. In this specification, general entities are sometimes referred to with the unqualified entity, when this leads to no ambiguity. Generally, entities are declared and used differently. Parameter entities are parsed and used only in the DTD part of the XML document.<\/li>\n- Parsed and Unparsed Entities<\/strong>
\nParsed entities contain text that is referred as replacement text intended to be processed by the parser and is considered as an integral part of the document. Unparsed entities are resources that can be of any type including text objects. This type of entity is never process by parser.<\/li>\n<\/ol>\n2. Logical Structure<\/strong> \nIt is a template that enables the elements to be included in a document and in the order in which they have to be included. \nThe logical structure includes the basic components of the XML document. It indicates how a document is built, irrespective of what a document contains. The first structural element is prolog which is the base for the logical structure. \nThe structure of the document of example code: \n<\/p>\nQuestion 6.\u00a0<\/strong><\/span>A well-formed document must have a root element. Explain with an example. \nAnswer:<\/strong><\/span> To create a well-formed XML document, it is necessary for it to have a root element. A root element is a unique element that contains all other elements in the XML document. \nThe XML document cannot contain more than one root element. \nThe following code is an example of a well-formed document:<\/p>\n<address>\r\n<city> Delhi <\/city>\r\n<state> Delhi <\/state>\r\n<country> India <\/country>\r\n<\/address>\r\nConsider the same code written in the following way: \r\n<city> Delhi <\/city>\r\n<state> Delhi <\/state>\r\n<country> India <\/country>\r\nThe preceding code is not a well-formed document, since it does not contain a root element.<\/pre>\nQuestion 7.\u00a0<\/strong><\/span>Explain the difference between a well-formed and a valid XML documents. CBSE 2011<\/strong> \nAnswer: \n<\/strong><\/span><\/p>\n1. Well-Formed XML Documents \n<\/strong>A \u201cWell-Formed\u201d XML document means that document has the correct XML syntax. \nThe XML document that follows XML grammar rules is called well-formed document. A document that includes sequence of markup characters that cannot be parsed or are invalid cannot be well-formed. The following points are to be kept in mind for a valid XML document:<\/p>\n\n | | | | | | | | |