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<><"><<><>
4 TThhee ssaammee iinnffoorrmmaattiioonn iinn XXMMLL <
• 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 <
• Nested structure • Conceptual tree • Order is important • Only “characters”, not integers7, etc ElEleemmeentntss
EEnncclloosseedd iinn TTaaggss BBeeggiinn TTaagg:: ee..gg..,, <
EElleemmeenntsts ccaann bbee nneesstteedd <
9 TTeexxtt aanndd MMiixxeedd CCoontnteenntt TTeexxtt aappppeeaarrss iinn eelleemmeenntt ccoonntteentnt <
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. <
SSoommeetitimemess wwee wwoouulldd lliikkee ttoo ppreresseerverve tthhee oorriiggiinnaall cchaharraacctteerrss,, aanndd nonott iinnteterrpprreett tthehemm aass mmaarrkkuupp CCDDAATTAA sseeccttiioonnss NNoott ppaarrsseedd aass XXMMLL
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)) <
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 <
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
<
<
21 MMiixxiingng SeSevveerraall NNaammeessppaacceess
<
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
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
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)
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.
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