MMooddululee 22

XXMMLL BBaassiiccss ((XMLXML,, NamNamesesppacaceses,, UUssagagee ssccenenarariiooss,, DDTTDDss))

1 HHiissttoorryy:: SGSGMMLL vvss.. HHTTMMLL vvss.. XXMMLL

SGML (1960)

XML(1996)

HTML(1990) XHTML(2000)

http://www.w3.org/TR/2006/REC-xml-20060816/

2 WWhyhy XXMMLL ??

 HHTTMMLL iiss ttoo bbee iinntteerrpprreetetedd bbyy bbrroowwsseerrss  SShhoowwnn oonn tthhee ssccrreeeenn ttoo aa hhuummaann  DDeessiirree toto sseeppaarraattee thethe ““ccoonntteennt”t” ffrroomm ““pprreesseennttaattiioonn””  PPrreesseentntaattiioonn hhaass ttoo pplleeaassee tthhee hhuummaann eeyyee  CCoonntetentnt ccaann bbee iinntteerrpprreetteedd bbyy mmaacchhiinneess,, ffoorr mmaacchhiinneess ppreresseennttaatitioonn iiss aa hahandndiiccaapp  SSeemmaanntiticc mmaarrkkuupp ooff tthhee ddaattaa

3 IInnffoorrmmaattiioonn aabboouutt aa bbooookk iinn HHTTMMLL

>PPooliticcs of eexxppererieence bby RRonalldd Laaiing, publlished iin 11996677>> IIttemm numbeerr::3220000703388110766<><"><<><><>>"><><><O"><%">

4 TThhee ssaammee iinnffoorrmmaattiioonn iinn XXMMLL <> <>PPoolliittiiccss ooff eexxppeerriieennccee<> <> <>RRoonnaalldd<> <>LLaaiinngg<> <> <> Elements

• Information is (1) decoupled from presentation, then (2) chopped into smaller pieces, and then (3) marked with semantic meaning • It can be processed by machines •Like HTML, only syntax, not logical abstract data model 5 XXMMLL kekeyy ccononcceeppttss

 DDooccuummeenntsts  EElleemmeennttss  AAttrttriibbuutetess  NNaammeessppaaccee ddeeccllaarraatitioonnss  TTeexxtt  CoCommmmeennttss  PPrroocceessssiinngg IInnsstrtruuccttiioonnss  AAllll iinnhheerriitteedd ffrroomm SSGGMMLL,, ththeenn HHTTMMLL 6 TThehe kekeyy ccooncnceeppttss ooff XXMMLL <> <>PPoolliittiiccss ooff eexxppeerriieennccee<> <> <>RRoonnaalldd<> <>LLaaiinngg<> <> • Documents Elements <> • Elements • Attributes • Text

• Nested structure • Conceptual tree • Order is important • Only “characters”, not integers7, etc ElEleemmeentntss

 EEnncclloosseedd iinn TTaaggss  BBeeggiinn TTaagg:: ee..gg..,, <>  EEnndd TTaagg:: ee..gg..,, <>  EElleemmeenntt wwiitthhoouutt ccoonntteenntt:: ee..gg..,, <> iiss aa sshhoorrtthhaanndd ffoorr <> >

 EElleemmeenntsts ccaann bbee nneesstteedd <> <> WWiillddee WuWuttzz <> <>  SSuubbeelleemmeennttss ccaann iimmpplleememenntt mmuullttiisseettss <> <> ...... > <> ...... <> <>  OOrrdederr iiss iimmppoorrttaanntt !!  DDooccuummeennttss mmuusstt bbee wweellll--ffoorrmmeedd <> <> <> <> iiss ffoorrbbiidddedenn!! <> <> <> iiss ffoorrbbiidddedenn!! 8 AtAtttrriibbututeess  AAttttrriibbuuttee aarree aassssoocciiaatetedd ttoo EElleemmeennttss <> <> ...... <> <> ...... <> <>  EElleemmeennttss ccaann hhaavvee oonnllyy aattttrriibbuutteess <>  AAttttrriibbuuttee nnaammeess mmuusstt bbee uunniiqquuee!! ((NoNo MMuulltitisseettss)) </> iiss iilllleeggaall!!  WWhhaatt iiss ththee ddiiffffeerreennccee bbeettwweeeenn aa nneesstteedd eelleemmeenntt aanndd aann aattttriribbuuttee?? AArere aatttrtriibbuutteess uusseeffuull??  MMooddeelliinngg ddeecciissiioonn:: sshhoouulldd „„nnaammee““ bbee aann aatttrtriibbuutete oorr aa ssuubbeelleemmeenntt ooff aa ppeerrssoonn ?? WWhhaatt aabboouutt „„aaggee““ ??

