An Introduction to the Extensible Markup Language

  • Published on

  • View

  • Download

Embed Size (px)


<ul><li><p>8/13/2019 An Introduction to the Extensible Markup Language</p><p> 1/8</p><p>An Introduction to the Extensible</p><p>Markup Language (XML)</p><p>by Martin Bryan ofThe SGML Centre</p><p> The SGML Centre, 1997</p><p>This file gives a very brief overview of the most commonly use com!onents of the</p><p>"orl "ie "eb Consortium#s $"%C&amp; '(tensible Mar)u! Language $*ML&amp;, ass!ecifie in the "%C +ecommenation a!!rove on 1th -ebruary 199./</p><p>What is XML?</p><p>*ML is subset of the Stanar Generali0e Mar)u! Language $SGML&amp; efine in S2</p><p>stanar ..79319.4 that is esigne to ma)e it easy to interchange structure ocumentsover the nternet/ *ML files always clearly mar) where the start an en of each of the</p><p>logical !arts $calle elements&amp; of an interchange ocument occurs/ *ML restricts the use</p><p>of SGML constructs to ensure that fall bac) o!tions are available when access to certaincom!onents of the ocument is not currently !ossible over the nternet/ t also efines</p><p>how nternet 5niform +esource Locators can be use to ientify com!onent !arts of</p><p>*ML ata streams/</p><p>6y efining the role of each element of te(t in a formal moel, )nown as aDocumentType Definition$T&amp;, users of *ML can chec) that each com!onent of ocument</p><p>occurs in a vali !lace within the interchange ata stream/ 8n *ML T allows</p><p>com!uters to chec), for e(am!le, that users o not accientally enter a thirlevelheaing without first having entere a seconlevel heaing, something that cannot be</p><p>chec)e using the :y!erTe(t Mar)u! Language $:TML&amp; !reviously use to coe</p><p>ocuments that form !art of the "orl "ie "eb $"""&amp; of ocuments accessiblethrough the nternet/</p><p>:owever, unli)e SGML, *ML oes not re;uire the !resence of a T/ f no T is</p><p>available, either because all or !art of it is not accessible over the nternet or because the</p><p>user faile to create it, an *ML system can assign a efault efinition for uneclarecom!onents of the mar)u!/</p><p>*ML allows users to3</p><p> bring multi!le files together to form com!oun ocuments</p><p> ientify where illustrations are to be incor!orate into te(t files, an the format</p><p>use to encoe each illustration</p><p> !rovie !rocessing control information to su!!orting !rograms, such as ocument</p><p>valiators an browsers</p><p> a eitorial comments to a file/</p></li><li><p>8/13/2019 An Introduction to the Extensible Markup Language</p><p> 2/8</p><p>t is im!ortant to note, however, that *ML is not3</p><p> a !reefine set of tags, of the ty!e efine for :TML, that can be use to</p><p>mar)u! ocuments</p><p> a stanari0e tem!late for !roucing !articular ty!es of ocuments/</p><p>*ML was not esigne to be a stanari0e way of coing te(t3 in fact it is im!ossible to</p><p>evise a single coing scheme that woul be suit all languages an all a!!lications/</p><p>nstea *ML is formal language that can be use to !ass information about the</p><p>com!onent !arts of a ocument to another com!uter system/ *ML is fle(ible enough tobe able to escribe any logical te(t structure, whether it be a form, memo, letter, re!ort,</p><p>boo), encyclo!eia, ictionary or atabase/</p><p>The components o XML</p><p>*ML is base on the conce!t of documentscom!ose of a series of entities/ $</p></li><li><p>8/13/2019 An Introduction to the Extensible Markup Language</p><p> 3/8</p><p>6ecause *ML tag sets are base on the logical structure of the ocument they are</p><p>somewhat easier to unerstan, an remember, than !hysically base mar)u! schemes of</p><p>the ty!e ty!ically !rovie by wor !rocessors/ 8n *ML memo might be coe as3</p><p>All staff</p><p>Martin Bryan5th November</p><p>ats and !o"s</p><p>$lease remember to %ee all cats and do"s indoors toni"ht.</p><p>This form the file is ieal for a com!uter to follow, an therefore to !rocess/ The start an</p><p>en of each logical element of the file has been clearly ientifie by entry of a starttag</p><p>$e/g/ &amp; an an entag $e/g/ &amp;/</p><p>?otice that at this !oint nothing has been sai about the format of the final ocument/-rom the neutral format !rovie by *ML users can either chose to is!lay the memo on</p><p>a screen, whose si0e can be varie to suit user !references, to !rint the te(t onto a !re</p><p>!rinte form, or to generate a com!letely new form, !ositioning each element of theocument where neee/</p><p>#eining $our o"n tag sets</p><p>To efine tag sets users must create a ocument Ty!e efinition that formally ientifies</p><p>the relationshi!s between the various elements that form their ocuments/ -or a sim!lememo the *ML T might ta)e the form3</p></li><li><p>8/13/2019 An Introduction to the Extensible Markup Language</p><p> 4/8</p><p>"here the !osition of an element in the moel is variable the element can be efine as</p><p>!art of a re!eatable choice of elements/ -or e(am!le, to allow references to boo)s or</p><p>figures to occur anywhere in the te(t of a !aragra!h, but not in the heaing, the moelefinition for the element coul be moifie to rea3</p><p>This tells the com!uter that the starttag can be amene to rea or if a variant font is re;uire/ f no such</p><p>change is re;ueste the !rogram is to use the efault value to ma)e the tag rea /</p><p>2ne es!ecially im!ortant ty!e of attribute is the uni;ue ientifier/ 6ecause it is uni;ue it</p><p>can be use to !rovie a cross reference between two !oints in the ocument/ -or</p><p>e(am!le, you can ensure that a uni;ue ientifier is assigne to each figure by aing anattribute list eclaration of the following form to the T3</p></li><li><p>8/13/2019 An Introduction to the Extensible Markup Language</p><p> 5/8</p><p>This tells the com!uter that every /</p><p>5ni;ue ientifiers can be referre to within the te(t by use of attributes that formientifier references/ Ty!ically a figure reference element might have its attribute</p><p>eclaration list efine as3</p><p>2nce such a eclaration has been mae in the T users can use an entity referenceof</p><p>the form &amp;comany;in !lace of the full name of the com!any/ 8n avantage of using this</p><p>techni;ue is that, shoul the name of the com!any referre to by the mnemonic changelater, only the entry in the T nees to be change as the entity reference will</p><p>automatically call in the current efinition/</p><p>Te(t store in another file it can also be incor!orate into a file using entity references/ nthis case the entity eclaration in the T ientifies the location of the file containing the</p><p>te(t to be reference, e/g/3</p></li><li><p>8/13/2019 An Introduction to the Extensible Markup Language</p><p> 6/8</p><p>"hen the string is encountere in the te(t the com!uter will re!lace it by the</p><p>coe whose ecimal value is @%%/</p><p>8lternatively the ecimal character number, or its he(aecimal e;uivalent, !recee by #,</p><p>can be use irectly as !art of a character reference, e/g/ &amp;3#+E;to generate =/</p><p>Illustrations&amp; tables and other special elements</p><p>*ML !rovies a number of techni;ues for hanling nonstanar ocument elements/</p><p>"here the coing scheme of an element of the file such as an illustration iffers from thatuse for normal te(t the contents of the element can be treate as an entity with a s!ecial</p><p>notation, e/g/3</p></li><li><p>8/13/2019 An Introduction to the Extensible Markup Language</p><p> 7/8</p><p>8n *ML file normally consists of three ty!es of mar)u!, the first two of which are</p><p>o!tional3</p><p>1/ 8nXML processing instructionientifying the version of *ML being use, theway in which it is encoe, an whether it references other files or not, e,g,</p><p>ect Moel $2M&amp;, which</p><p>!rovies a C2+68 L interface between a!!lications e(changing *ML ata/</p><p>ata store using non*ML notations will nee a!!ro!riate a!!lication software to!rocess it, but the *MLcoe file will correctly ientify where each !iece of such ata</p><p>belongs in the com!lete ocument an where it has been store !rior to use/</p><p>6y storing ata in the clearly efine format !rovie by *ML you can ensure that your</p><p>ata will be transferable to a wie range of harware an software environments/ ?ewtechni;ues in !rogramming an !rocessing ata will not affect the logical structure of</p><p>your ocument#s message/ f more etail nees to be ae to the file all you nee to o is</p><p>to u!ate the moel an then a new mar)u! tags where re;uire in the ocument</p><p>instance/ f a com!letely new style is re;uire then the e(isting ocument moel can belin)e to the new one to !rovie automatic u!ating of ocument structures/</p><p>"ebmaster3 mtbryanAsgml/unet/com</p><p>Lesson 1: Authoring XML Elements</p></li><li><p>8/13/2019 An Introduction to the Extensible Markup Language</p><p> 8/8</p><p>What is an XML element?</p><p>XML is a meta-markup language, a set of rules for creating semantic tags used to describe data. An XMLelement is made up of a start tag, an end tag, and data in between. The start and end tags describe thedata within the tags, which is considered the value of the element. For eample, the following XMLelement is a !director" element with the value #Matthew $unn.#</p><p>Matthew Dunn</p><p>The element name #director# allows %ou to mark up the value #Matthew $unn# semanticall%, so %ou candifferentiate that particular bit of data from another, similar bit of data. For eample, there might beanother element with the value #Matthew $unn.#</p><p>Matthew Dunn</p><p>&amp;ecause each element has a different tag name, %ou can easil% tell that one element refers to Matthew$unn, the director, while the other refers to Matthew $unn, the actor.'f there were no wa% to mark upthe data semanticall%, having two elements with the same value might cause confusion.</p><p>'n addition, XML tags are case-sensitive, so the following are each a different element.</p><p>Attributes</p><p>An element can optionall% contain one or more attributes. An attribute is a name-value pair separated b%an e(ual sign )*+.</p><p>Westfield</p><p>'n this eample, ZIP="0108"is an attribute of the !'T" element. Attributes are used to attachadditional, secondar% information to an element, usuall% meta information. Attributes can also acceptdefault values, while elements cannot. ach attribute of an element can be specified onl% once, but in an%</p><p>order.</p><p>!r it#</p><p>'n the following tet bo, t%pe the title of a favorite movie and then click $ontinue.</p><p>$he%&amp; the snta'</p><p>&amp;ecause XML is a highl% structured language, it is important that all XML be well-formed. That is, the XMLmust have both a start tag and end tag, and must be authored using the proper s%nta. 'n the following</p><p>bo, create an XML element with a start tag, an end tag, and a value on a single line. lick the Well()orme*?button to see if %our XML is correct.</p></li></ul>


View more >