html5-img
1 / 17

XML

eXtensible Markup Language (XML). 1. XML. O pen C omputing I nstitute, Inc. What is XML? • eXtensible Markup Language • Subset of SGML (Standardized General Markup Language) – marks up content, not formatting, just like SGML – omits complex features • Formatting is done with

yagil
Download Presentation

XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. eXtensibleMarkupLanguage (XML) 1 XML OpenComputingInstitute,Inc.

  2. WhatisXML? •eXtensibleMarkupLanguage •SubsetofSGML(StandardizedGeneralMarkupLanguage) –marksupcontent,notformatting,justlikeSGML –omitscomplexfeatures •Formattingisdonewith –CascadingStyleSheets(CSS) –eXtensibleStyleLanguage(XSL) •RelationshiptoHTML –canexpresstherulesforHTMLinan XMLDocumentTypeDefinition(DTD) –HTMLdocumentscanbeXMLdocuments •haveasinglerootelement(<html>) •closealltags •encloseattributevaluesinquotes 2 XML OpenComputingInstitute,Inc.

  3. SomeBenefitsofUsingXML •XMLdocumentsareself-describing –notjustacollectionofdatavalues •CanusestandardXMLtools(&someSGMLtools) tocreate,modify,processandview –XMLeditors –SAXandDOMprogramminginterfaces –XML-awarebrowsers •CanuseaDTDtoconstrainstructureandallowedvalues •CanuseXSLtoreadexistingXMLdocuments andcreatenewoneswithadifferentstructure –whenneedschange –whenotherapplicationsexpectthedatatobestructureddifferently •Errorsindatadon’tpreventuseofotherdocumentdata aslongasitisstillwell-formed 3 XML OpenComputingInstitute,Inc.

  4. SomeDesignGoalsForXML •CompatiblewithSGML –takeadvantageofexistingexpertiseandsomeexistingtools •Optionalelementskepttoaminimum –comparisonofspec.sizes:SGML~500pages,XML~30pages •Human-readable,likeHTML •Easytocreatedocuments •Tersenessofmarkupisoflittleimportance –elementandattributenamestakeupalotofspace butcompresseswell(~90%) •Supportavarietyofapplications,notjustwebbrowsers •EasytowriteapplicationsthatprocessXMLdocuments –canuseSAXandDOMinterfaces 4 XML OpenComputingInstitute,Inc.

  5. CustomMarkupLanguages •XMLisusedtocreatemarkuplanguages forspecificapplications •Examples –ChemicalMarkupLanguage(CML) •fordisplayingmoleculedescriptionsandtreesandmodeldiagrams – – – – – FDX-forfootwearindustrydata FpMLandFinXML-forsecuritiestradingdata HL7-forhealthcaredata MathML-formathematicalequations OpenFinancialeXchange(OFX) •forpersonalfinancialdatalikethatstoredinQuickenorMoney •alsosupportsconsumerandsmallbusinessbankingandbillpayment –OpenSoftwareDistribution(OSD) •forsoftwaredistributionandupdates 5 XML OpenComputingInstitute,Inc.

  6. CategorizingThePieces • • • • • Basics: Validating: Links: Formatting: Programming: XML DTDandXMLSchema XLinkandXPointer CSSandXSL SAXandDOM 6 XML OpenComputingInstitute,Inc.

  7. XMLElements(ortags) •Mustbesurroundedby<and>characters •Mustbeterminatedinoneoftwoways <city/> <city>contentgoeshere</city> •Canincludeattributes <cityname="St.Louis"state="Missouri"/> •Cancontainchildelements <city> <name>St.Louis</name> <state>Missouri</state> </city> •Childelementsmustbeproperlynested –proper: –improper: <a><b></b></a> <a><b></a></b> 7 XML OpenComputingInstitute,Inc.

  8. ExampleXMLDocument <?xmlversion="1.0"?>XMLdeclaration <!DOCTYPEmusicCollectionSYSTEM"musicCollection.dtd"> rootelement <musicCollection> prolog section documenttype declaration <owner>MarkVolkmann</owner> <artisttype="group"> <name>Cranberries</name> <cdcategory="pop"> <title>EverybodyElseIsDoingIt,SoWhyCan'tWe?</title> <track> <name>IStillDo</name> <time>3:16</time> </track> <track> <name>Dreams</name> <time>4:32</time> </track> </cd> </artist> anXMLcomment <!--placemoreartistshere--> </musicCollection> 8 XML OpenComputingInstitute,Inc.

  9. Well-formed&ValidXMLDocuments •Well-formeddocuments –allelementsareterminated –oneelement,therootelement,containsalltheothers –elementsdonotoverlap •childelementsmustbeclosedbeforetheirparentisclosed –attributevaluesareenclosedinquotes –<isonlyusedtostartelements –alsoafewrulesaboutentities •entitiesareshorthandnamesforreplacementtext •entitiescanalsorefertonon-XMLdata •Validdocuments –well-formed –conformtoaDTD 9 XML OpenComputingInstitute,Inc.

  10. DocumentTypeDefinitions(DTD) •ADTDdefines – – – – – allowedelementsandtheirattributes validelementnestingrelationships sequenceinwhichelementsmustappearwithintheirparentelement numberoftimeselementscanoccurwithintheirparentelement andmore •Onlyneededfor“valid”documents, notformerely“well-formed”documents •DTDsformanyapplicationdomainsalreadyexist •FourDTDtypes –ELEMENT,ATTLIST,ENTITYandNOTATION identifiestheapplicationtobeused forprocessingdatainagivenformat 10 XML OpenComputingInstitute,Inc.

  11. ElementDefinitions •Fourtypesofelementdefinitions ParsedCharacterData –nocontent-EMPTY –onlytextcontent,nochildelements-(#PCDATA) –onlychildelements,notextcontent-requiresacontentmodel –anycontent-ANY •Elementcontentmodels –typicallyasequenceofchildelementsseparatedbycommas –specialcharactersindicatethenumberofoccurrencesallowed •?means0or1,*means0ormore,+means1ormore,defaultis1 –example:(a*,b+,c?,(d|e)) •specifies0ormoreaelements,followedbyoneormorebelements, followedby0or1celements,followedbyonedoreelement 11 XML OpenComputingInstitute,Inc.

  12. Attributes •Tentypesofattributedefinitions –enumerated-listofallowedvalues;example:(red|green|blue) –CDATA-anycharacters –NMTOKEN-onlycharactersallowedin“nametokens” •letters,digits,underscore,hyphen,periodandcolon;beginwithaletter NMTOKENS-awhitespace-separatedlistofNMTOKENvalues ID-uniqueidentifierfortheelementwithintheXMLdocument IDREF-referstoanotherelementwithinthesameXMLdocument IDREFS-awhitespace-separatedlistofIDREFvalues ENTITY-referstoanunparsedexternalentitysuchasanimagefile ENTITIES-awhitespace-separatedlistofENTITYvalues NOTATION-identifiesthedataformatofanunparsedexternalentity – – – – – – – •Attributescanberequired(#REQUIRED), optional(#IMPLIED)orhavedefaultvalues 12 XML OpenComputingInstitute,Inc.

  13. ExampleDTD <!ELEMENT <!ELEMENT <!ELEMENT <!ELEMENT <!ELEMENT <!ELEMENT <!ELEMENT <!ELEMENT musicCollection(owner,artist*)> artist(name,cd*)> cd(title,track*)> track(name,time?)> name(#PCDATA)> owner(#PCDATA)> time(#PCDATA)> title(#PCDATA)> <!ATTLISTartisttype(group|solo)#REQUIRED> <!ATTLISTcd category(classical|country|jazz|pop|rock|other)#REQUIRED import(true|false)"false" yearCDATA#IMPLIED > <!ATTLISTtracksampleFileENTITY#IMPLIED> 13 XML OpenComputingInstitute,Inc.

  14. XMLSchema •W3CproposedschemalanguagealternativetoDTDs –asupersetoftheDTDcapabilities –combinesthebestfeaturesofothersimilarproposals •XML-Data,XDR,DCD,SOX,DDML –usesXMLsyntaxinsteadofauniquesyntaxlikeDTDs •canedit,validate,andtransformusingstandardXMLtools •CreatedbytheW3CXMLSchemaWorkingGroup –seeXMLSchemaPart1:StructuresW3CWorkingDraft6-May-1999 andXMLSchemaPart2:DatatypesW3CWorkingDraft6-May-1999 14 XML OpenComputingInstitute,Inc.

  15. XMLSchema(Cont’d) •SomeXMLSchemaimprovementsoverDTDs –built-indatatypes •string,boolean,number,dateTime,binary(ex.imagedata),uri •integer,decimal,real,date,time,timePeriod –user-generateddatatypes(built-indatatypeswith“constrainingfacets”) •stringsupportslength(forfixed-length),maxlength(forvariable-length), andCOBOL-likepicturesorPerl-likeregularexpressionstoconstrainformat •numbersupports minInclusive,minExclusive,maxInclusiveandmaxExclusive –integer,decimalandrealareallnumbers –limitsonnumberofoccurrencesofchildelements •minOccurcanbesettoanumber(0ormore) •maxOccurcanbesettoanumber(1ormore)or"*"forunlimited 15 XML OpenComputingInstitute,Inc.

  16. XLink •ProvidesgreaterlinkingcapabilitiesthanHTML •Anyelementcanserveasalink –nospecialelement,justspecialattributes •Features –simplelinks •unidirectionallinktoasingleresource(likeHTMLlinks) –extendedlinks •bi-directionallinktooneormoreresources •canbedefinedinaseparatefiletoallowmultiplefilestosharethelink –activatewith“user”(userclick)or“auto”(whenpageisloaded) –showwith“replace”(replacecurrentpage), “new”(displayinanewwindow)or “embed”(embedintocurrentpage) –custombehaviorswhenlinkisactivated(ex.soundsandtransitioneffects) 16 XML OpenComputingInstitute,Inc.

  17. eXtensibleMarkupLanguage (XML) -- END -- 1 XML OpenComputingInstitute,Inc.

More Related