Sunteți pe pagina 1din 3

IntroductionandOverview

Tutorial01

Tutorial 1: Introduction and Overview

Introduction to XML

1. WhatisXML?WheredidXMLcomefrom?WhatbusinessproblemsthatXMLwasdesignedto
solve?XMLfollowedHTML,whichinturnfollowedSGML.Allthreearemarkuplanguages,which
havebothsyntaxandgrammar.Coverpages,anOASISgroup,hasanexcellentwebsitearound
markuplanguages.
2. XMLisusedinRSS,RDFandSemanticWebtechnology,XMLsitemaps,andWebservices.Infact,
XHTMLisbasedonXML.
3. XMLisametalanguage,whichallowsyoutowriteyourowncustommarkuplanguages,which
youcandescribeinaDTDorXMLschema.
4. XMLishumanreadableand'created'butalmostalwayswritten,andread,byamachine.Web
services,SOAPandecommercearemachinetomachineapplicationsofXML.
5. XML is application agnostic, vendor neutral, and can be read by any 'XML aware application',
whichtypicallywillemployanXMLparser.

Dissection of an XML Example, message.xml

XML is a way for you to define structured information of all kindscontent, object data, inter
applicationmessages,orsyndicatedcontentsummariesandrepresentsdataapartfromvisualmarkup.
Itseparatesdatafromcontent.

A site could be easily constructed by combining an XML document that holds the content data (your
pagetext,perhapspointerstospecificimagefilesandtheirdimensions,sitenavigation,headers/footers,
andsoon)andanXSL(eXtensibleStylesheetLanguage)documentinconjunctionwithaCSSstylesheet
thatdefineshowthepageisvisuallyconstructed.

Whyisthisimportant?Byseparatingyourcontentfromyourdata,youhavetheabilitytoworkoneach
withoutaffectingtheother.Forexample,contentteamscouldbeupdatingtheXMLcontentandimage
pointersintheXMLfileatthesametimethatvisualdesignersaretweakingtheCSSstylesheet(visual
layout) and an integration engineer is finetuning the XSL document that pulls it all together. No
collisions by three parties trying to check out or open the same HTML file at the same time.
Developmentharmonyachieved.

TheactualstructureofanXMLdocumentisstraightforward.ThefollowingXMLdocumentisthedata
representationofamessagefromJanetoJohn:

CT05933XML&WebServices

Page1of3

IntroductionandOverview

Tutorial01

<?xmlversion="1.0"encoding="UTF8"?>
<message>
<from>JaneDoe</from>
<to>JohnDoe</to>
<date>February14,2006</date>
<body>Aretheannualreportfilesfinishedyet?</body>
<priority>high</priority>
<attachments>
<attachmenttype="jpg">file_1.jpg</attachment>
<attachmenttype="pdf">file_2.pdf</attachment>
</attachments>
</message>

Note,first,thatthis(andeachwellformed)XMLdocumentstartswithanXMLdeclarationthatdefines
both the XML version and character encoding used within the document itself. The root node of this
particulardocumentismessagewhollyappropriategivenitscontentandthatmessagecancontain
severalproperties:
from:Thesenderofthemessage
to:Therecipientofthemessage
date:Whenthemessagewassent
body:Themaincontentofthemessage
priority:High,medium,orlow
attachments: A container tag that can encapsulate a number of attachment tags pointing to
specificfiles
attachment:Atagthatdefineseachuniquefileassociatedwiththemessage

Syntaxwise,XMLisbothverystrictinitsinterpretation,whilereasonablyeasytolearnanduse.Here
areafewguidingprinciples:
XMLtagsarecasesensitive
XMLelementsmustbenestedappropriately,andhaveaclosingtag
AllXMLdocumentsmusthaveasinglerootelement
AttributesinXMLdocumentsmustbequoted
XMLcommentsfollowthesamesyntaxasHTMLcomments(<!comment>)

In a nutshell, an XML file is simply a text file that wraps data into logical constructs. How those
constructsareparsedisanothermatter.

Dissection of simple.xml

Thesimple.xmlfilecontainsinformationaboutaperson,theircontactinformation,whattheydo,their
education,andanyothergeneralcomments.Thereisonlyonerootnodeandinthiscaseitisnamed
simple. Nested within it are the nodes, contact, general, and comments. Each of these nodes have
nestednodescontainedwithinthemaswell.NoticethatthefirstlineistheXMLdeclaration.Itdefines
the XML version (1.0) and the encoding UTF8 (8bit UCS/Unicode Transformation Format, a variable
lengthcharacterencodingforUnicode).Thefollowingisanexampleofsimple.xmlwithdata.

CT05933XML&WebServices

Page2of3

IntroductionandOverview

Tutorial01

<?xmlversion="1.0"encoding="UTF8"standalone="yes"?>
<simple>
<contact>
<first_name>Jane</first_name>
<last_name>Doe</last_name>
<nick_name></nick_name>
<email_address>janedoe@gmail.com</email_address>
</contact>
<general>
<occupation>WebDesigner</occupation>
<education>BAFineArts</education>
<goals>StartWebDesignCompany</goals>
</general>
<comments>
<comment>MusttakeDreamweaver</comment>
</comments>
</simple>

XML will not be displayed like HTML pages in the browser. The XML document will be displayed with
colorcoded root and child elements. A plus (+) or minus sign () to the left of the elements can be
clickedtoexpandorcollapsetheelementstructure.ToviewtherawXMLsource(withoutthe+and
signs),select"ViewPageSource"or"ViewSource"fromthebrowsermenu.

Note:InChrome,Opera,andSafari,onlytheelementtextwillbedisplayed.ToviewtherawXML,you
mustrightclickthepageandselect"ViewSource".

Tutorials and Primers

1.
2.
3.
4.

W3SchoolsPrimeronXMLhttp://www.w3schools.com/web/web_xml.asp
W3XMLTutorialonXMLhttp://www.w3schools.com/xml/default.asp
TellMeNetworksprimeronXML:https://studio.tellme.com/general/xmlprimer.html
XMLFAQ:http://xml.silmaril.ie/basics/whatfor/

Links to XML Related Sites

1. XML.COM
http://www.xml.com/
2. WDVLXMLtutorial
http://wdvl.com/Authoring/Languages/XML/
3. SunJavaXMLIntroduction
http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/overview/1_xml.html
4. IBM'SXMLWebsite
http://www.ibm.com/developerworks/xml/
5. GoogleDirectoryonXML
http://directory.google.com/Top/Computers/Data_Formats/Markup_Languages/XML/Resource
s/FAQs,_Help,_and_Tutorials/

CT05933XML&WebServices

Page3of3

S-ar putea să vă placă și