9 TTeexxtt aanndd MMiixxeedd CCoontnteenntt  TTeexxtt aappppeeaarrss iinn eelleemmeenntt ccoonntteentnt  <>TThhee ppoolliititiccss ofof eexxppeerriieennccee<>  CCaann bbee mmiixxeedd wwiitthh ootthheerr ssuubbeelleemmeennttss  <>TThhee ppoolliititiccss ofof <>eexxppeerriieennccee<><>  MMiixxeedd CCoonntetentnt  FFoorr „„ddococuummeennts“ts“ dadattaa ---- vveerryy uusseeffuull  TThhee nneeeedd ddooeess nnoott aarriissee iinn „„ddaattaa““ pprroocceessssiinngg,, oonnllyy eennttiititieess aanndd rreellaattiioonnsshhiippss  PPeeooppllee ssppeeaakk iinn sseenntetenncceess,, nnoott eennttiittiieess aanndd rreellaattiioonnsshhiippss.. XXMMLL aalllloowwss ttoo pprreesseerrvvee tthhee ssttrruuccttuurree ooff nnaattuurraall llaanngguuaaggee,, wwhhiillee aaddddiinngg sesemmaannttiicc mmaarrkkuupp tthhaatt ccaann bbee iinnteterrpprreetteedd bbyy mmaacchhiinneess..

10 CCononttiinnuuoousus ssppeeccttrruumm bbeettwweeeenn nnaattuurraall llaannguguaaggee,, sseemmii--ssttrruuccttuurreedd dadattaa,, aanndd ssttrruuccttuurreedd ddaattaa 1. DDaannaa ssaaiidd thathatt thethe bbooookk eennttiittlleedd „„TThehe ppoolliittiiccss ooff eexxppeerriieennccee““ iiss rreeaallllyy eexxcceelllleenntt !! 2. <> TThhee bbooookk eentntiittlleedd „„TThehe ppoolliititiccss ooff eexxppeerriieennccee““ iiss rereaallllyy eexxcceelllleenntt !! <> 3. <> TThhee bbooookk eentntiittlleedd <> TThhee ppoolliittiiccss ooff eexxppeeririeennccee<> iiss rreeaallllyy eexxcceelllleentnt !! <> 4. <> <>DDaannaa<> <>TThhee ppoolliititiccss ooff eexxppeerriieennccee<> <> eexxcceelllleenntt<> 11 <> CCDDATATAA sseeccttiioonnss

 SSoommeetitimemess wwee wwoouulldd lliikkee ttoo ppreresseerverve tthhee oorriiggiinnaall cchaharraacctteerrss,, aanndd nonott iinnteterrpprreett tthehemm aass mmaarrkkuupp  CCDDAATTAA sseeccttiioonnss  NNoott ppaarrsseedd aass XXMMLL  Hello,world! Hello, world!]]>

12 CCoommmmeentntss,, PPIIss,, PPrroollogog  CCoommmmeenntt:: SSyynnttaaxx aass iinn HHTTMMLL <>  PPrroocceessssiinngg IInnssttrruucctitioonnss  CCononttaaiinn nnoo ddaatata -- iinnteterrpprreettaattiionon bbyy pprroocceessssoorr  SSyynntataxx:: <>  PPaauussee iiss „„TTaarrggeett““;; 1100sseeccss iiss „„CCoonntteenntt““  XXMMLL iiss aa rreesseerrvveedd ttaarrggeett ffoorr pprroolloogg  PPrroolloogg <>  SSttaannddaalloonnee ddeeffiinneess wwhehetthheerr tthheerree iiss aa DDTTDD  EEnnccooddiingng iiss uussuuaallllyy UUniniccooddee..

