TopicsNext topics |
Step Two: Creating a Root ElementThe goal of this step is to create a root element, which contains all other elements that you create. It is the most important element, as it contains the rest of the document and becomes synonymous with your document type. It cannot be repeated. Markup documents, whether HTML, XML or SGML, employ a root element, which contains all other elements. The root element usually describes the focus or function of the document. The HTML element in HTML is a good root element because it reveals the name of the markup language. The TRIVIA element, in the example, is another effective root element because it describes the function of the document. All XML elements, root elements included, obey a certain syntax. They include their name or type inside angle brackets. You will probably have noticed their frequent occurrence in HTML, SGML or XML documents that you may have seen. For example, the paragraph element in HTML is written as <P>. There are other rules for elements and for attributes, which they contain, but most elements take the form: <NAME>CONTENT</NAME>. XML is case sensitive, so an element might appear as: <DocumentTitle>XML Tutorial</DocumentTitle>. As you can see, the case of the start- and end-tags, which contain the element, must agree. Your Well-Formed XML InstanceYou are now at the stage in the creation of your document in which you must decide on its content and the elements you are doing to use to describe it. Pick an element that describes the document that you are about to create. Use this element as your root element, as it will contain all other elements within it, and describe your document. For example, NOVEL, SONG and LOG would likely make good root elements because they imply the function of the entire document. This document contains help about XML document creation and uses <HELP> as an aptly picked root element. <?xml version="1.0" standalone="yes"?> <HELP> </HELP> Example Document InstanceThis document is a good example of appropriate content description using XML. It begins with an XML declaration and employs a good root element. It also describes the structure of the entire document well, making sure to represent the distinctions between different types of content. <?xml version="1.0" standalone="yes"?> <TRIVIA> <MATH> <QUESTION>What is the square root of 25</QUESTION> <ANSWER>5</ANSWER> </MATH> <GENERAL> <QUESTION>What is the season after Summer </QUESTION> <ANSWER>Fall</ANSWER> <ANSWER>Autumn </ANSWER> </GENERAL> </TRIVIA> <Beginning of Document> <Table of Contents> <Previous> <Next> |