13 WWhhiitteesspapacceess ddeeccllaarraattiioonn  WWhhiitteessppaaccee == CCoonnttiinunuoouuss sseeqquueennccee ooff SSppaaccee,, TTaabb aanndd ReRettuurrnn cchaharraaccteterr  SSppeecciiaall AAttttrriibbuuttee xxmmll::ssppaaccee ttoo ccoontntroroll uussee  HHuummaan-n-rereaaddiibbllee XXMMLL ((wwiitthh WWhhiitetessppaaccee)) <> <>TThhee ppoolliittiiccss ooff eexxppeerriieennccee> <>RRononaalldd llaaiinngg<> <>  ((EEffffiicciieentnt)) mmaacchhiinnee--rreeaaddiibbllee XXMMLL ((nnoo WWSS)) <><>TThhee ppoolliittiiccss ooff eexxppeerriieennccee><>RRononaalldd LLaaiinngg<>>  PPeerfrfoormrmaannccee iimmpprroovveemmeenntt:: ccaa.. FFaaccttoorr 22..

14 LLaangnguuaaggee ddeeccllaarraattiioonn

The quick brown fox jumps over the lazy dog.

Whatt ccoolloouurr is it?

Whatt ccoolloorr is it?

15 UniUnivveerrssaall RReessouourrccee IIdedennttiiffiieerrss

 UURRLLss,, UURRIIs,s, IIRRIIssoonn tthhee WWeebb  UURRLL ((UUnniivveerrsasall RReessoouurrccee LLooccaatotorrss)):: ddeeffeerreenncceeaabbllee iiddeenntitiffiieerr oonn tthhee WWeebb  Thee tarrget oof aann URL pointer is aann HHTTMMLL ffiillee (virrtuuall oor materialized))  UURRIIss ((UUnniiqquuee RReessoouurrccee IIddeennttiiffiieerr)):: ggeenneerraall ppuurrppoosese kkeeyy ttoo rreessoouurrcceess oonn tthhee WeWebb  Uniquely iddentifiees aa resourrcee  Target is nonot an HTTML ffiillee,, ccaann bbee aanynytthihingng ((sscchehemmaa,, ttaabbllee,, ffiillee,, enttityy, objejecctt,, ttuuppllee,, pperersson,, physical item, etcc)  Lifettime aandnd sscope of this ““key”” iss user deeppeendndeentnt  IIRRII ((IInntteerrnnaattiioonnaalliizzeedd RReessoouurrccee IIdedenntitiffiieerrss))  Alllooww nnoonn LLaattiinn cchaharraacctterss (Chinesee,, AArrabic,, JJaapanese, eettcc)  UURRLL,, UURRII,, IIRRIIss  Alll ssttrriingngss 16  Very LOONG stringss NNaammeessppaacceess  IInntteeggrraattiioonn ooff DDaattaa ffrromom ddiivveerrssee ddaattaa ssoouurrcceess  IInntteeggrraattiioonn ooff ddiiffffeerreenntt XXMMLL VVooccaabbuullaarriieess ((aakkaa NNaammeessppaacceess))  EEaacchh „„vvooccaabbuullaarryy““ hhaass aa uunniiqquuee kkeeyy,, iidedennttiiffiieedd bbyy aa UURRII//IIRRII  SSaammee llooccaall nnaammee,, ffrroomm ddiiffffeerreenntt vvococaabbuullaarriieess ccaann hhaavvee  Diffffererentent meaning  Diffffererentent structuure associiaated witth it  QQuuaalliiffiieedd NNaammeess ((QQnnaammee)) ttoo aattttaacchh aa „„nnaammee““ ttoo iittss „„vvooccaabbuullaarryy““  for allll nnodess in ann XXML dooccuummeenntt tthat has namees (Attributes, Elemeennts, Pis  QQNNaammee ::::== ttrriippllee (( UURRII [[ pprreeffiixx:: ]] llooccaallnnaammee ))  Bindingng ((pprreeffiix,x, UURRII)) iiss introdduced iinn eelleemmeennttss ssttaarrtt ttaagg  Later onlnlyy thehe pprreeffixx iss uused,, not the loonng URIIss  Preefix is opttiionall, defaault nameespaces  Preefix and loocaallnaame a sepaarratteed byy „„::““  „„hhttttpp::///w/w33..oorrgg/T/TRR/1/1999999//RREECC--xxmmll--nnaammeess““ 17 NNaammeessppaacceess ((ccoonntt))

 NNaammeessppaaccee ddeeffiinniittiioonnss llooookk lliikkee AAttrttriibbuutetess  IIddeentntiiffiieedd bbyy „„xxmlmlnnss::pprereffiixx““ oorr „„xxmmllnsns““ ((ddeeffaauulltt))  BBiinndd tthhee PPrereffiixx ttoo tthhee UURIRI  SSccooppee iiss tthhee eentntiirree eelleemmeenntt wwhheerree thethe nnaammeessppaaccee iiss ddeeccllaarreedd  IInncclluuddeess tthehe eelleemmeenntt iitstslleeff,, iitsts aattttrriibbuutteess aanndd iisstt ssuubbtrtreeeess  EExxaammppllee <> <>ccoontentennt> <>  18 DDeeffaauulltt nnaammeessppaacceess  DDeeffaauulltt nnaammeessppaacceess,, nnoo pprreeffiixx <> <> <> <>  OOnnllyy aapppplliieess toto ssuubbeelleemmeennttss,, nnoott aatttrtriibbuutteess <> <> <> <>

19 EExxaammplplee:: NNaammeessppaacceess

 DDQQ11 ddeeffiinneess ddiisshh ffoorr cchhiinnaa  DDiiaammeetteer,r, VVoolluummee,, DDeeccoorr,, ......  DDQQ22 ddeeffiinneess ddiisshh ffoorr ssaatetelllliitteess  DDiiaammeetteer,r, FFrreeqquueennccyy  HHooww mmaannyy „„ddiisshheess““ aarree ththeerree??  BBeetttteerr aasskk ffoorr::  „„HHooww mmaannyy ddiisshheess aarere tthheerree??““ oorr  „„HHooww mmaannyy ddiisshheess aarree ttheherree??““

20 EExxaammplplee:: NNaammeessppaacceess

<> <>2200<> <>55<> <>MMeeiissssnneerr<> <>

<> <>220000<> <>2200--22000000MMHHzz<> <>

21 MMiixxiingng SeSevveerraall NNaammeessppaacceess

<> <>2200<> <>55<> <>MMeeiissssnneerr<> <>TThhiiss iiss aann uunnqquuaalliiffiieedd eelleemmeenntt nnaammee<> <>

22 EExxaammppllee XXMMLL ddaattaa

 XXHHTTMMLL ((bbrroowwsseerr//pprreesseentantatitioon)n)  RSRSSS ((bbllooggss))  UUBBLL ((UUnniivveerrssaall BBuussiinneessss LLaanngguuaaggee))  HHeeaalltthhCCaarree LLeevveell 77 ((mmeeddiiccaall ddaatata))  XXBBRRLL ((ffiinanancnciiaall ddaattaa))  DDiiggiittaall pphhoottooggrarapphyhy mmeettaaddaatata ((XXMMPP))  XXMMII ((mmeetataddaatata))  XXQQuueerryyXX ((pproroggrraammss))  XXFFoormrmss ((ffoormrmss))  SSOOAAPP ((mmeessssaaggee eennvevellooppeess))  MMiiccrorossoofftt OOffffiiccee ---- PPoowweerrppooiintnt iinn XXMMLL ((ddooccuummeennttss)) 23 XXHHTTMMLL

QuickTim e™ and a TIFF (Uncompressed) decom pressor are needed to see this picture.

24 RRSSS,S, bbllooggss  XML.com http://xml.com/pub XML.com features a rich mix of information and services for the XML community. XML.com http://www.xml.com http://xml.com/universal/images/xml_tiny.gif UBUBLL ((UUnniivveerrssaall BBuussiinenessss LLaangnguuaaggee))  VVooccaabbuullaarriieess ddeeffiinniittiioonsns ffoorr::  ApppliicaatioonResponse•AtttachedDooccuument•BillOfLaading •Caatallogue•CatalogueDeeleetioon•CattaalogueIIteemSpeccific ationUpdaate•CataloguePricingUpdate•CatalogueRequ est•CertiffiiccaateOOffOOriigin•CreedittNNoote••DebiitNNottee•Deespatc hAdviccee•ForrwarddiingInstructions•FreighttIInnvoice••Invoic e•Order•OrderCancellation•OrderChange•OrdderResp onse•OrderResponseSiimplee•PPackingList•Quotation•R eceiptAdvice•Reminder•RemittanceAdvice•ReqquestF orQuotation•SelfBilledCreditNNoote•SeelffBiilleedInvooice•St atement•TransporttaationSStatus••WWaayybbilll

26 HHeeaalltthhCCaarreeLLeevveell 77

 MMeeddiiccaall iinnffoorrmmaatitioonn tthhaatt iiss bbeeiinngg eexxcchhaangngeedd bbeettwweeeenn hhoossppiittaallss,, ppaattiieennttss,, ddoocctotorrss,, pphhaarrmmaacciieess aanndd iinnssuurraannccee ccoommppaanniieess  hhttttpp::////eenn..wwiikkiippeeddiiaa..oorrgg//wwiikkii//HHLL77

27 XXBBRRLL ((FFiinnaanncciiaall iinfnfoorrmmaattiioonn))

 GGooaall:: ffaacciilliittaattee tthhee eexxcchhaannggee ooff bbuussiinneessss aanndd ffiinnaanncciiaall ppeerrffoorrmmaannccee iinnffoorrmmaattiioonn bbeettwweeeenn ccoommppaanniieess,, ggoovveerrnnmmeennttss,, iinnssuurraannccee ccoommppaanniieess,, bbaannkkss,, eettcc..  MMaannddaattee bbyy llaaww iinn mmaannyy ccoouunnttrriieess  hhttttpp::////eenn..wwiikkiippeeddiiaa..oorrgg//wwiikkii//XXBBRRLL

28 EExxtteennssiibbllee MMeettaaddaattaa PPllaattffoorrmm (XMP)  Useed inn PPDDF,, pphhoott(ooXggrraaMphPy aa)nndd pphhoottoo eeddiittinng appliiccaattiioonnss.  Parttiiccuullaarr sscchheemas fforr bbaassiicc pprooppeerrttiieess uuseeffuull foorr reccorddiing tthe hhissttorryy ooff aa rreessoouurrccee aass iitt ppaasssseess throouugghh mmuullttiippllee pprroocceesssiinngg sstteeppss,, ffrroomm bbeeiinngg photograapphheedd,, ssccaannnneedd,, oorr aauutthhoorreedd aass tteextt,, throouugghh pphhoottoo eeddiitiinngg sstteeppss (suucchh aass croopppinngg oorr colloorr aaddjjuussttmmeennt),, ttoo aassseemmbbllyy innttoo aa ffiinnaall iimmaaggee..  XMPP aalllloowwss eeaacch ssooffttwwaree pprrooggrraamm oorr ddeevviiccee aalloonngg the wwaayy tto aadd iittss owwnn iinnffoorrmmatiioonn ttoo aa ddiigittaall ressourcce, whhiichh ccaann tthheenn bee rreettaaiineedd inn thhee ffiinnaall diggiittall ffiille.  hhttttpp::////eenn..wwiikkiippeeddiiaa..oorgrg//wwiikkii//EExxtetennssiibbllee__MMeettaaddaatt aa__PlPlaattffoormrm 29 MMiiccrroossoofftt OOffffiiccee iinn XXMMLL

 OOffffiiccee 22000033 wwaass aabbllee ttoo iimpmpoorrtt//eexxppoortrt aallll ddooccuummeennttss iinnttoo XXMMLL  OOffffiiccee 22000077 mmooddeellss thethe ddooccuummeennttss NNAATTIIVVEELLYY iinn XXMMLL  EExxaampmplleess ooff vvooccaabbuulalarrieiess aanndd sscchheemmaass::  WWoorrddpprroocceessssiinnggMMLL ((tthhee XMXMLL ffiillee ffoorrmmaatt ffoorr WWoorrdd 22000033)),, SSpprreeaaddsshheeeettMMLL ((EExxcceell 22000033)),, FFoorrmmTTeemmppllaattee XXMMLL sscchheemmaass ((IInnffooPPaatthh 22000033)) aanndd DDaattaaDDiiaaggrraammiinnggMMLL ((VViissiioo 22000033))

30 FFoorrmmss oonn tthhee WWeebb iinn XXMMLL

 XXMMLL FFoorrmmss ((XXffoorrmmss))  hhttttpp::////wwwwww..ww33..oorrgg//TTRR//xxffoormrmss// 

31 PrProgogrraammss aandnd ququeerriieess iinn XXMMLL  XXQQuueerryy,, tthhee XXMMLL ququeerryy llaanngguuaaggee,, hhaass aann XXMMLL rreepprreesseennttaatitionon  PPrrooggrraammss aanndd qquueerriieess aarree aallssoo DDAATTAA  BBlluurrrriinngg tthhee ddiististinnccttiioonn bbeettwweeeenn ddaattaa,, mmeettaaddaatata,, ccooddee  distinct document http://www.bn.com descendant-or-self author

32 SOSOAAPP aanndd WWeebb SSeerrvivicceess  WWeebb SSeerrvviicceess iiss tthhee ffaavvooririttee wwaayy ooff eexxcchhaannggiinngg iinnffoorrmamatitioonn bbeettwweeeenn aapppplliiccaatitioonnss  XXMMLL eexxcchhaannggee oovveerr HHTTTTPP,, wwiitthh aa ssppeecciiffiicc pprroottooccooll ((SSOOAAP)P)  uuid:093a2da1-q345-739r-ba5d- pqff98fe8j7d 2001-11- 29T13:20:00.000-05:00 Åke Jógvan Øyvind 33 TThhee nneeeedd ffoorr XXMMLL ““sscchheemmaass””  UUnnlliikkee aannyy ootthheerr ddaattaa ffoorrmmaatt,, XXMMLL iiss totottaallllyy fflleexxiibbllee,, eelleemmeenntsts ccaann bbee nneesstteedd iinn aarrbbiittrraarryy wwaayyss  WWee ccaann ssttaarrtt bbyy wwrriititingng tthhee XXMMLL ddaatata ---- nono nneeeedd ffoorr aa pprriioorrii ddeessiiggnn ooff aa sscchehemmaa  TThhiinnkk rreellaattiiononaall dadattaabbaasseess,, oror JJaavvaa ccllaasssseess  HHoowweevveer,r, sscchheemmaass aarere nneecceessssaarryy::  FFaacciilliittaattee ththee wwrriittiinngg ooff aapppplliiccaattiioonnss tthhaatt pprroocceessss ddaatata  CCoonnssttrraaiinntt tthhee ddaattaa tthhaatt iiss ccororrreecctt fforor aa cceerrtataiinn aapppplliiccaattiionon  HHaavvee aa pprriioorrii aaggrreeeemmeennttss bbeettwweeeenn ppaarrttiieess wwiitthh rreessppeecctt ttoo tthhee dadattaa bbeeiinngg eexxcchhaannggeedd  SScchehemmaa:: aa momoddeell ooff ththee ddaattaa  SSttrruuccttuurraall ddeeffiinniittiioonnss  TTyyppee ddeeffiinniittiioonnss  DDeeffaauullttss 34 HHiissttoorryy aanndd rroollee ooff XXMMLL SScchheemmaa LLaanngguuaaggeess  SSeeveverraall ssttaannddaarrdd SScchehemmaa LLaanngguuaaggeess  DDTTDDss,, XXMMLL SScchheemmaa,, RReellaaxxNNGG  SScchehemmaa llaanngguuaaggeess hhaavvee bbeeeenn ddeessiiggnenedd aafftteer,r, aanndd iinn aann oorrtthhooggoonanall ffaasshhiioonn,, ttoo XXMMLL iittsseellff  SScchehemmaass aandnd ddaattaa aarere ccoommpplleetteellyy ddeeccoouupplleedd iinn XXMMLL  DDaattaa ccaann eexxiisstt wwiitthh oorr wwiitthhoouutt sscchheemmaass  OOrr wwiitthh mmuullttiippllee scschheemmaass  SScchheemmaa eevvoolluuttiioonnss rraarreellyy iimmppososee eevvololvviinngg tthhee ddaattaa  SScchheemmaass ccaann bbee ddeesisiggnneedd bbeeffororee tthhee ddaatata,, oorr eexxttrraacctteedd ffrroomm tthhee dadattaa ((DDaatataGGuuiidede ---- SStatannffoorrd)d)  MMaakkeess XXMMLL tthehe ririgghhtt cchohoiiccee ffoorr mmaanniippuullaattiinngg sseemimi-- ssttrruuccttuurreedd ddaattaa,, oorr rarappiiddllyy eevovollvviingng ddaattaa,, oorr hhiigghhllyy ccuusstotomimizzaabbllee ddaatata 35 DDTTDDss  IInnhheeriritteedd ffroromm SSGMGMLL  PPaarrtt ooff tthhee ooririggiinanall XXMMLL 11..00 ssppeecciiffiiccaatitioonn  DDeessccrriibbee tthhee ““ggrraammmmaar”r” ooff tthehe XXMMLL ffiillee  EElleemmeenntt ddeeccllaarraattiioonnss:: hhooww eelleemmeennttss aarree aalllloowweedd ttoo nneesstt wwiitthhiinn eeaacchh ootthheerr bbyy rruulleess aanndd ccononssttrraaiinnttss  AAttttrriibbuutteess lliissttss:: ddeescscrriibbee wwhhaatt aattttrriibbuutteess aarree aallllowoweedd onon wwhhiicchh eelleemmeenntt  SSoommee ccononstrstraaiinnttss oonn tthhee vvaalluuee ooff eelleemmeenntsts aanndd aattttrriibbuutteess  WhWhiicchh iiss tthhee rroooott eelleemmeenntt ooff tthhee XXMMLL ffiillee  CChehecckkiingng tthhee sstrtruuccttuurraall ccoonnssttrraaiinnttss:: DDTTDD vvaalliiddaattiioonn ((vvaalliidd vvss.. iinvnvaalliidd ddooccuummeentntss))  DDTTDD vveerryy uusseeffuull ffoorr aa wwhihillee,, nnoott uusseedd aannyymmoorree,, 36 sseevveerraall mmaajjoorr lliimmiittaattiioonnss DDeeccllaarriinngg tthhee ssttrrucucttuurree ooff elements  GGrraammmmaarr tthhaatt ddeesscceriribbleessm tthheee ssnttrrutusccttuurree ooff thethe eelleemmeenntt  Subelementents, iiddentified bby Namme orr  #PCCDDAATTAA  CComombbiinnaattoorrss ::  „+“ forr at leastt 11  „*“ forr 0 orr moorre  „?“ for 0 orr 1  „ , „ foorr ccooncncaatteennaattiioonn  „ | „„ forr choice  <>  PCPCDDAATTAA:: oonnllyy tteexxtutuaall ccoonntteenntt aalllloowweedd  <>  EEMMPPTTYY :: tthhee eelleemmeenntt mmuusstt bbee eemmppttyy  <>  AANNYY:: aalllloowwss aanyny ccoonntteenntt 37  <> EExxaammppllee DDTTDD ffoorr rreecciippeess

38 DDeeffiinininngg tthhee aattttrriibbuuttee lliissttss

 SSttrruuccttuurree:: <>  <>  CDCDAATTAA mmeeaannss nnoorrmmaall ccoonntetenntt  ##RREEQQUUIIRREEDD,, oorr ##IIMMPPLLIIEEDD rreeffeerr ttoo tthhee ffaacctt ththaatt ththee aattttrriibbuuttee iiss ooppttiioonnaall oorr nnoott  DDeeffaauulltt vvaalluuee ppoossssiibbllee 39 AtAtttrriibbuutteess ((ccoontnt..))  ##RREEQQUUIIRREEDD  DDooccuummeenntt mmuusstt ssppeecciiffyy aa vvaalluuee ffoorr aatttrtriibbuutete  ##IIMMPPLLIIEEDD  AAttttrriibbuuttee iiss oopptitioonnaall,, tthheerree iiss nono ddeeffaauulltt  vvaalluuee  DDeeffaauulltt vavalluuee,, iiff nnoo oothetherr vvaalluuee ssppeecciiffiieedd  ##FFIIXXEEDD vvaalluuee  DDeeffaauulltt vavalluuee,, iiff nnoo oothetherr vvaalluuee ssppeecciiffiieedd  IIff vvaalluuee ssppeecciiffiieedd,, iitt mmuusstt bbee tthhee ffiixxeedd vvaalluuee

40 MMaajjoorr aattttrriibubuttee ttyyppeess

 PPCCDDAATTAA:: nnoorrmmaall TTeexxtt ccoonntteenntt  IIDD  VVaalluuee iiss uunniiqquuee wwiitthihinn ddooccuummeenntt  EElleemmeenntt hhaass aatt mmoosstt oonnee aattttriribbuutete ooff tthhiiss ttyyppee  NoNo ddeeffaauulltt vvaalluueess aalllloowweedd  IIDDRREEFF,, IIDDREREFFSS  ReReffeerreenncceess ttoo ootthheerr eelleemmeenntsts wwiitthhiinn tthhee ddooccuummeenntt  IIDDRREEFFSS:: EEnnuummeerraattiioonn,, „„ ““ aass sseeppaararatotorr

41 IIDD aanndd IIDDRREEFF aattttrriibbututeess

 <>

 <> <> <>

42 AtAtttrriibbuutteess lliisstt eexxaammppllee

amount CD A TA #I M P L I E D

unit CD A TA #I M P L I E D >

carbohydrates CD A TA #R E QUI R E D fat CD A TA #R E QUI R E D 43

calories CD A TA #R E QUI R E D

alcohol CD A TA #I M P L I E D > MMiixxeedd ccoonntteenntt iinn DDTTDDss

 MMiixxiinngg PCDPCDAATTAA ddeeccllaarraatitioonnss wwiithth ootthheerr ssuubbeelleemmeenntsts mmeeaannss thathatt ththee ccoonntetenntt ccaann bbee ““mmiixxeedd””

some text some emphasized text blah some bold text

44 DDeeccllaarraattiioonnss ooff DDTTDDss

 NNoo DDTTDD ((wweellll--ffoorrmmeedd DDooccuummeentntss))  DDTTDD iinnssiiddee ththee DDooccuummeennt:t: <>  DDTTDD eexxtteerrnnaall,, ssppeecciiffiieedd bbyy UURIRI:: <>  DDTTDD eexxtteerrnnaall,, NNaammee aanndd ooppttiioonnaall UURRII:: <> <>  DDTTDD iinnssiiddee ththee ddooccuummeenntt ++ eexxtteerrnnaall:: <>

45 CCoorrrreeccttnneessss ooff XXMMLL ddococuummeennttss

 WeWellll ffoorrmmeedd ddococuummeenntsts  Verify the basic XMML coonstraints, e.g.  VVaalliidd dodoccuummeennttss  Verify the additional DDTDD structtural constrraiinntss  NNoonn wweellll ffoorrmmeedd XXMMLL ddooccuummeennttss ccaannnnotot bbee pprroocceesssseedd  NNoonn--vvaalliidd ddococuummeenntsts ccaann ssttiillll bbee pprroocceesssseedd ((qquueerriieed,d, ttrraannssffoorrmmeedd,, eettcc))

46 LLiimmiittaattiioonsns ooff DDTTDDss

 DDTTDDss ddeessccrriibbee oonnllyy tthhee ““ggrraammmmaarr”” ooff ththee XXMMLL ffiillee,, nnoott tthehe ddeettaaiilleedd sstrtruuccttuurree aanndd//oorr ttyyppeess  Thiiss ggrraammmmaattiiccaall ddeessccrriippttiioonn hhaass ssoommee oobbvviioouuss shoorrttcoommiinnggss:  we cannot express that a “length” elemennt must contain a non-negative numberr (constraints on the type of the value of an element or attribute)  TThhee ““uunniitt”” element should only be allowed when “aammoouunntt”” iss present (co-occurrreence constraints)  thee ““ccoommmmeenntt”” eleemennt should be alloowedd to aappeaar anywhere (schema flexiibility)

47 Good Schema design principles  The XML schema language shall be 1. more expressive than XML DTDs 2. expressed in XML 3. self-describing 4. usable by a wide variety of applications that employ XML 5. straightforwardly usable on the Internet 6. optimized for interoperability 7. simple enough to be implemented with modest design and runtime resources 8. coordinated with relevant W3C specs 48 RReeccaappiittuullaattiioonn  XXMMLL aass iinnheherriittiinngg ffrroomm tthehe WWeebb hhiissttoorryy  SSGGMMLL,, HHTTMMLL,, XXHHTTMMLL,, XXMMLL  XXMMLL kkeeyy ccoonncceeppttss  DDococuummeennts,ts, eelleemmeennttss,, aattttrriibbuutteess,, tteexxtt  OOrrdederr,, nneesstteedd ssttrruuccttuurree,, tteexxttuuaall iinnfforormmaattiioonn  NaNammeessppaacceess  XXMMLL uussaaggee sscceenanarriiooss  FFiinnaanncciiaall,, mmeedidiccaall,, mmeettaaddaattaa,, bbllooggss,, eettcc  DDTTDDss aanndd tthhee nneeeedd ffoorr ddeessccrriibbiinngg tthhee ““ssttruruccttuurere”” ooff aann XXMMLL ffiillee  NeNexxtt:: XXMMLL SScchheemmaass

49