Sabin Buraga: 'Tehnologii XML'

  • 442 views
Uploaded on

Varianta electronică a volumului "Tehnologii Web" de Sabin Buraga (416 pagini, ISBN 973-46-0249-7) prezentând cele mai importante tendințe în utilizarea, proiectarea, procesarea și conceptualizarea …

Varianta electronică a volumului "Tehnologii Web" de Sabin Buraga (416 pagini, ISBN 973-46-0249-7) prezentând cele mai importante tendințe în utilizarea, proiectarea, procesarea și conceptualizarea datelor prin suita de tehnologii XML (Extensible Markup Language). Subiectele atinse includ diverse aspecte ale familiei XML și soluțiile pentru modelarea și stocarea conținutului semi-structurat.

Alte detalii la http://profs.info.uaic.ro/~busaco/books/xml/

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
442
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
23
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Sabin Buraga Tehnologii XML
  • 2. Tehnologii XML2 Seria Web HVWH FRRUGRQDW GH GU 6DELQ %XUDJD )DFXOWDWHD GH ,QIRUPDWLF 8QLYHUVLWDWHD Å$O, &X]Dµ ,DüL
  • 3. Sabin Buraga HVWH OHFWRU GRFWRU OD )DFXOWDWHD GH ,QIRUPDWLF D 8QLYHUVLWLL Å$O, &X]Dµ GLQ ,DüL ILLQG WLWXODUXO FXUVXULORU Å7HKQRORJLL :HEµ Å6HPDQWLF :HEµ Å,QWHUDFLXQH RP- -FDOFXODWRUµ üL Å5HHOH GH FDOFXODWRDUHµ (VWH ODXUHDW DO 3UHPLXOXL Å*KHRUJKH &kUWLDQXµ DO $FDGHPLHL 5RPkQH 
  • 4.  0DL PXOWH DPQXQWH SULYLWRDUH OD DFWLYLWLOH VDOH VXQW disponibile pe Web la adresa http://www.infoiasi.ro/~busaco. La Editura Polirom a mai publicat: $WHOLHU GH SURJUDPDUH vQ UHHOH GH FDOFXODWRDUH (în colaborare, 2001), Programare Web în EDVK üL 3HUO (în colaborare, 2002), 3URLHFWDUHD VLWXULORU :HE 'HVLJQ üL IXQFLRQDOLWDte + CD (2002), $SOLFDLL :HE OD FKHLH (coord., 2003), Utilizare Linux (în colaborare, 2004), Situri Web la cheie. 6ROXLL SURIHVLRQDOH GH LPSOHPHQWDUH (coord., 2004), 3URLHFWDUHD VLWXULORU :HE 'HVLJQ üL IXQFLRQDOLWDWH  &' HGLLD D ,,D 
  • 5. üL PrimiL SDüL vQ /LQX[ (în colaborare, 2006). %UXQD =D QL $XJXVWR 3DOPRQDUL D FXUD GL
  • 6.  0DQXDOH GL SVLFRORJLD GL FRPXQLWº ƒ  E 6RFLHWº HGLWULFH LO 0XOLQR %RORJQD ©  E (GLWXUD 32/,520 ZZZSROLURPUR (GLWXUD 32/,520 ,D>L %GXO &DURO , QU  32 %2;   %XFXUH>WL %GXO ,& %U?WLDQX QU  HW  DS  23  32 %2;   'HVFULHUHD &,3 D %LEOLRWHFLL 1D@LRQDOH D 5RP¼QLHL %85$*$ 6$%,1 &251(/,8 7HKQRORJLL ;0/  6DELQ %XUDJD r ,D>L 3ROLURP  %LEOLRJU ,6%1 
  • 7.  ,6%1 
  • 8.   ;0/ 3ULQWHG LQ 520$1,$
  • 9. 3 32/,520 
  • 10. Tehnologii XML4
  • 11. 5 Cuprins Prefa ......................................................................................................................9 Capitolul 1 – Calea de acces la Web.................................................................11 1. Preambul.......................................................................................................11  $VSHFWH HVHQLDOH SULYLWRDUH OD SURWRFROXO +773....................................12 2.1. Preliminarii...........................................................................................12  &RQFHSWH üL IXQFLRQDUH......................................................................12 2.3. Mesajele HTTP.....................................................................................18 2.4. Atributele HTTP..................................................................................22  /RFXO +773 vQ DUKLWHFWXUD VSDLXOXL :::............................................26 5HIHULQH............................................................................................................28 Capitolul 2 – Modele de date semistructurate. Familia XML.....................29 1. Introducere...................................................................................................29 1.1. Formate de date...................................................................................29 1.2. Modele de date ....................................................................................30 1.3. Date semistructurate...........................................................................31 2. XML pentru reprezentarea datelor semistructurate...............................33 2.1. Precursori .............................................................................................33  &RQFHSWH GH ED] &DUDFWHUL]DUH üL WUVWXUL...................................34  &RQVWLWXHQL..........................................................................................37 2.4. Familia XML.........................................................................................44  $SOLFDLL üL LQVWUXPHQWH ;0/ ............................................................45 2.6. O privire de ansamblu........................................................................47  &RPSRQHQWH GH ED] DOH IDPLOLHL ;0/....................................................49 3.1 6SDLLOH GH QXPH ;0/ ........................................................................49 3.2. Modelul de date XML: XML Infoset.................................................52 3.3. Transformarea documentelor XML..................................................54 3.4. Validarea documentelor XML.........................................................102  ([SULPDUHD OHJWXULORU YLD ;/LQN ...................................................137 4. Limbaje bazate pe XML. Exemple...........................................................143  ,QWHUDFWLYLWDWHD FX XWLOL]DWRUXO )LOLHUD ;+70/  üL ;)RUPV....144 4.2. Specificarea structurii hipertext a unui sit Web............................150  3URWRFROXO GH FRPXQLFDLH IRORVLW GH -DEEHU..................................150  ,QWHURJUL ;0/ ..........................................................................................153 5.1. Preliminarii.........................................................................................153
  • 12. Tehnologii XML6 5.2. Baze de date native XML..................................................................153  0RGDOLWL GH UHDOL]DUH D LQWHURJULORU ...........................................157  ,PSOHPHQWUL üL DSOLFDLL...................................................................163 5.5. Studii de caz.......................................................................................164  ûDEORDQH GH SURLHFWDUH ;0/....................................................................177 6.1. Punerea problemei............................................................................177  &H HVWH XQ üDEORQ".............................................................................178  &DWHJRULL GH üDEORDQH GH SURLHFWDUH ;0/......................................178 5HIHULQH..........................................................................................................189 Capitolul 3 – 3URFHVUL ;0/............................................................................193 1. Preliminarii.................................................................................................193 2. Modelul DOM............................................................................................194 2.1. Caracterizare......................................................................................194  ,QWHUIHH üL LPSOHPHQWUL..................................................................196  )XQFLRQDOLWL GH ED] DOM Core.................................................197 2.4. Extensii oferite de DOM nivelul 2...................................................202 2.5. Extensii oferite de DOM nivelul 3...................................................206  ,PSOHPHQWUL......................................................................................207 2.7. Exemple ..............................................................................................209  ,QWHUIDD 6$;..............................................................................................240 3.1. Caracterizare......................................................................................240 3.2. Maniera de procesare........................................................................240  ,PSOHPHQWUL......................................................................................244 3.4. Exemple ..............................................................................................244 3.5. DOM versus SAX ...............................................................................251  $OWH PRGDOLWL GH SURFHVDUH ;0/..........................................................253 4.1. Preliminarii.........................................................................................253  3URFHVDUHD VLPSOLILFDW D GRFXPHQWHORU ;0/...............................254 4.3. Consultarea documentelor XML prin XMLReader .......................255 4.4. Generarea documentelor XML prin XMLWriter...........................259  $OWH IDFLOLWL RIHULWH GH .NET Framework .....................................260  2 DOWHUQDWLY OD '20 SULQ ;20 ....................................................266 5HIHULQH..........................................................................................................266 Capitolul 4 – XML pentru servicii Web: SOA, REST, AJAX.....................269 1. Preambul.....................................................................................................269  $UKLWHFWXUD RULHQWDW VSUH VHUvicii Web .................................................270 2.1. Introducere.........................................................................................270  7HKQRORJLL GH SURJUDPDUH D DSOLFDLLORU :HE ...............................271 2.3. Un studiu de caz................................................................................285
  • 13. 7 3. AJAX (Asynchronous JavaScript And XML).............................................299 3.1. Context................................................................................................299 3.2. Caracterizare......................................................................................302 3.3. 8Q SULP H[HPSOX YHULILFDUHD H[LVWHQHL XQXL QXPH de cont de utilizator..........................................................................304 3.4. Al doilea exemplu: jurnalizarea pe partea de server D H[FHSLLORU DSUXWH vQ SURJUDPHOH -DYD6FULSW executate în cadrul browser-ului......................................................312  $VSHFWH LPSRUWDQWH vQ OHJWXU FX UHDOL]DUHD GH DSOLFDLL $-$;...............................................................................320 3.6. AJAX în contextul REST...................................................................322  8WLOL]UL üL LQWHUIHH GH SURJUDPDUH $-$;.....................................323  &RQVLGHUDLL SULYLQG VHFXULWDWHD DSOLFDLLORU IRORVLQG $-$;.......323 3.9. În loc de concluzii…..........................................................................325 5HIHULQH..........................................................................................................327 Capitolul 5 – &WUH :HE-ul semantic .............................................................331 1. Introducere.................................................................................................331 2. Spre Web-ul semantic...............................................................................334 2.1. Punerea problemei............................................................................334 2.2. Niveluri ale Web-ului semantic ......................................................335 3. Specificarea meta-datelor prin RDF........................................................337  &DUDFWHUL]DUH JHQHUDO ......................................................................337  0RGHOXO GH ED] ................................................................................339 3.3. Vocabulare de meta-date..................................................................342 3.4. Sintaxe alternative.............................................................................346  ,PSOHPHQWUL üL XWLOL]UL...................................................................349  5') üL PLFURIRUPDWHOH......................................................................351 4. De la Web 1.0 la Web 2.0 (Data Web).......................................................352 4.1. Preliminarii. Caracteristici ale „noului” Web................................352  0DUFDMH DGQRWUL
  • 14. GHILQLWH GH XWLOL]DWRU........................................354 4.3. Participare, nu doar publicare a datelor ........................................355 4.4. Descentralizare radicaO ...................................................................356  ÍQFUHGHUH UDGLFDO )RORVLUHD VWDQGDUGHORU ....................................357  ,QWHUDFLXQH ERJDW FX XWLOL]DWRUXO..................................................358 4.7. Spre Web-ul social?...........................................................................359 5. Ontologii.....................................................................................................361 5.1. Ontologia cu „O” mare sau mic? ....................................................361 5.2. Scopuri................................................................................................362
  • 15. Tehnologii XML8 6. Tipuri de ontologii ....................................................................................362  &ODVLILFUL............................................................................................362 6.2. Specificarea taxonomiilor.................................................................364 6.3. Tezaure ...............................................................................................369  0RGHODUHD FXQRüWLQHORU 2QWRORJLL FRPSOH[H...............................370 7. Specificarea unei ontologii.......................................................................371 7.1. Specificarea categoriilor ...................................................................372  6SHFLILFDUHD SURSULHWLORU................................................................373  6SHFLILFDUHD UHODLLORU ........................................................................374  ([HPSOLILFUL......................................................................................375 8. Formalisme.................................................................................................377 8.1. Punerea problemei............................................................................377 8.2. Spre un model formal.......................................................................377  /RJLFLOH GHVFULHULL 2 SUH]HQWDUH VXFFLQW......................................378 9. Proiectarea (ingineria) ontologiilor.........................................................381 9.1. Preliminarii.........................................................................................381 9.2. Metodologii de proiectare a ontologiilor.......................................381 10. Specificarea ontologiilor prin OWL......................................................385 10.1. Caracterizare....................................................................................385 10.2. Sintaxa OWL....................................................................................386  'LIHUHQH vQWUH QLYHOXULOH 2:/ .....................................................392  &WUH UDLRQDPHQW DXWRPDW....................................................................393 11.1. MaQLHUH GH UDLRQDPHQW.................................................................393  'H OD RQWRORJLL OD UDLRQDPHQW DXWRPDW .......................................394 12. „Concluzii”...............................................................................................403 5HIHULQH..........................................................................................................404 %LEOLRJUDILH JHQHUDO ........................................................................................409
  • 16. 3UHID „,PSRUWDQW HVWH QX XQGH HüWL FL vQFRWUR WH vQGUHSL” Oliver Wendell Holmes Jr. &DUWHD GH ID – parte a seriei Web a Editurii Polirom – are drept principal VFRS SUH]HQWDUHD FHORU PDL LPSRUWDQWH WHQGLQH vQ XWLOL]DUHD SURLHFWDUHD SURFHVDUHD üL FRQFHSWXDOL]DUHD GDWHORU YLD VXLWD GH WHKQRORJLL Extensible Markup Language (XML – acronim explicitat, cu umor, de unii prin Excellent Marketing Language). Al doilea demers este cel de a-l conduce pe cititor spre YLLWRUXO vQWUHY]XW DO VSDLXOXL :RUOG :LGH :HE 6XELHFWHOH DWLQVH GHRVHELW GH DFWXDOH SH SODQ PRQGLDO VH UHIHU vQ VSe- cial la GLYHUVH DVSHFWH DOH IDPLOLHL ;0/ VROXLL SHQWUX PRGHODUHD üL VWRFDUHD FRQLQXWXOXL VHPLVWUXFWXUDW &RQVLGHUP F GH LQWHUHV VH YRU EXFXUD – prin- tre altele – SULOH GHGLFDWH ED]HORU GH GDWH QDWLYH ;0/ LQFOXVLY FX SUHzen- tarea unor limbaje de interogare SUHFXP ;3DWK üL ;4XHU
  • 17.  üDEORDQHORU GH SURLHFWDUH ;0/ VDX PDQLHUHL GH LQWHUDFLXQH :HE YLD $-$; Asynchronous JavaScript And XML
  • 18.  9ROXPXO QX RPLWH PRGDOLWLOH GH SURFHVDUH ;0/ SULQ GLYHUVH PHWRGH GH UHGDUH D FRQLQXWXOXL YLD WUDQVIRUPUL ;6/ Exten- sible Styesheet Language), de validare a documentelor sau de creare a servi- ciilor Web, punctând cele mai bune practici de utilizare. 'H DVHPHQHD IDFHP R WUHFHUH vQ UHYLVW D FRQFHSWHORU GH ED] üL D FHORU mai populare tehnologii ale Web-ului, cu reliefarea GLUHFLLORU GH HYROXLH FWUH Data Web, Social Web üL FHHD FH YD IL Semantic Web. De la prezentarea modului de acces via protocolul HTTP (Hypertext Transfer Protocol), de- WDOLHP FRPSRQHQWHOH GH ED] DOH IDPLOLHL GH OLPEDMH ;0/ SHQWUX D DMXQJH V GHVFULHP – într-un final mereu amânat – meta-GDWHOH üL RQWRORJLLOH (x- puneUHD HVWH UHDOL]DW GLQWU-R SHUVSHFWLY SUDJPDWLF GDU QX QHJOLMP PHQLonarea bazelor teoretice, acolo unde este cazul. 1XPHURDVHOH LPSOHPHQWUL SUH]HQWDWH UHFXUJ OD GLYHUVH SDUDGLJPH üL limEDMH GH SURJUDPDUH SUHFXP & & -DYD -DYD6FULSW 3HUO üL 3+3 'H asemenea, sunt descrise diverse limbaje de marcare bazate pe XML – XHTML 2.0, XForms, RDF (Resource Description Framework), FOAF (Friend Of A Friend
  • 19. üL 2:/ Web Ontology Language) – üL sunt prezentate me- todologiile de proiectare a unora noi.
  • 20. 3UHID10 0DWHULDOXO YD SXWHD IL SDUFXUV üL vQHOHV GH RULFH SHUVRDQ LQWHUHVDW GH domeniul Web, în special de meta-OLPEDMXO ;0/ LQWHQLRQkQG V-üL IRr- meze o privire de ansamblu asupra tehnologiilor actuale üL DVXSUD HYROXLHL Web-XOXL vQ YLLWRUXO DSURSLDW 9ROXPXO VH DGUHVHD] GH]YROWDWRULORU GH Vituri üL DSOLFDLL :HE VSHFLDOLüWLORU vQ GRPHQLL SUHFXP ED]HOH GH GDWH LQWHUDFiunea om-FDOFXODWRU LQWHOLJHQD DUWLILFLDO LQJLQHULD VRIWZDUH VDX FDOFXOXO GLs- tribuit, SUHRFXSDL GH PRGHODUHD FRQFHSWXDO D GDWHORU üL GH prelucrarea IOH[LELO HILFLHQW üL LQGHSHQGHQW GH SODWIRUP D GRFXPHQWHORU Atât stu- GHQLL üL PDVWHUDQ]LL GH OD IDFXOWLOH GH LQIRUPDWLF VDX FX SURILO vQUXGLW FkW üL HOHYLL GLQ FODVHOH PDUL YRU JVL FX FHUWLWXGLQH LQIRUPDLL GH LQWHUHV referitoare la Web. 'HüL OXFUDUHD GH ID D IRVW HIHFWLY VFULV vQ SHULRDGD  LDQXDULH – 27 fe- EUXDULH  FRQLQXWXO HL UHIOHFW H[SHULHQD DFXPXODW SH SDUFXUVXO XOWi- PLORU DQL üL VH ED]HD] vQWU-R DQXPLW PVXU SH DFWLYLWaWHD GHVIüXUDW GH autor în cadrul unor discipline ca Tehnologii Web, Semantic Web üL ,QWHUDFi- une om-calculator SUHGDWH OD )DFXOWDWHD GH ,QIRUPDWLF D 8QLYHUVLWLL Å$le- [DQGUX ,RDQ &X]Dµ GLQ ,DüL $SUHFLHP LQWHUHVXO üL VSULMLQXO DFRUGat de-a lungul anilor de o parte din- WUH VWXGHQLL QRüWUL – DFWXDOPHQWH DEVROYHQL PDMRULWDWHD &DUWHD QX DU IL DMXQV OD IRUPD DFWXDO IU DSRUWXO GLUHFW VDX LQGLUHFW DO GRPQLORU Dr. Cor- nelius Croitoru, Laurian Gridinoc, CWOLQ +ULFX, Dr. Toader Jucan, Manuel ûXEUHGX üL 'U ûWHIDQ 7UXüDQ-Matu 'H DVHPHQHD QH H[SULPP JUDWLWXGLQHD QRDVWU FROHFWLYXOXL (GLWXULL 3ROLURP üL SULQLORU QRüWUL 1X vQ XOWLPXO rând, mulXPLP ILUPHL 6QF52 SHQWUX DFRUGDUHD XQHL OLFHQH DFDGHPLFH D editorului XML <oXygen />. SLWXO FULL SRDWH IL DFFHVDW OD http://www.infoiasi.ro/~busaco/books/xml/. Ma- joritatea surselor incluse în acest volum pot fi preluate direct de pe sit, sub auspiciile preY]XWH GH OLFHQHOH *18 GNU is Not UNIX). Autorul poate fi contactat via situl personal: http://www.infoiasi.ro/~busaco/. 1X QH PDL UPkQH GHFkW V Y GRULP R UH
  • 21. SDUFXUJHUH SOFXW D FULL üL PXOW VXFFHV vQ DFWLYLWDWHD GXPQHDYRDVWU GH – SRWHQLDOL VDX FRQVDFUDL – DFWXDOLYLLWRUL VSHFLDOLüWL vQ WHKQRORJLLOH ;0/ Dr. Sabin Buraga ,DüL 27 februarie 2006
  • 22. Capitolul 1 Calea de acces la Web „$ GHILQL vQVHDPQ D XFLGH D VXJHUD vQVHDPQ D FUHD” Stéphane Mallarmé $FHVW FDSLWRO DGXFH vQ DWHQLD FLWLWRUXOXL R VHULH GH DPQXQWH SULYito- are la protocolul de transfer al datelor hipertext ± HTTP (Hypertext Transfer Protocol). Suplimentar, se descriu caracteristicile principale ale identificatorilor uniformi de resurse. Cuvinte-cheie: protocol, HTTP, adresarea resurselor, URI. 1. Preambul 8QXO GLQWUH FHOH PDL LPSRUWDQWH üL PDL GH VXFFHV VHUYLFLL DOe Internetului, World Wide Web-ul – mai pe scurt, Web VDX VSDLXO WWW –, a fost instituit la CERN (Centre Européen pour la Recherche Nucléaire – Centrul European de &HUFHWUL 1XFOHDUH GH OD *HQHYD
  • 23. vQ DQXO  JUaLH YL]LXQLL OXL 6LU 7LP Berners-Lee. AceVWD vPSUHXQ FX 5REHUW &DLOODX üL R HFKLS GH VSHFLDOLüWL D propus un sistem informatic disWULEXLW VFRSXO SULQFLSDO XUPULW ILLQG IDFLOL- tarea accesului rapid la inIRUPDLLOH WHKQLFH FXSULQVH vQ PDQXDOHOH GH XWLOL]DUH D FDOFXODWRDUHORU 'RX PDUL GLUHFLL SUHFXUVRDUH WUHEXLH PHQLRQDWH • GH]YROWDUHD KLSHUWH[WXOXL VDX D SURFHVULL FRPSXWHUL]DWH D GRFX- mentelor electronice complexe); • SURJUHVXO vQUHJLVWUDW vQ FHHD FH SULYHüWH SURLHFWDUHD üL IRORVLUHD SURWRFRDOHORU ,QWHUQHW FDUH DX IFXW SRVLELO FRPXQLFDUHD JOREDO GLQWUH UHHOHOH GH FDOFXODWRare. Web-XO UHSUH]LQW XQ VLVWHP GH GLVWULEXLH ORFDO VDX JOREDO D LQIRUPDLLORU hipermedia (Berners-/HH 
  • 24.  'LQ SXQFW GH YHGHUH WHKQLF VSDLXO :HE SXQH OD GLVSR]LLH XQ VLVWHP JOREDO üL VWDQGDUGL]DW GH FRPXQLFare PXOWLPHGLD LQIRUPDLLOH ILLQG RUJDQL]DWH DVRFLDWLY üL GLsWULEXLWH vQ IXQFLH
  • 25. Tehnologii XML12 GH FHUHULOH XWLOL]DWRULORU IXQFLRQkQG FRQIRUP Podelului client/server. Putem vedea Web-XO FD ILLQG XQ XQLYHUV LQIRUPDLRQDO FRPSXV GLQ elemente de interes, denumite resurse, desemnate de identificatori globali GHQXPLL 85, Uniform Resource Identifiers). În cadrul acestui capitol, ne vom concentra mai ales asupra celor mai importante detalii referitoare la protocolul HTTP, una dintre componentele GH ED] DOH VSDLXOXL ::: 2$VSHFWHHVHQLDOHSULYLWRDUHODSURWRFROXO+773 2.1. Preliminarii %D]D FRPXQLFULL GLQWUH VHUYHUHOH üL FOLHQLL :HE OD QLYHO GH DSOLFaLH HVWH DVLJXUDW GH SURWRFROXO HTTP (Hypertext Transfer Protocol), ajuns actu- DOPHQWH OD YHUVLXQHD  üL SUHFL]DW Ge documentul RFC 2616 (Gettys et al., 1999). Protocolul HTTP este folosit în special pentru hipertext, dar poate fi FRQVLGHUDW GUHSW SURWRFRO JHQHULF ED]D FRPXQLFULL vQWU-un sistem GLVWULEXLW GH PDQDJHPHQW DO GDWHORU 2 FDUDFWHULVWLF LPSRUWDQW D protocROXOXL HVWH LQGHSHQGHQD GH SODWIRUP GLIHULWHOH FDOFXODWRDUH FDUH FRPXQLF SULQ +773 SXWkQG IRORVL GLYHrVH VLVWHPH GH RSHUDUH üL DSOLFDLL KLSHUWH[W $FHDVWD VH UHDOL]HD] SULQ QHJRFLHUHD PRGXOXL GH UHSUH]HQWDUH D GDWHORU FDUH XUPHD] D IL WUDQVPLVH üL SULQ FDSDFLWDWHD LPSOHPHQWULORU GH D codifica sau decoGLILFD GDWHOH +773 HVWH IRORVLW vQF GLQ DQXO  GH OD începuturile Web-ului. +773 UHSUH]LQW XQ SURWRFRO JHQHULF SHQWUX WUDQVPLWHUHD LQIRUPDLLORU în format hipertext, el aplicându-VH üL vQWUH XWLOL]DWRU üL Lntermediari pentru alte protocoale mai vechi: SMTP (Simple Mail Transfer Protocol), FTP (File Transfer Protocol) sau NNTP (Network News Transfer Protocol) detalii în Naik, 1998). Fiind un protocol utilizat în Internet, HTTP este bazat pe stiva de protocoale TCP/IP (Transmission Control Protocol/Internet Protocol), putând fi considerat fiabil (reliable). &RQFHSWHüLIXQFLRQDUH 3ULQFLSDOHOH FRQFHSWH FX FDUH OXFUHD] SURWRFROXO VXQW cererea üL UVSXQVXO: un client Web trimite un mesaj (cererea) la un server 0HVDMXO FRQLQH identificatorul resursei dorite, dat sub forma unui URI (Uniform Resource Identifier
  • 26.  PHWRGD GH DFFHV IRORVLW YHUVLXQHD SURWRFoOXOXL SUHFXP üL R serie de meta-LQIRUPDLL FDUH SRW IL XWLOH VHUYeUXOXL 5VSXQVXO VHUYHUXOXi FXSULQGH XQ FRG LQGLFkQG VWDUHD VHUYHUXOXL GXS LQWHUSUHWDUHD FHUHULL XQ
  • 27. Calea de acces la Web 13 mesaj explicativ pentru codul de stare transmis, meta-LQIRUPDLLOH FDUH YRU IL SURFHVDWH GH FWUH FOLHQW üL HYHQWXDO XQ FRQLQXW e.g., UHVXUVD VROLFLWDW
  • 28.  În general, o sesiune GH FRPXQLFDUH +773 HVWH LQLLDW GH FWUH FOLHQW üL FRQVW GLQ FHUHUHD XQHL UHVXUVH LGHQWLILFDWH XQLF SH XQ VHUYHU FXQRVFXW $FHVWD HVWH QXPLW üL server de origine GDWRULW IDSWXOXL F vQ FRPXQLFDUHD vQWUH FOLHQW üL VHUYHU SRW V DSDU XQXO VDX PDL PXOL intermediari: proxy QXPLW üL server proxy), SRDUW (gateway) sau tunel (tunnel): – Proxy-ul este un intermediar care retrimite un mesaj HTTP, eventual modificând o parte a sa. – Poarta UHSUH]LQW XQ Lntermediar care se poate situa înaintea unui server de orLJLQH üL V VH LGHQWLILFH GUHSW DFHVWD FOLHQWXO :HE necunoscând acest aspect. – Tunelul HVWH XQ LQWHUPHGLDU FDUH QX VFKLPE FRQLQXWXO PHVDMXOXL HO are rol exclusiv de retransmitere a lui; de exemplu, tunelul poate fi folosit pentru (de)criptarea mesajeloU YHKLFXODWH vQWUH VHUYHU üL FOLHQW în cadrul unui intranet/extranet. ÍQ FHOH PDL PXOWH GLQWUH FD]XUL vQWUH FOLHQWXO üL VHUYHUXO GH RULJLQH QX H[LVW LQWHUPHGLDUL vQWUH DFHVWHD VWDELOLQGX-VH R FRQH[LXQH GLUHFW D VH YHGHD üL ILJXUD 
  • 29.  Figura 1. Modelul client/server HTTP: FOLHQWXO :HE IRUPXOHD] R FHUHUH GH VROLFLWDUH D XQHL UHVXUVH VWRFDWH SH XQ VHUYHU :HE üL SULPHüWH UVSXQVXO IXUQL]DW GH DFHO VHUYHU De asemenea, un alt concept important este cel de cache, desemnând un depozit local de stocare (în memorie, pe disc) a mesajelor (datelor) la nivel de server/client. Un proxy GHLQH REOLJDWRULX XQ cache ILLQG GHQXPLW üL sistem de cache YH]L üL VHFLXQHD  D FDSLWROuOXL GH ID
  • 30.  Un exemplu tipic de cerere-UVSXQV HVWH XUPWRUXO vQ FDUH FHUHUHD DUH forma:
  • 31. Tehnologii XML14 GET / HTTP/1.1 Host: www.infoiasi.ro User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 Accept: image/gif, image/jpeg, */* Accept-Language: en-us Accept-Encoding: gzip, deflate, compress, identity Connection: Keep-Alive Un pRVLELO UVSXQV DU SXWHD IL FHO GH PDL MRV HTTP/1.1 302 Found Date: Mon, 02 Jan 2006 13:42:40 GMT Server: Apache/2.0.40 (Red Hat Linux) Location: http://www.infoiasi.ro/fcs/index.html Content-Length: 295 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html> <head><title>302 Found</title></head> <body><h1>Found</h1><p>The document has moved <a href="http://www.infoiasi.ro/fcs/index.html"> here</a>.</p> <hr /><address>Apache/2.0.40 Server at www.infoiasi.ro Port 80</address></body> </html> Vom descrie în continuare elementele importante ale protocolului. Adresarea resurselor Web Pentru transferul documentelor hipertext, acestea trebuie adresate într-un mod uniform, independent de sistemul de VWRFDUH üL GH FRQYHQLLOH UHHOHL 0RGDOLWDWHD GH DGUHVDUH IRORVLW SH :HE HVWH UHSUe]HQWDW GH identificatorii uniformi de resurse ± URI (Uniform Resurse Identifiers) (detalii în Berners-Lee, )LHOGLQJ üL 0DVLQWHU 
  • 32. . Ceea ce este deseori denumit adres ::: LGHQWLILFDWRU XQLYHUVDO GH documente sau localizator uniform de resurse este unificat în terminologia Internet într-un singur concept: LGHQWLILFDWRU XQLIRUP GH UHVXUV üL UHSUH]HQWDW într-R IRUP XQLF üL FRQVLVWHQW 0XOLPHD 85, HVWH SDUWLLRQDW vQ GRX VXEPXOLPL LPSRUWDQWH URL (Uniform Resource Locator
  • 33. üL URN (Uniform Resource Name).
  • 34. Calea de acces la Web 15 URL-XO HVWH IRORVLW vQ ORFDOL]DUHD XQHL UHVXUVH vQ UHHD vQ VSHFLDO vQ Internet) prin protoculul HTTP. Sintaxa URL pentru Web este: "http:" "//" server [ ":" port ][ FDOHBDEVROXW [ "?" interogare ]] 'DF QX HVWH VSHFLILFDW H[SOLFLW SRUWXO HVWH FRQVLGHUDW D IL SRUWXO  (portul implicit standard pentru protocolul HTTP). Semantica unui URL HVWH XUPWRDUHD UHVXUVD VH DIO SH XQ VHUYHU LGHQWLILFDW SULQ server, care „asculWµ HYHQWXDOH FHUHUL GH FRQHFWDUH OD SRUWXO VSHFLILFDW VDX LPSOLFLW resursa esWH LGHQWLILFDW SULQ FDOHBDEVROXW ÍQ JHQHUDO WUHEXLH HYLWDW folosirea drept server a adresei IP (e.g., 193.231.30.225) în favoarea folosirii numelui simbolic asociat acesteia (i.e., www.infoiasi.ro). Parametrul FDOHBDEVROXW UHSUH]LQW XQ üLU GH QXPH GH GLUHFWRDUH GHOLPLWDWH GH FDUDFWHUXO ŵ HYHQWXDO WHUPLQDW FX QXPHOH ILüLHUXOXL FDUH VWRFKHD] UHVXUVD DGUHVDW SULQ LQWHUPHGLXO 85/-ului. Componenta interogare desHPQHD] XQ üLU VXSOLPHQWDU LQFOu]kQG LQIRUPDLL LQWHUSUHWDWH GH UHVXUV (de cele mai multe ori, de un script), caracterele „;”, „/”, „?”, „:”, „@”, „&”, Å µ ŵ ŵ üL ŵ ILLQG UH]Hrvate. 7UHEXLH PHQLRQDW IDSWXO F DFHVWH FDUDFWHUH VSHFLDOH VXQW FRGLILcate conform unei metode denumite URL encoding, vQ FDUH FDUDFWHUXO vQ FDX] HVWH VXEVWLWXLW GH FRGXO VX QXPHULF vQ ED]D  SUHIL[DW GH VHPQXO ŵ GH H[HPSOX Åaµ GHYLQH Å(µ
  • 35.  6SDLXO HVWH vQORFXLW FX ŵ Câteva exemple de URL-uri: • http://www.linux.org/ • http://students.infoiasi.ro/~lug/ • http://193.231.30.131/~busaco/ 3UHFL]P IDSWXO F XQ 85/ SRDWH DYHD GUHSW VXIL[ XQ LGHQWLILFDWRU GH IUDJPHQW SUHFHGDW GH FDUDFWHUXO ŵ FX VFRSXO GH D IDFH UHIHULUH GLUHFW OD R SDUWH FRQVWLWXHQW D UHVXUVHL DGUHVDWH de acel URL. Drept exemplificare, se poate da: http://www.sit.ro/buletin.html#a2005. Un URN GHVHPQHD] XQ VXEVHW DO 85, FDUH UPkQH SHUPDQHQW üL XQLF FKLDU GDF UHVXUVD D GLVSUXW RUL D GHYHQLW LQDFFHVLELO 851-ul se XWLOL]HD] PDL DOHV SHQWUX D GHVHPQD HQWLWL WLSXUL GH GDWH VSDLL GH QXPH HWF
  • 36. IRORVLWH GH DQXPLWH DSOLFDLL :HE &D H[HPSOH GH 851-uri putem da: • urn:infoiasi.ro:BookInfo – HVWH VSHFLILFDW GH R DSOLFDLH :HE GHVHPQDW GH GRPHQLXO infoiasi.ro; • urn:mozilla:package:communicator – identific SDFKHWHOH VRIW- ware ale suitei Mozilla; • urn:schemas-microsoft-com:datatypes – GHVHPQHD] WLSXrile de date definite de Microsoft;
  • 37. Tehnologii XML16 • urn:ISBN:973-681-988-4 – VSHFLILF QXPUXO ,6%1 International Standard Book Number) asoFLDW XQHL FUL • urn:ietf:rfc:2401 – VH UHIHU OD LGHQWLILFDUHD XQXL SURWRFRO standardizat de IETF (în cazul acesta, IP Secure). Într-un context mai general, URI-XULOH SRW GHVHPQD UHVXUVH FDUH V SRDW IL DFFHVDWH SULQ LQWHUPHGLXO SURWRFRDOHORU 7&3,3 $VWIHO IRUPD JHQHULF D unui identifiFDWRU XQLIRUP GH UHVXUVH SUH]LQW XUPWRDUHOH FRPSRQHQWH principale: schema "://" autoritate cale "?" interogare Componenta schema LGHQWLILF PRGDOLWDWHD GH LGHQWLILFDUH D SURWRFROXOXL GH WUDQVIHU XWLOL]DW SHQWUX D DYHD DFFHV OD R DQXPLW UHVXUV &HOHODOWe elemente sunt similare celor descrise mai sus. Schemele URI se înre- JLVWUHD] OD ,$1$ Internet Assigned Numbers Authority) – lista schemelor 85, DFWXDOH HVWH GLVSRQLELO OD DGUHVD http://www.iana.org/assignments/ uri-schemes. Ca exemple de scheme se pot enumera: • data:image/png;base64,R101...A7 – schema data SHUPLkQG LQFOXGHUHD vQ PDQLHU inline D XQRU LQIRUPDLL GH PLFL Gimensiuni; DFHDVW WHKQLF VH QXPHüWH üL DGUHVDUH LPHGLDW (Masinter, 1998); VLQWD[D JHQHUDO DUH IRUPD "data:" [ tip_MIME ][ ";base64" ] "," FRQLQXW, în care tip_MIME UHSUH]LQW WLSXO 0,0( DO UHVXUVHL (vezi infra), iar FRQLQXW GHVHPQHD] FRQLQXWXO SURSULX-zis al UHVXUVHL FRGLILFDW EDVH vQ FD]XO vQ FDUH H VSHFLILFDW FODX]D "base64") sau în maniera URL-urilor. Un alt exemplu este data:text/plain;charset=iso-8859-7,%be%fg%be; • file:///tmp/ – VFKHP file FH GHVHPQHD] UHVXUVH GH WLS ILüLHU GLQ cadrul sistemului de stocare de la nivelul clientului; • ftp://ftp.funet.fi/pub/README.txt – VFKHP ftp pentru serviciile protocolului de transfHU GH ILüLHUH )73
  • 38.  • https://www.infoiasi.ro/~busaco/teach/ – VFKHP https pen- tru serviciile protocolului securizat HTTPS (vezi Rescorla, 2000); • mailto:busaco@infoiasi.ro – VFKHP mailto SHQWUX SRüWD HOHFWURQLF VH XWLOL]HD] GH RELFHL SURWRFROXO GH WUDQsfer SMTP); • news:comp.infosystems.www.servers.unix – VFKHP news SHQWUX JUXSXULOH GH üWLUL 86(1(7 1173 – Network News Transport Protocol); • tag:blogger.com,2006:blog-333 – VFKHP tag GHVWLQDW V identifice în mod unic – VSDLDO üL WHPSRUDO – R DQXPLW UHVXUV într-R PDQLHU FRQYHQDELO SHQWUX XWLOL]DWRU vQ DFHVW FD] HVWH YRUED
  • 39. Calea de acces la Web 17 de subiectele de interes ale unui blog
  • 40.  DFHDVW VFKHP DUH VLQWD[D "tag:" autoritate "," GDWDBFDOHQGDULVWLF ":" infor- PDLL ["#" fragm_URI], unde autoritate GHVHPQHD] XQ GRPHQLu '16 VDX R DGUHV GH e-mail, GDWDBFDOHQGDULVWLF VSHFLILF R GDW în forma AAAA-LL-ZZ (doar anul e obligatoriu), iar LQIRUPDLL sunt caractere codificate în stilul URL-XULORU IXQFLRQkQG VLPLODU componentei interogare SUH]HQWDW DQWHULRU GHWDOLL vQ .LQGEHUJ üL Hawke, 2005); • telnet://delta.ac.tuiasi.ro:7777 – VFKHP telnet pentru servicii interactive via protocolul TELNET. 5HODWLY UHFHQW DX IRVW LQVWLWXLL üL LGHQWLILFDWRULL LQWHUQDLRQDOL]DL GH UHVXUVH GHQXPLL ,5, ± Internationalized Resource Identifiers 'UVW üL 6XLJQDUG 
  • 41.  $FHüWLD VXQW FRPSOHPHQWDUL 85,-XULORU SHUPLkQG specificarea unor seturi de caractere mai largi decât ASCII (e.g., Unicode). De exemplu, http://color.org/ros&#xE9 este identic cu URI-ul http://color.org/ros&#233 (folosind eQWLWLOH-caracter permise de HTML/XML) sau http://color.org/ros&#xE9 XWLOL]kQG HQWLWLOH-FDUDFWHU 8QLFRGH GLQ ;0/
  • 42. üL SRDWH IL UHSUH]HQWDW vizual prin http://color.org/rosé ÍQ DFHVW FRQWH[W WUHEXLH PHQLRQDW üL VSHFLILFDLD SULYLWRDUH OD QXPHOH GH GRPHQLL LQWHUQDLRQDOH – IDN (International Domain Names), extinzând sistemul numelor de domenii DNS (Domain Name System). &RGLILFDUHDFRQLQXWXOXL 3HQWUX FD GDWHOH V ILH FRUHFW LQWHUSUHWDWH LQGLIHUHQW GH SODWIRUPD KDUGZDUH üL VRIWZDUH HOH WUHEXLH V UHVSHFWH DFHHDüL FRGLILFDUH SH :HE (VWH GHILQLW conceptul de set de caractere, pentru a putea interpreta corect datele VFKLPEDWH XWLOL]kQG SURWRFROXO +773 vQWUH GRX SODWIRUPH GLIHULWH FX UHSUH]HQWUL GLIHULWH DOH GDWHORU $VWIHO LQIRrPDLD HVWH WUDQVPLV în forma XQXL üLU GH FDUDFWHUH XUPkQG FD HQWLWaWHD GH OD FHOODOW FDSW IRORVLQG LQGLFDLLOH GHVSUH VHWXO GH FDUDFWHUH V UHDOL]H]H WUDQVIRUPDUHD GLQ üLU GH RFWHL vQ üLU GH FDUDFWHUH 6HWXO GH FDUDFWHUH LPSOLFLW HVWH ,62-8859-1, dar H[LVW R PXOWitudine de alte seturi (de exemplu, ISO-8859- GHQXPLW üL Latin- FDUH RIHU SULQWUH DOWHOH üL UHSUezentarea diacriticelor din limba URPkQ
  • 43.  3URWRFROXO +773 UHVSHFW VHWXULOH GH FDUDFWHUH GHILQLWH GH VSHFLILFDLLOH MIME (Multipurpose Internet Mail Extensions) descrise pe larg în GRFXPHQWHOH 5)&  üL  YH]L )UHHG üL %RUHQVWHLQ D üL UHVSHFWLY )UHHG üL %RUHQVWHLQ E
  • 44.  &RQIRUP VWDQGDUGXOXL 0,0( SHQWUX ILHFDUH UHVXUV VH VSHFLILF WLSXO üL VXEWLSXO DFHVWHLD 'H H[HPSOX text/html pentru un document HTML, text/plain în cazul unui document text neformatat,
  • 45. Tehnologii XML18 image/jpeg pentru o imagine în format JPEG, video/mpeg în cazul unui film MPEG, model/vrml SHQWUX R OXPH YLUWXDO PRGHODW vQ 950/ HWF SHQWUX mai multe detalii, vezi Buraga, 2005). De asemenea, PHVDMHOH SRW IL FRGLILFDWH vQ YHGHUHD FRPSULPULL VDX DVL- guUULL LGHQWLWLL üLVDX LQWHJULWLL 'H H[HPSOX VXQW SHUPLVH FRGLILFULOH • gzip – UHSUH]LQW FRGLILFDUHD /HPSHO-=LY /=
  • 46. IRORVLW GH FWUH SURJUDPXO GH DUKLYDUH FX DFHODüL QXPH GLVSRQLELO în mediile UNIX/Linux; • compress – UHSUH]LQW R FRGLILFDUH /HPSHO-Ziv-Welch (LZW) utili- ]DW GH FWUH XWLOLWDUXO GH DUKLYDUH FX DFHODüL QXPH vQWkOQLW SH platformele UNIX. 2.3. Mesajele HTTP &HUHULOH üL UVSXQVXULOH +773 VXQW YHKLFXODWH SULQ LQWHUPHGLXO PHVDjelor. $VWIHO PHVDMHOH +773 VXQW FRQVLGHUDWH GH GRX WLSXUL cerere de la client FWUH VHUYHU üL UVSXQV DO VHUYHUXOXL FWUH FOLHQW (OH UHSUH]LnW HQWLWLOH JHQHULFH GLQ FRPXQLFDUHD +773 XQ PHVDM DYkQG OD SULPD YHGHUH XUP- WRDUHD IRUP Mesaj HTTP = linie_de_start (atribut_de_antet)* CRLF [ FRQinut_mesaj ] Componenta linie_de_start HVWH QXPLW linie de cerere sau linie de stare în FD]XO FHUHULL UHVSHFWLY UVSXQVXOXL 0HWD-caracterul „*” desemQHD] IDSWXO F QXPUXO GH DSDULLL SRDWH IL QXO XQX VDX RULFDUH LDU &5/) UHSUH]LQW VHFYHQD GH FDUDFWHUH Carriage Return FRGXO 
  • 47. üL Line Feed (codul 10). &RQVWUXFLD Å[...]µ LQGLF R DSDULLH RSLRQDO D H[SUHVLHL GLQWUH SDUDQ- tezele drepte. În descrierea de mai sus, atribut_de_antet IRUPHD] SDUWHD GH VWart a PHVDMXOXL DGLF antetul (header
  • 48.  8Q DQWHW FRQLQH PDL PXOWH DWULEXWH FDUH VXQW IRORVLWH OD FRPSOHWDUHD XQHL FHUHUL VDX D XQXL UVSXQV FX PHWD-infor- PDLD QHFHVDU LQWHUSUHWULL FRUHFWH D PHVDMXOXL SULQ VWDEilirea unor valori VSHFLILFDWH GH FWUH SUotocolul HTTP sau a unor protocoale definite de utilizator (de exemplu, SOAP – Simple Object Access Protocol). Fiecare atribut FRQLQXW vQ DQWHW HVWH GH IRUPD Atribut de antet = nume_atribut ":" [ valoare_atribut ] 2UGLQHD DFHVWRUD QX HVWH VHPQLILFDWLY GDU HVWH LQGLFDW V VH WULPLW PDL vQWkL DWULEXWHOH JHQHUDOH IRORVLWH GH RELFHL DWkW SHQWUX FHUHUH FkW üL SHQWUX UVSXQV
  • 49.  DSRL DWULEXWHOH VSHFLILFH WLSXOXL UHVSHFWLY GH PHVDM LDU OD VIkUüLW FHOH VSHFLILFH HQWLWLL FXSULQVH vQ FRQLQXWXO Pesajului.
  • 50. Calea de acces la Web 19 CRUSXO PHVDMXOXL +773 FRQLQH HQWLWDWHD DVRFLDW FHUHULL VDX UVSXQ- sului, de multe ori reprezentând chiar resursa din linia de antet a cererii. &RUSXO XQXL PHVDM SRDWH OLSVL GDF PHWRGD GLQ FHUHUH R Lmpune, el chiar WUHEXLH V OLSVHDVF
  • 51.  3UH]HQD FRUSXOXi mesajului este, de obicei, VHPQDOL]DW SULQ SUH]HnD vQ DQWHWXO +773 D XQRU DWULEXWH UHIHULWRDUH OD acesta: Content-Length sau Transfer-Coding. Lungimea unui mesaj este consi- GHUDW OXQJLPHD vQWUHJXOXL FRUS GXS DSOLFDUHD OD FRQLQXWXO LQLLDO D XQRU eventuale codifiFUL Mesajul de tip cerere (Request) )RUPD JHQHUDO D XQXL PHVDM GH WLS FHUHUH HVWH Cerere HTTP = linie-de-cerere (antet-general | antet-cerere | antet-entitate)* CRLF [ corpul-mesajului ] /LQLD GH FHUHUH GHEXWHD] FX QXPHOH PHWRGHL Iolosite, urmat de LGHQWLILFDWRUXO UHVXUVHL FUHLD L VH DGUHVHD] FHUHUHD 85,
  • 52. üL GH YHUVLXQHD protocolului (e.g., HTTP/1.1). Linie de cerere = PHWRG SP identificator-UHVXUV SP versiune-HTTP CRLF 7UHEXLH SUHFL]DW üL IDSWXO F VHFYHQD &5/) WUHEXLH V DSDU vQ vQWUHJLPH LDU SUH]HQD VHSDUDW D XQXLD GLQWUH RFWHLL UHSUH]HQWkQG &5 VDX LF este inWHU]LV SH SDUFXUVXO OLQLHL GH FHUHUH 63 GHVHPQHD] XQ VSDLX DOE (blank). 0HWRGD FHUHULL HVWH LQGLFDW OD vQFHSXWXO OLQLHL GH FHUHUH üL UHSUH]LQW DFLXQHD FDUH YD IL vQWUHSULQV vQ UDSRUW FX UHVXUVD VSHFLILFDW GH FWUH 85, În general, metoda este case-sensitive GH RELFHL SUHFL]DW FX PDMXVFXOH
  • 53.  SULQWUH FHOH PDL X]XDOH PHWRGH SHUPLVH GH VSHFLILFDLD +773 HQXme- rându-VH *(7 +($' 3267 üL 237,216 *HWWs et al. 
  • 54.  ([LVW GH asemenea, posibilitatea folosirii altor metode, nestandardizate, atât timp cât HOH SRW IL LGHQWLILFDWH GH FWUH WRDWH SULOH FRPXQiFULL &HOH PDL XWLOL]DWH PHWRGH +773 VH EXFXU GH XUPWRDUHOH FDUDFWHULVWLFL • GET – UHSUH]LQW R FHUHUH GH DFFHVDUH D XQRU LQIRUPDLL HQWLWL
  • 55.  8Q FOLHQW +773 QDYLJDWRU URERW SURJUDP GH GHVFUFare, agregator de üWLUL HWF
  • 56. IRORVHüWH PHWRGD *(7 SHQWUX D RELQH R DQXPLW UHVXUV ILH F HD UHSUH]LQW XQ ILüLHU GRFument text, HTML, imagine PNG saX -3(* DSOLFDLH DUKLY GRFXPHQW ;0/ HWF
  • 57.  ILH F LQGLF
  • 58. Tehnologii XML20 H[HFXLD SH VHUYHUXO :HE D XQXL SURFHV FDUH YD SURGXFH GDWHOH dorite (e.g., invocarea unui script CGI); • HEAD – HVWH VLPLODU FX PHWRGD *(7 GDU VHUYHUXO YD UHWXUQD XQ PHVDM DYkQG LQIRUPDLL GRDU în antet. Meta-datele din anteturile +773 GLQ Uspunsul la o cerere HEAD vor fi identice cu cele din UVSXQVXO OD R FHUHUH *(7 8WLOLWDWHD DFHVWHL PHWRGH FRQVW vQ REL- nerea meta-datelor asociate unei resurse Web fU D WUDQVIHUD HIHFWLY întreaga entitate, în vederea – de exemplu – D WHVWULL H[LVWHQHL UHVXUVHL D RELQHULL GDWHL XOWLPHL PRGLILFUL VDX D IXUQL]ULL GUHSWX- rilor de acces; • POST – PHWRGD HVWH XWLOL]DW SHQWUX D LGHQWLILFD GDF VHUYHUXO DFFHSW R HQWLWDWH vQJOREDW vQ FDGUXO FHUHULL 3267 HVWH SURLHFWDW V LPSOHPHQWH]H R PHWRG XQLIRUP SHQWUX IXQFLL SUecum adnotarea UHVXUVHORU WULPLWHUHD GDWHORU XQXL IRUPXODU :HE FWUH VHUYHU extinderea unei baze de date printr-R RSHUDLXQH GH LQVHUDUH HWF • OPTIONS – UHSUH]LQW R FHUHUH GH LQIRUPDLL GHVSUH RSLXQLOH GH FR- municare disponibile într-XQ GLDORJ +773 FHUHUHUVSXQV $FHDVW PHWRG DUH UROXO GH D RIHUL XQXL FOLHQW SRVLELOLWDWHD GH D DFKL]LLona LQIRUPDLL GHVSUH R UHVXUV GH SH XQ VHUYHU VDX FKLDU GHVSUH XQ VHU- ver Web sau server proxy, fU D LPSOLFD R DFLXQH GLUHFW DVXSUD unei resurse (de exemplu, în vederea negocierii transmiterii de date). 8Q H[HPSOX GH OLQLH GH FHUHUH FDUH VH DGUHVHD] XQXL proxy (folosind un 85, GDW vQ IRUPD DEVROXW
  • 59. HVWH XUPWRUXO GET http://students.infoiasi.ro/~revista HTTP/1.1 &HO PDL IUHFYHQW PRG GH D VSHFLILFD R UHVXUV HVWH SULQ FDOHD DEVROXW SkQ OD DFHDVWD DYkQG 85,-ul specificat ca valoare a atributului Host. Un H[HPSOX GH FHUHUH vQ YHGHUHD RELQHUHD UHVXUVHL /pub/index.html de pe VHUYHUXO VWXGHQLORU GH OD )DFXOWDWHD GH ,QIRUPDWLF GLQ ,DüL VH YD IRUPXOD GXS VWDELOLUHD FRQH[LXQLL 7&3 SH SRUWXO  DO PDüLQLL students.infoiasi.ro astfel: GET /pub/index.html HTTP/1.1 Host: students.infoiasi.ro &DOHD DEVROXW QX SRDWH IL YLG HD WUHEXLH V FRQLQ FHO SXLQ Faracterul ŵ FDUH UHSUH]LQW GRFXPHQWXO UGFLQ RULFH GHVFULHUH LQYDOLG D UHVXUVHL ILLQG VHPQDODW SULQWU-XQ FRG GH VWDUH FRUHVSXQ]WRU Pot fi specificate atribute de cerere care sunt folosite pentru a transmite LQIRUPDLL VXSOLPHQWDUH GHVSUH DFHD FHUHUH üL GHVSUH FOLHQW 6H SRDWH IDFH R DQDORJLH vQWUH WULPLWHUHD XQHL PHWRGH +773 FX DSHOXO XQHL IXQFLL GLQWU-un
  • 60. Calea de acces la Web 21 OLPEDM GH SURJUDPDUH XQGH DWULEXWHOH UHSUH]LQW SDUDPHWULL GH LQWUDUH Câteva dintre aceste atribute specifice cererii sunt: Accept, Accept-Encoding, Authorization, From, Host, Proxy-Authorization, Referer sau User-Agent (a se FRQVXOWD üL VHFLXQHD  D FDSLWROXOXL GH ID
  • 61.  0HVDMXOGHWLSUVSXQV Response) 'XS SULPLUHD üL LQWHUSUHWDUHD XQXL PHVDM GH WLS FHUHUH üL LQWHUSUHWDUHD OXL un servHU +773 UVSXQGH FX XQ PHVDM GHQXPLW UVSXQV )RUPD JHQHUDO D acestuia este: 5VSXQV +773 linie-de-stare (antet-general | antet-cerere | antet-entitate)* CRLF [ corpul-mesajului ] Linia de stare începe cu versiunea protocolului HTTP implementat de FWUH VHUYHU üL FRQWLQX FX XQ FRG GH VWDUH UHSUH]HQWkQG QXPUXO DVRFLDW GH FWUH VSHFLILFDLD +773 XQHL DQXPLWH VLWXDLL D VHUYHUuOXL vQ XUPD WUDWULL XQHL FHUHUL 8UPHD] XQ WH[W H[SOLFDWLY SHQWUX FRGXO GH VWDUH FDUH QX WUHEXLH V ILH VWULFW HO SXWkQG IL GHFLV RGDW FX LPSOHPHQWDUHD SURpriu-]LV GDU HVWH LQGLFDW V FODULILFH VLWXDLD HxSULPDW GH FRGXO GH VWDUH Linie-de-stare = versiune-HTTP SP cod-de-stare SP text-explicativ CRLF Cod-de-stare este format din trei cifre organizate în categorii de VWUL DVWIHO vQFkW FRGXULOH GLQ DFHHDüL FDWHJRULH VH UHIHU OD VWUL VLPLODUH HOH VXQW GLVWLQVH GXS SULPD FLIU vQ PRGXO XUPWRU • 1xx: Informativ – FHUHUHD D IRVW SULPLW FRPXQLFDLD FRQWLQX • 2xx: Succes – FHUHUHD D IRVW SULPLW LQWHUSUHWDW üL DFFHSWDW GH FWUH server; • [[ 5HGLUHFLRQDUH – pentru a atinge scopul cererii este nevoie de o inteURJDUH XOWHULRDU HYHQWXDO FWUH XQ DOW VHUYHU • [[ (URDUH SURYRFDW GH FWUH FOLHQW – ILH FHUHUHD HVWH LQFRUHFW GLQ punct de vedere sintactic, fie nu poate IL VDWLVIFXW • [[ (URDUH SURYRFDW GH FWUH VHUYHU – FHUHUHD HVWH DSDUHQW FRUHFW GDU serverul nu o poate îndeplini din diferite motive. 7H[WXO H[SOLFDWLY HVWH LQWURGXV SHQWUX D RIHUL R LQIRUPDLH VXSOLPHQWDU putând fi de folos dezvoltatorilor de apOLFDLL :HE FXP DU IL SURJUDPDUHD OD nivelul serverului HTTP prin diferite tehnologii, precum CGI, PHP sau JSP GHWDOLL vQ *HWWV  üL %XUDJD 
  • 62. 
  • 63. Tehnologii XML22 'H DVHPHQHD SULQ LQWHUPHGLXO DWULEXWHORU VSHFLILFH UVSXQVXULORU +773 VH SRW WUDQVPLWH LQIRUPDLL DGLLRQDOH &kWHYD GLQWUH DWULEXWHOH VSHFLILFH UVSXQVXULORU VXQW XUPWRDUHOH Location, Server sau WWW-Authenticate YH]L VHFLXQHD XUPWRDUH
  • 64.  Jurnalizarea cererilor 8Q H[HPSOX GH ILüLHU GH MXUQDOL]DUH D FHUHULORU +773 HVWH XUPWRUXO vQ acest caz, este voUED GH ILüLHUXO JHQHUDW GH VHUYHUXO $SDFKH
  • 65. YH]L üL %XUDJD üL $FRVWFKLRDLH 
  • 66.  dyn419.win.tue.nl – licenta [29/Sep/2005:11:08:04 +0300] "GET /~busaco/teach/bsc2006/ HTTP/1.1" 200 24757 dyn419.win.tue.nl – – [29/Sep/2005:11:07:54 +0300] "GET /~busaco/teach/bsc2006 HTTP/1.1" 401 1283 193.226.24.219 – – [29/Sep/2005:11:06:17 +0300] "GET / HTTP/1.1" 403 1039 83.115.156.9 – – [29/Sep/2005:11:05:59 +0300] "GET /~busaco/paint/days/trio.jpg HTTP/1.1" 304 – proxy.info.uaic.ro – – [29/Sep/2005:11:05:38 +0300] "GET /favicon.ico HTTP/1.1" 404 1035 rat.cluj.astral.ro – – [29/Sep/2005:11:04:27 +0300] "GET /~linux/ HTTP/1.0" 200 4974 triton.france3.fr – – [29/Sep/2005:11:04:27 +0300] "GET /~acf/ HTTP/1.1" 200 446 triton.france3.fr – – [29/Sep/2005:11:04:27 +0300] "GET /~acf HTTP/1.1" 301 327 crawl.googlebot.com – – [29/Sep/2005:11:03:11 +0300] "GET /~busaco/paint/works/Forms.jpg HTTP/1.1" 304 – 2.4. Atributele HTTP Vom descrie în continuare o serie dintre atributele vehiculate în cadrul cereULORU VDX UVSXQVXULORU +773 Accept (VWH XQ DWULEXW VSHFLILF XQHL FHUHUL +773 üL DUH XQ URO LPSRUWDQW vQ VWDELOLUHD WLSXOXL FRQLQXWXOXL SULQ LQWHUPHGLXO XQHL QHJRFLHUL FRQGXVH GH server. Prin intermediul acestui atribut, clientul are posibilitatea de a sSHFLILFD WLSXULOH PHGLD SH FDUH DFHVWD OH UHFXQRDüWH üL OH SRDWH LQWHUSUHWD VDX SRDWH LQGLFD QXPDL WLSXO GH UVSXQVXUL SUHIHUate. 6LQWD[D HVWH GDW PDL MRV
  • 67. Calea de acces la Web 23 Accept = "Accept" ":" ( tip_media [ parametri ] )* Parametrul tip_media VH UHIHU OD WLSXULOH GH GDWH YHKLFXODWH üL DUH IRUPD tip_media = ("*/*") | (tip "/" "*") | (tip "/" subtip) Componenta parametri are sintaxa: parametri = ";" "q" "=" valoare_calitate (extensie)* Caracterul asterisc „*” este folosit pentru a specifica un grup de tipuri folosind conYHQLLOH 0,0( SUH]HQWDWH PDL VXV Å*/*µ UHSUH]LQW WRDWH tipurile media, iar „tip/*µ GHVHPQHD] WRDWH VXEWLSXULOH 0,0( DOH WLSXOXL VSHFLILFDW GH FRQVWUXFLD tip. Fiecare tip_media poate fi urmat de unul sau PDL PXOL SDUDPHWUL vQFHSkQG FX SDUDPHWUXO Åq” denumit FDOLWDWH UHODWLY (relative quality
  • 68.  FDUH SHUPLWH DVRFLHUHD XQHL FDOLWL UHODWLYH SH R VFDO GH OD 0 la 1 a acestuia. Un exemplu: Accept: image/*; q=0.2, image/jpeg $FHDVW FRQVWUXFLH VSHFLILF SUHIHULQD SHQWUX WLSXO 0,0( image/jpeg, LDU GDF Dcest tip nu este disponibil, atunci se poate returna orice tip de imagine. Allow 6SHFLILF PHWRGHOH +773 SHUPLVH D IL IRORVLWH 'H FHOH PDL PXOWH RUL DSDUH într-XQ UVSXQV FX FRGXO GH VWDUH  Method Not Allowed), indicând FOLHQWXOXL FH PHWRG SRDWH IL XWLOL]DW Authorization 8Q FOLHQW FDUH GRUHüWH V VH DXWHQWLILFH vQ JHQHUDO GXS SULPLUHD XQXL UVSXQV GH WLS  Unauthorized
  • 69.  WUHEXLH V LQFOXG vQ FHUHUH DWULEXWXO Authorization, DYkQG FD YDORDUH LQIRUPDLD QHFHVDU DXWHQWLILFULL ÍQ JHQHUDO GXS FH XQ FOLHQW VH DXWHQWLILF OD XQ VHUYHU üL RELQH DXWRUL]DLLOH QHFHVDUH DFHVWHD DU WUHEXL V ILH YDODELOH üL SHQWUX XUPWRDUHOH FHUHUL QHFHVDUH SDUFXUJHULL XQHL SUH]HQWUL SHQWUX R SHULRDG GH WLPS determinaW Un exemplu efectiv de folosire a metodei de autorizare în cazul VHUYHUXOXL $SDFKH HVWH GLVSRQLELO vQ OXFUULOH %XUDJD  üL %XUDJD üL $FRVWFKLRDLH 
  • 70. Tehnologii XML24 Cache-Control Permite controlul cache-ului, de cele mai multe ori la nivelul proxy-ului GLQWUH FOLHQW üL VHUYHU Sintaxa acestui atribut HVWH XUPWRDUHD Cache-Control = "Cache-Control" ":" (directiva "=" valoare)* Directivele cele mai folosite sunt: • max-age GHVHPQHD] WLPSXO PVXUDW vQ VHFXQGH
  • 71. vQ FDUH VLVWHPXO de cache YD SVWUD R FRSLH D UHVXUVHL :HE • public VSHFLILF IDSWXO F GDWHOH SRW IL VWRFDWH GH FWUH RULFH VLVWHP de cache üL DFFHVDWH IU UHVWULFLL • private VHPQLILF IDSWXO F GDWHOH SRW IL PHPRUDWH GH VLVWHPXO GH FDFKH vQV QX YRU IL SDUWDMDWH DOWRU DSOLFDLL • no-cache VSHFLILF VLVWHPXOXL GH cache V UHvPSURVSWH]H GH ILHFDUH GDW Uesursele solicitate de un client; • no-store LQKLE VWRFDUHD GDWHORU OD QLYHOXO VLVWHPXOXL GH cache RSLXQH IRORVLWRDUH vQ FD]XO WUDQVIHUXOXL GH LQIRUPDLL VHQVLELOH
  • 72.  DFHDVW GLUHFWLY HVWH LJQRUDW GH ,QWHUQHW ([SORUHU GHFL QX SRDWH IL IRORVLW vQ SUDFWLF • must-revalidate VHPQLILF IDSWXO F VLVWHPXO GH cache WUHEXLH V verifice exSLUDUHD GDWHORU GHLQXWH OD ILHFDUH FHUHUH Un exemplu ar putea fi cel de mai jos: Cache-Control: max-age=600, no-cache="Set-Cookie" Connection Este un atribut general fRORVLW SHQWUX D VSHFLILFD DQXPLWH SURSULHWL OHJDWH GH FRQH[LXQH vQ JHQHUDO 7&3,3
  • 73. üL VH DSOLF GRDU FRPuQLFDLHL vQWUH GRX DSOLFDLL +773 GLQ ODQXO XQRU FHUHUL VDX UVSXQVXUL 2 YDORDUH VSHFLILF DFHVWXL DWULEXW HVWH Åcloseµ üL VHPQDOHD] vQFKLGHUHD FRQH[LXQLL GXS WULPLWHUHD PHVDMXOXL $FHVW DWULEXW HVWH XWLO vQ LPSOHPHQ- WDUHD FRQH[LXQLORU SHUVLVWHQWH üL LQGLF ILH F HVWH FXSULQV vQ FHUHUH VDX UVSXQV
  • 74. vQWUHUXSHUHD FRQH[LXQLL GXS vQFKHLHUHD FLFOului cerere-UVSXQV actual. Content-Disposition PerPLWH R DQXPLW IOH[LELOLWDWH vQ WUDQVPLWHUHD XQRU WLSXUL SDUWLFXODUH GH UHSUH]HQWUL GH UHVXUVH &HD PDL XWLOL]DW YDULDQW HVWH FHD vQ FDUH VH VSHFLILF SURJUDPXOXL GH QDYLJDUH V VDOYH]H FD ILüLHU GDWHOH UHFHSLRQDWH în loFXO UHGULL RELüQXLWH FD vQ H[HPSOXO XUPWRU
  • 75. Calea de acces la Web 25 Content-Disposition: attachment; filename="articol.pdf" Content-Type 'HVHPQHD] WLSXO 0,0( DO UHSUH]HQWULL UHVXUVHL VROLFLWDWH GH XQ FOLHQW RUL transmise de server. Acest atribut trebuie specificat obligatoriu în cadrul unui script CGI (Buraga et al., 2002). From &RQLQH R DGUHV GH e-mail vQ JHQHUDO FHD D XWLOL]DWRUXOXL DSOLFDLHL +773 FOLHQW 9DORDUHD DFHVWXL DWULEXW SRDWH IL IRORVLW SHQWUX vQUHJLVWUDUHD DFFHVXOXL vQ ILüLHUHOH-jurnal (log-urile) ale serverului HTTP, în scopul identificULL FHUHULORU LQYDOLGH VDX UHVSLQVH 7ULPLWHUHD DFHVWHL LQIRUPDLL QX HVWH FRQVLGHUDW R SUREOHP GH VHFXULWDWH FL PDL GeJUDE XWLO SHQWUX GH- tecWDUHD FHUHULORU HIHFWXDWH VXE DOW QXPH VDX vQ FD]XO URERLORU :HE SHQWUX SRVLELOLWDWHD FRQWDFWULL SHUVRDQelor resSRQVDELOH OD DSDULLD XQRU DQRPDOLL GH IXQFLRQDUH DOH URERLORU UHspectivi. Host 5HSUH]LQW XQ DWULEXW IRORVLW SHQWUX VSHFLILFDUHD DGUHVHL ,QWHUQHW üL D SRUWXOXL vQ YHGHUHD VWDELOLULL H[DFWH D ORFDLHL XQGH VH DIO UHVXUVD FUHLD L VH DGUHVHD] FHrerea. Acest atribut trebuie inclus în orice cerere HTTP/1.1, WUHEXLH V UHIOHFWH vQWRFPDL LGHQWLWDWHD VHUYHUXOXL-RULJLQH VDX D SRULL indicate în URI-XO RULJLQDO üL DUH UROXO vQGHSUWULL SoVLELOHORU DPELJXLWL Sintaxa acestui atribut este: Host = "Host" ":" URI [ ":" port ] Pentru un URI de genul http://www.infoiasi.ro/fcs.css FHUHUHD WUHEXLH V FRQLQ GET /fcs.css HTTP/1.1 Host: www.infoiasi.ro ÍQ +773 SUH]HQD DWULEXWXOXL Host HVWH REOLJDWRULH FKLDU üL FX R YDORDUH YLG XQ proxy HTTP/1.1 trebuLH V YHULILFH F ILHFDUH FHUHUH LQFOXGH DFHVW DWULEXW 6HUYHUHOH +773 WUHEXLH V UVSXQG GH ILHFDUH GDW FX codul de stare 400 (Bad Request) la cererile HTTP/1.1 care nu includ atributul Host. Location $FHVW DWULEXW VSHFLILF UVSXQVXULORU +773 HVWH XWLOL]DW vQ FRQMXQFLH FX coduri de stare de tip 3xx SULQ FDUH VH LQGLF SURSULHWL DOH OoFDLHL FXUHQWH
  • 76. Tehnologii XML26 a resursei) sau 201 (Created
  • 77.  ÍQ DPEHOH VLWXDLL VH SRDWH VWDELOL ORFDLD FXUHQW VDX SUHIHUDW D UHVXUVHL VXE IRUPD XQXL 85, DEVROXW Sintaxa acestXL DWULEXW HVWH XUPWRDUHD Location = "Location" ":" URI_absolut 8Q H[HPSOX GH UHGLUHFLRQDUH D FOLHQWXOXL browser-ului) Web este: Location: http://www.infoiasi.ro/~busaco/cv.html Referer Prin intermediul acestui atribut, clientul poate specifica, în interesul serverului, URI-XO GH OD FDUH UHVXUVD D IRVW RELQXW 6SUH H[HmSOX GDF într-XQ GRFXPHQW ;+70/ H[LVW R OHJWXU VSUH DOW GRFXPHQW FOLHQWXO poate include în cererea pentru al doilea document, ca Referer, URI-ul prin FDUH D IRVW RELQXW GRFXPHQWXO LQLLDO YH]L üL FHOH GLVFXWDWH vQ FDGUXO VHFLXQLL  D Fapitolului 2). Server &RQLQH LQIRUPDLL GHVSUH DSOLFDLD VHUYHU FXP DU IL QXPHOH YHUVLXQHD SURGXFWRUXO DSOLFDLLOH FRPSDWLELOH (VWH SRVLELO üL DWDüDUHD XQRU LQIRUPDLL üL FRPHQWDULL VSHFLILFH PDL PXOWRU DSOLFDLL FDUH Geservesc cererile la nivelul serverului HTTP (e.g., modulele Apache instalate, VHUYHUHOH GH DSOLFDLL :HE HWF
  • 78.  Un exemplu ar putea fi: Apache/2.0.48 (Win32) mod_perl/1.99_10-dev Perl/v5.8.0 PHP/4.3.4 mod_python/3.0.3 Python/2.2.2 WWW-Authenticate Atributul WWW-Authenticate trebuie inclus în orice cerere 401 (Unautho- rized
  • 79. SHQWUX D RIHUL DSOLFDLHL-XWLOL]DWRU LQIRUPDLL QHFHVDUH DXWHQWLILFrii în UDSRUW FX UHVXUVD FHUXW $WULEXWXO FRPSOHPHQWDU DFHVWXLD SHQWUX FHUHUH este Authorization. O serie de alte atribute sunt descrise în lucrarea Shiflett, 2003. /RFXO+773vQDUKLWHFWXUDVSDLXOXL::: 'XS FXP DP Y]XW OD vQFHSXWXO FDSLWROXOXL :HE-ul este compus din UHVXUVH GLVWULEXLWH SULQFLSDOHOH DVSHFWH FDUH WUHEXLH V ILH DYXWe în vedere fiind identificarea, LQWHUDFLXQHD üL reprezentarea prin diverse formate de date a DFHVWRU UHVXUVH FRQIRUP -DFREV üL :DOVK 
  • 80. 
  • 81. Calea de acces la Web 27 ÍQ FHHD FH SULYHüWH LGHQWLILFDUHD UHVXUVHORU ILHFDUH UHVXUV WUHEXLH V ILH DGUHVDELO )LHFUHL UHVXUVH WUHEXLH V L VH DVRFLH]H XQ 85, GLstinct, evitându-VH DVWIHO DPELJXLWLOH 'HVLJXU ILHFDUH 85, YD DYHD YD IL VWDELOLW de) un proprietar – SHUVRDQ RUJDQL]DLH VSHFLILFDLH WHKQLF HWF &RQVRULXO :HE vQFXUDMHD] IRORVLUHD vQ PDQLHU FRQVLVWHQW D 85,-urilor, pe baza schemelor existente, înregistrate la IANA. De asemenea, trebuie LQXW FRQW GH IDpWXO F QDWXUD XQHL UHVXUVH QX HVWH GDW GH DGUHVD HL FL GH reprezentare – GLQ DFHVW SXQFW GH YHGHUH XQ 85, WUHEXLH V ILH opac. Pentru a identifica în mod indirect o resurV VHFXQGDU ÅOHJDWµ RUL ÅVFXIXQGDWµ
  • 82. vQ UHVXUVD LQLLDO VH SRW XWLOL]D LGHQWLILFatorii de fragment (detalii în Buraga, 2005). $VLJXUDUHD LQWHUDFLXQLL VH UHDOL]HD] SULQ LQWHUPHGLXO XQXL agent Web, FDUH SRDWH IL R SHUVRDQ VDX R DSOLFDLH Voftware ce are acces la Web. 3URJUDPXO DFLRQkQG vQ QXPHOH XQXL XWLOL]DWRU XPDQ SRDUW QXPHOH GH agent-utilizator. Componentele precum serverele, proxy-XULOH URERLL QDYL- gatoarele, player-ele multimedia, programele de oglindire, agregatoarele de üWLUL etc. se numesc DJHQL VRIWZDUH. &RPXQLFDUHD vQWUH DFHüWL DJHQL LPSOLF 85,-uri (pentru adresare), PHVDMH üL D GDWH GLDORJXO GHFXUJkQG FRQIRUP XQRU SURWRFRDOH ,QWHrnet precum HTTP, descris în subcapitolul 2. Structura mesajelor interschimbate depinde de protocol, dar din punct de vedere conceptual putem considera F WRate mesajele sunt compuse din date LQIRUPDLLOH SURSULX-]LVH
  • 83. üL meta-date (date descriind datele vehicuODWH
  • 84.  DFHVWHD GLQ XUP SRW IL specificate de atributele din cadrul anteturilor HTTP. $FFHVXO OD R UHVXUV :HE VH YD UHDOL]D YLD 85, – DFLXQH QXPLW üL GHUHIHUHQLHUH – HYHQWXDO LPSOLFkQG PDL PXOL SDüL GH H[HPSOX vQ VLWXDLD QHJRFLHULL FRQLQXWXOXL
  • 85.  UH]XOWkQG R UHSUH]HQWDUH D UHVXUVHL VROLFLWDWH 2 reprezentare GHQRW GDWHOH FDUH FRGLILF LQIRUPDLD GHVSUH VWDUHD DFWXDO
  • 86. D XQHL UHVXUVH &RQVRULXO :HE UHFRPDQG HYLWDUHD LQFRQVLVWHQHORU GLQWUH GDWHOH UHSUH]HQWULL üL PHWD-date (de exemplu, meta-GDWHOH SRW GHVFULH F UHSUH]HQWDUHD YD IL GLVSRQLELO vQ IRUPDW WH[WXDO GDU vQ UHDOLWDWe clientul UHFHSLRQHD] UHVXUVD UHSUH]HQWDW vQWU-un format binar). Un alt aspect important este cel de asigurare a VLJXUDQHL LQWHUDFLXQLL $VWIHO DJHQWXO FDUH DFFHVHD] R UHVXUV QX WUHEXLH V UHDOL]H]H QLFL R DFLXQH FRODWHUDO side effect) în cadrXO LQWHUDFLXQLL 'H H[Hmplu, la VROLFLWDUHD XQHL UHSUH]HQWUL D UHVXUVHL YLD PHWRGD *(7 D SUotocolului +773 QX WUHEXLH DOWHUDW VWDUHD UHVXUVHL GRULWH i.e., incrementarea unui FRQWRU DO QXPUXOXL GH DFFHVUL DOH XQXL GRFXPHQW
  • 87.  'H DVHPHQHD proprietarul XQXL 85, DU WUHEXL V RIHUH UHSUe]HQWUL DOH UHVXUVHL UHVSHFWLYH într-R PDQLHU FRQVLVWHQW üL SUHGLFWLELO
  • 88. Tehnologii XML28 /D ILQDOXO DFHVWXL FDSLWRO WUHEXLH V SUHFL]P üL F SURWRFROXO +773 MRDF XQ URO LPSRUWDQW vQ FDGUXO DUKLWHFWXULL RULHQWDWH VSUH VHUYLFLL vQ JHne- UDO üL VSUH VHUYLFLLOH :HE vQ VSHFLDO – GHWDOLL vQ FDSLWROXO  DO FULL GH ID 5HIHULQH Berners-Lee, T.; Fielding, R.; Masinter, L., Uniform Resource Identifiers (URI): Generic Syntax, RFC 2396, Internet Engineering Task Force (IETF), 2004: http://www.ietf.org/rfc/rfc2396.txt Bray, T. et al. (eds.), Extensible Markup Language 1.0 (Third Edition), W3C Recommendation, Boston, 2004: http://www.w3.org/TR/REC-xml Buraga, S., Tehnologii Web 0DWUL[ 5RP %XFXUHüWL  http://www.infoiasi.ro/~busaco/ books/web.html Buraga, S. et al., 3URJUDPDUH :HE vQ EDVK üL 3HUO 3ROLURP ,DüL  http://www.infoiasi.ro/ ~cgi/ Buraga, S., Proiectarea siturilor Web HGLLD D GRXD
  • 89.  3ROLURP ,DüL  http:// www.infoiasi.ro/~design/ %XUDJD 6 $FRVWFKLRDLH ' „Administrarea serverelor Web”, NET Report, iulie 2002: http://www.infoiasi.ro/~busaco/publications/articles/admin-web.pdf Dürst, M.; Suignard, M. (eds.), Internationalized Resource Identifiers, RFC 3987, Internet Engineering Task Force (IETF), 2005: http://www.ietf.org/rfc/ rfc2987.txt Freed, N.; Borenstein, N., Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies, RFC 2045, Internet Engineering Task Force (IETF), 1996: http://www.ietf.org/rfc/rfc2045.txt Freed, N.; Borenstein, N., Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types, RFC 2046, Internet Engineering Task Force (IETF), 1996: http://www.ietf.org/rfc/rfc2046.txt Gettys, J. et al., Hypertext Transfer Protocol ± HTTP/1.1, RFC 2616, Internet Engineering Task Force (IETF), 1999: http://www.ietf.org/rfc/rfc2616.txt Jacobs, I.; Walsh, N., Architecture of the World Wide Web, Volume One, W3C Recommendation, Boston, 2004: http://www.w3.org/TR/webarch/ Kindberg, T.; Hawke, S., The ’tag’ URI Scheme, RFC 4151, Internet Engineering Task Force (IETF), 2005: http://rfc4151.x42.com/ Masinter, L., The ’data’ URL scheme, RFC 2397, Internet Engineering Task Force (IETF), 1998: http://www.faqs.org/rfcs/rfc2397.html Naik, D., Internet Standards and Protocols, Microsoft Press, Redmond, 1998 Rescorla, E., HTTP Over TLS, RFC 2818, Internet Engineering Task Force (IETF), 2000: http://www.ietf.org/rfc/rfc2818.txt Shiflett, C., HTTP Developer’s Handbook, Sams Publishing, 2003 * * *, World-Wide Web Consortium, Boston, 2006: http://www.w3.org/
  • 90. Capitolul 2 Modele de date semistructurate. Familia XML „(VHQLDOXO vQ OXPkQDUH QX HVWH FHDUD FH ODV XUPD FL OXPLQD” Antoine de Saint-Exupéry Capitolul expune cele mai importante aspecte privitoare la meta-limbajul XML, oferind o privire de ansamblu asupra tehnologiilor XML în YLJRDUH 6H SUH]LQW PDQLHUHOH GH WUDQVIRUPDUH YDOLGDUH üL LQWHURJDUH a documentelor XML prin intermediul unor limbaje standardizate ca ;3DWK ;6/ ;0/ 6FKHPD 5(/$; 1* üL ;4XHU 'H DVHPHQHD materialul expunH PRGDOLWLOH GH VWRFDUH üL PDQDJHPHQW DO LQIRUPD- LLORU VHPLVWUXFWXUDWH YLD ED]H GH GDWH QDWLYH ;0/ 6XQW H[HPSOLILFDWH üL GLYHUVH OLPEDMH ED]DWH SH ;0/ /D ILQDOXO FDSLWROXOXL VH IDFH R SUH]HQWDUH D üDEORDQHORU GH SURLHFWDUH ;0/ Cuvinte-cheie: date semistructurate, XML, meta-OLPEDM DSOLFDLL ;0/ üDEORDQH VWUXFWXUDOH 1. Introducere 1.1. Formate de date &DSLWROXO GH ID VH FRQFHQWUHD] DVXSUD PRGHOHORU GH UHSUH]HQWDUH D UHVXUVHORU :HE 'DF SHQWUX LGHQWLILFDUH :HE-ul recurge la identificatori uniforPL GH UHVXUVH GHVFULüL vQ FDSLWROXO DQWHULRU LDU SHQWUX LQWHUDFLXQH VH IRORVHüWH vQ PRG X]XDO SURWRFROXO +773 UHSUH]HQWDUHD UHVXUVHORU VH UHDOL]HD] YLD IRUPDWH GH GDWH $UKLWHFWXUD VSDLXOXL ::: vQFXUDMHD] refolosirea formatelor existente, printre aspectele importante legate de aceasta putându-VH HQXPHUD -DFREV üL :DOVK 
  • 91. 
  • 92. Tehnologii XML30 • DGRSWDUHD IRUPDWHORU WH[WXDOH vQ FRQWUDVW FX FHOH ELQDUH YH]L üL %XUDJD  üL %XUDJD 
  • 93.  • FRQWUROXO YHUVLXQLORU R UHVXUV SRDWH HYROXD vQ WLPS DSUkQG necesitatea FXQRDüWHULL LVWRULFXOXL PRGLILFULORU VDOH VDX PLQLPDO data ultimei actuDOL]UL
  • 94.  • H[WHQVLELOLWDWHD PDL DOHV vQ FHHD FH SULYHüWH KLSHUWH[WXO R UHVXUV SRDWH LQFOXGH UHIHULQH üLVDX DOWH WLSXUL GH FRQLQXW PRGDOLWLOH GH extindere fiind, practic, infinite); • FRPSXQHUHD IRUPDWHORU R UHVXUV SRDWH IL UHSUH]HnWDW SULQWU-un format de date care în anumite cirFXPVWDQH IXQFLRQHD] FD XQ FRQWDLQHU DO XQRU IRUPDWH HWHURJHQH ILHFDUH DGUHVDW üL SURFHVDW într-un mod specific – de exemplu, un document poate avea „scufundate” meta-GDWH SULYLWRDUH OD SURSULHWLOH DFHVWXLD SOXV WLSXUL GH FRQLQXW GLYHUVH LPDJLQL YHFWRULDOH VDX UDVWHU OXPL ' expresii matematice etc.); • VHSDUDUHD FRQLQXWXOXL SUH]HQWULL üL LQWHUDFLXQLL DFHVWH WUHL aspecte trebuie pe cât posLELO V ILH WUDWDWH vQWU-R PDQLHU LQGHSHQ- GHQW
  • 95.  'DF SkQ vQ DQLL  FHUFHWULOH V-au axat asupra modului de procesare vQ DFHD SHULRDG LQIRUPDWLFLHQLL DX IRVW SUHRFuSDL PDL DOHV GH WHKQLFLOH GH SURLHFWDUH D DOJRULWPLORU
  • 96.  GDWHOH ILLQG PXOW PDL SXin importante decât codul-VXUV GHFHQLLOH  üL  DOH VHFROXOXL ;; DX FRQGXV OD DSDULLD XQRU IRUPDWH GH GDWH SURSULHWDUH IRORVLWH vQ VSHFLDO GH DSOLFDLLOH GH ELURX GDWHOH ILLQG OD IHO GH LPSRUWDQWH FD üL FRGXO DFHVWD GLQ XUP GH FHOH PDL PXOWH ori, pXWkQG IL FRQFHSXW FKLDU GH XWLOL]DWRU YLD XQRU IDFLOLWL SUHFXP macro-urile). Cu proliferarea serviciilor Internet, mai ales a Web-ului, datele au putut fi publicate liber, folosindu-VH XQ IRUPDW SUH]HQWDLRQDO SXV OD GLVSR]LLH GH +70/ ÍQFHSkQG FX QRXO mileniu, datele sunt considerate PXOW PDL LPSRUWDQWH GHFkW FRGXO 'DFRQWD 2EUVW üL 6PLWK 
  • 97.  DWHQLD F]kQG DVXSUD PRGHOULL FkW PDL HILFLHQWH D LQIRUPDLilor, prin intermediul unui format deschis, extensibil – subiectul acestui capitol. Mai mult decât atât, modelarea datelor nu reIOHFW GRDU VLQWD[D – VSHFLILFDW SULQWU-un set GH FRQYHQLL GH PDUFDUH – FL üL VHPDQWLFD – pâQ DFXP UHSUH]HQWDW GH codul-VXUV DO SURJUDPHORU FH SUelucrau acele date. 1.2. Modele de date 'DF IRUPDWHOH GH GDWH UHIOHFW PDQLHUD HIHFWLY GH VWRFDUH üL SUH]HQWDUH D LQIRUPDLLORU OD QLYHO FRQFHSWXDO WUHEXLH DGRSWDW PFDU XQ PRGHO GH
  • 98. Modele de date semistructurate. Familia XML 31 UHSUH]HQWDUH (YROXLD LQIUDVWUXFWXULL FRPSXWDLRQDOH D FRQGXV üL OD adoptarea unor modele de date diferite. $UKLWHFWXULOH WUDQ]DFLRQDOH DOH anilor ’60-’70 ai secolului trecut se pretau pentru modele de reprezentare ierarhice (arborescente) sau bazate pe grafuri. 2GDW FX DSDULLD vQ DQLL · D UHHOHORU ORFDOH GH FDOFXODWRare, au fost dez- voltate arhitecturi client/server, punctul central fiiQG GHLQXW GH PRGHOHOH relaLRQDOH GH UHSUH]HQWDUH üL VWRFDUH D GDWHORU &OLHQLORU OL VH SHUPLWH LQWHU- SUHWDUHD GDWHORU GHLQXWH OD QLYHO GH VHUYHU vQ GLYHUVH FRPELQDLL JUDLH unui limbaj structurat de interogare (SQL – Structured Query Language), uQRU LQWHUIHH GH SURJUDPDUH D DSOLFDLLORU $3, – Application Programming Interface
  • 99. üL XQRU ÅSXQLµ GH DVLJXUDUH D FRQHFWLYLWLL SUHFXP 2'%& – Open Database Connectivity – sau JDBC – Java Database Connectivity). Apar vQV SUREOHPH SULYLWRDUH OD LQGH[DUH QRUPDOL]DUH LQWHJULWDWH UHIHUHQLDO inclusiv anumite costuri (legate, de exemplu, de optimizare sau denormalizare) (vezi Fotache, 2005). 3UH]HQWXO HVWH ÅJXYHUQDWµ GH DUKLWHFWXULOH QDYLJDLRQDOH ED]DWH SH KLSHUWH[W XWLOL]DWH GH R SOHLDG GH GLVSR]LWLve, inclusiv cele mobile. Daum üL 0HUWHQ 
  • 100. FRQVLGHU F PRGHOHOH GH GDWH FHOH PDL SRWULYLWH VXQW FHOH recurgând la gramaticile regulate (Jucan, 1999). Astfel, trebuie impuse ce- ULQH VXSOLPHQWDUH SHQWUX XQ PRGHO GH GDWH ÅLGHDOµ DOLQLDW GLUHFLLORU actuale de evoOXLH D :HE-ului: • asigurarea accesului la meta-date (datele privitoare la date) – WUHEXLH RIHULWH IDFLOLWL SHQWUX SXEOicarea, generarea (semi-)auto- PDW WUDQVIRUPDUHD vQ DOWH IRUPDWH D PHWD-datelor; • adnotarea resurselor, inclusiv a meta-datelor; • SRVLELOLWDWHD UHDOL]ULL GH LQWHURJUL IOH[LELOH • YHULILFDUHD LQWHJULWLL – FX REVHUYDLD F PHQLQHUHD XQHL LQWHJULWL UHIHUHQLDOH OD QLYHO JOREDO HVWH LPSRVLEiO • IDFLOLWDUHD UHDOL]ULL GH WUDQVIRUPUL DOH GDWHORU FX JHQHUDUHD GH documente prezeQWkQG DOWH VWUXFWXUL ILOWUUL üL LQWHURJUL VLPSOH
  • 101.  • GHSHQGHQD GH FRQWH[WXO SURFHVULL üLVDX DO SUH]HQWrii; • utilizarea de formate standardizate, deschise. 1.3. Date semistructurate ÍQ PRG FODVLF vQDLQWH GH D QH SXQH SUREOHPD VWRFULL HIHFWLYH D GDWHOor în FDGUXO XQHL ED]H GH GDWH WUHEXLH V FRQFHSHP R VFKHP definind structurile SULORU GH LQIRUPDLH SH FDUH GRULP V OH SVWUP ÍQ FD]XO PRGHOXOXL UHODLRQDO DFHDVW VFKHP VSHFLILF QXPUXO üL WLSXO FkPSXULORU GH GDWH
  • 102. Tehnologii XML32 SOXV UHODLLOH FH VH SRW IRUPD vQWUH HOH &RQFHSWXDO VH DSHOHD] OD PRGHOXO entitate-UHODLH (5 – Entity-Relationship
  • 103.  6FKHPD GH]YROWDW HVWH XQD ULJLG, vQ VHQVXO F WRDWH GDWHOH VWRFDWH WUHEXLH V VH FRQIRUPH]H UHVWULFLLORU LPSXVH GH DFHDVWD üL PDL PXOW VFKHPD WUHEXLH SUoiectaW vQDLQWH GH D SRSXOD ED]D GH GDWH FX LQIRUPDLL 6H SHUPLWH DüDGDU VWRFDUHD XQXL YROXP larg de date uniforme VWUXFWXUDWH vQ PDQLHU VLPLODU ([LVW vQV VLWXDLL FkQG DFHDVW DERUGDUH HüXHD] ÍQ VSHFLDO vQ FD]XO Web-XOXL GDWHOH VXQW HWHURJHQH üL SRt proveni din diverse surse. Utili- ]DWRULL SRW V QX DLE LQVWUXLUHD QHFHVDU SUoLHFWULL MXGLFLRDVH D XQHL VFKHPH GH ED]H GH GDWH LDU PXOWH DSOLFDLL PDQLSXOHD] LQIRUPDLL FDUH evoOXHD] vQ WLPS 5H]XPkQG GDWHOH GRULWH D IL PRGHODWH VXQW SUDFWLF QHOL- mitate (unbound
  • 104. üL QHFXQRVFXWH QHH[LVWkQG apriori un vocabular comun. 8Q H[HPSOX HGLILFDWRU GDW GH )ORUHVFX 
  • 105.  HVWH FHO DO FUHULL XQXL GHSR]LW GH UHHWH JDVWURQRPLFH SURYHQLQG GLQ vQWUHDJD OXPH üL LQFOX]kQG üL GHWDOLL GH RUGLQ LVWRULF üL FXOWXUDO UHIHULWRDUH OD SUHJWLUHD GLYHUVHORU IHOXUL GH PkQFDUH 2 DOW H[HPSOLILFDUH DU IL DFHHD D VWRFULL XQHL DQWRORJLL GH SRH]LL 8Q DOW GH]DYDQWDM DO WUDGLLRQDOHORU PRGHOH GH GDWH HVWH F GHVHRUL GDWHOH QX SUH]LQW WUVWXUL DXWRH[SOLFDWLYH self-explanatory
  • 106. üL QX SHUPLW OD SULPD YHGHUH SUHFL]DUHD D FH DQXPH UHSUH]LQW 'H H[HPSOX XQ WXSOX GH IRUPD („Sabin”, „Buraga”, 33), preluat dintr-R WDEHO D XQHL ED]H GH GDWH UHODLR- QDOH QX RIHU SUHD PXOWH LQIRUPDLL SULYLWRDUH OD VHPDQWLFD GDWHORU 3XWHP presuSXQH F SULPHOH GRX HOHPHQWH GHVHPQHD] SUHQXPHOH üL QXPHOH XQHL SHUVRDQH vQV HVWH GLILFLO GH ÅJKLFLWµ FH UHSUH]LQW XOWLPXO QXPU IU D DYHD OD GLVSR]LLH R VFKHP DVRFLDW $U SXWHD IL YRUED GH YkUVW GDU OD IHO GH ELQH GH QXPUXO GH DUWLFROH SXEOLFDWH GH FHD SHUVRDQ OD FRQIHULQH LQWHUQDLRQDOH VDX GH SXQFWDMXO RELQXW OD XQ MRF ÍQ FRQWH[WXO :HE-ului, dateOH DU WUHEXL V ILH DXWRH[SOLFDWLYH PDL DOHV FkQG VXQW LQWHUVFKLPEDWH vQWUH WHUH HQWLWL SHUVRDQH VHUYLFLL VLsWHPH HWF
  • 107. FDUH QX QHDSUDW SDUWDMHD] R VFKHP GH GDWH FoPXQ RUL DFHODüL IRUPDW GH UHSUH]HQWDUH ÍQ FRQWUDVW FX WUDGLLRQDOHOH VLVWHPH GH PDQDJHPHQW DO GDWHORU GDWHOH VHPLVWUXFWXUDWH QX QHFHVLW SUH]HQD XQHL GHIiQLLL D XQHL VFKHPH GH GDWH &RQIRUP $ELWHERXO %XQHPDQ üL 6XFLX 
  • 108.  DFHVWH GDWH DX R VWUXFWXU LQWULQVHF IU D IL VSHFLILFDW VHSDUDW üL vQ DYDQV
  • 109.  vQV QX XQD ULJLG üL QLFL XQD FRPSOHW QHVWUXFWXUDW ÍQ IDSW QX H[LVW R GHILQLLH H[DFW D FHHD FH vQ- VHDPQ GDWH VHPLVWUXFWXUDWH )ORUHVFX 
  • 110. GHVHPQHD] SULQ date VHPLVWUXFWXUDWH DFHOH LQIRUPDLL GLJLWDOH FDUH QX SRW IL PRGHODWH IDFLO üL HILFLHQW FRQIRUP PHWRGRORJLLORU VFKHPHORU üL LQVWUumentelor software WUDGLLRQDOH 0XOWH GLQWUH SUREOHPHOH VXUYHQLWH vQ DFHVW FRQWH[W VXQW FHOH privind nepotrivirile dintre inIRUPDLLOH SH FDUH GRULP V OH PRGHOP üL IDFLOLWLOH RIHULWH GH LQVWUXPHQWHOH DFWXDOH
  • 111. Modele de date semistructurate. Familia XML 33 &HO PDL IUHFYHQW FD] GH H[LVWHQ D GDWHORU VHPLVWUXFWXUDWH HVWH FHO vQ cadrul paginilor Web formate din text scris în limbaj natural. Un mare SURFHQWDM GLQ LQIRUPDLLOH SUH]HQWH SH :HE HVWH FRQLQXW GH GRFXPHQWH vQ formate precum HTML, PDF, JPEG sau Word. Modelul entitate-UHODLH QX HVWH DGHFYDW SHQWUX D PRGHOD OLPEDMXO QDWXUDO RDPHQLL FRPXQLF SULQ intermeGLXO IUD]HORU üL QX D HQWLWLORU üL UHODLLORU GLQWUH HOH Fare, din punct de vedere teoretic, trebuie a priori stabilite). Mai mult, popularele limbaje de specificare a schemelor sunt în general prea simpliste pentru a modela VWUXFWXUL LQIRUPDLRQDOH GLQDPLFH üL WRW PDL FRPSOH[H SH PVXU FH HYR- OXHD] Desigur, OD FHOH GH SUHFL]DWH PDL VXV vQFHS V VH vQWUHYDG VROXLL 3ULPD HVWH IRORVLUHD IDPLOLHL GH OLPEDMH ;0/ 3ULQ PRGDOLWLOH VDOH VLQWDFWLFH OLPEDMXO ;0/ SHUPLWH PRGHODUHD XQXL VSHFWUX ODUJ GH LQIRUPDLL GH OD GDWH complet structurate (e.g. LQIRUPDLL SULYLWRDUH OD FRQWXUL EDQFDUH
  • 112. SkQ OD WH[W vQ OLPEDM QDWXUDO 'XS FXP YRP YHGHD vQ FDGUXO DFHVWXL FDSLWRO GRFXPHQWHOH ;0/ SRW LQFOXGH FRQLQXWXUL PL[WH SRW IL WUDQVIRUPDWH vQ DOWH IRUPDWH üL GH DVHPHQHD SRW IL LQWHUogate. 2. XML pentru reprezentarea datelor semistructurate 2.1. Precursori 3HQWUX vQFHSXW QH YRP SODVD vQ GRPHQLXO UHSUH]HQWULL GRFXPHQWHORU HOHFWURQLFH /D vQFHSXWXUL DFHVWH WLSXUL GH UHVXUVH FRQLQHDX FRGXUL VDX macro-uri care indicau un anumit mod de formatare a documentelor, într-o mDQLHU SDUWLFXODU FRGLILFaUHD VSHFLILF GHSLQ]kQG GH FDUDFWHULVWLFLOH hardware sau ale sistemului de operare). Prin contrast, modul de codificare JHQHULF DSUXW OD VIkUüLWXO DQLORU ·
  • 113. XWLOL]HD] marcatori (tag-uri) des- criptivi pentru specificarea modului de aranjare (structurare) a unui anumit document. Printre susLQWRULL DFHVWHL GLQ XUP PHWRGH V-D QXPUDW üL William Tunnicliffe SUHüHGLQWH DO *&$ Graphic Communications Association), FDUH D GRULW V LPSXQ VHSDUDUHD FRQLQXWXOXL Gocumentelor de formatul lor. Tot la finalul anilor 1960, Stanley Rice propune ideea unui catalog XQLYHUVDO GH PDUFDWRUL SDUDPHWUL]DL SHQWUX VWUXFWuUDUHD HGLWULL GH FDUWH Norman Scharpf GH]YROW DFHDVW LGHH üL DVWIHO HVWH FUHDW GenCode, capabil a recunoaüte ce tipuri GH FRGXUL VXQW QHFHVDUH HGLWULL ILHFUHL FODVH GH GRFXPHQW vQ SDUWH üL Podul de includere a documentelor de dimensiuni reduse în unele mai largi. Acest proiect a jucat ulterior un rol important în dezvoltarea standardului SGML, precursor al limbajului XML.
  • 114. Tehnologii XML34 În 1969, Charles Goldfarb FRQGXFWRU DO SURLHFWXOXL ,%0 GH FHUFHWDUH D VLVWHPHORU LQIRUPDLRQDOH LQWHJUDWH vQ GRPHQLXO OeJLVODWLY vPSUHXQ FX Edward Mosher üL Raymond Lake, invenWHD] GML (Generalized Markup Language) pentru a permite editarea, formataUHD GH WH[WH üL SDUWDMDUHD documentelor în contextul sistemelor distribuite. GML se baza pe ideile de codiILFDUH JHQHULF DOH OXL 5LFH üL 7XQQLFOLIIH üL LQWURGXFHD FRQFHSWXO GH GHILQLUH IRUPDO D WLSXULORU GH GRFXPHQWH prin intermediul unor structuri de elemente recursive. 3UL PDMRUH DOH *0/ DX IRVW LPSOHPHQWDWH vQ VLVWHPHOH GH HGLWDUH FRPSXWHUL]DW SH mainframe-XUL GH FWUH ,%0 üL DOWH FRUSRUDLL *ROGIDUE vüL conWLQX FHUFHWULOH UHIHULQH vQFUXFLüDWH SURFHVDUH vQOQXLW WLSXUL GH documente concureQWH FDUH QX YRU DSUHD vQ *0/ GDU YRU IL GH]YROWDWH FD SUL DOH 6*0/ În 1978, ANSI (American National Standards Institute
  • 115.  SULQ FRPLWHWXO VX GH SURFHVDUH D LQIRUPDLLORU GHVHPQHD] XQ JUXS FDUH V VH RFXSH GH FUHDUHD de limbaje de programare pentru SUHOXFUDUHD HOHFWURQLF D WH[WHORU JUXS condus de Charles Card, avându-O FD PHPEUX SH 1RUPDQ 6FKDUSI üL DSRL cooptându-O üL SH *ROGIDUE 5H]XOWDWXO D IRVW OLPEDMXO 6*0/ D FUXL SUiP SUH]HQWDUH D IRVW H[SXV vQ  'LQ DQXO  *&$ O-a putut recomanda FD VWDQGDUG LQGXVWULDO VXVLQXW GH 0LQLVWHUXO $SUULL DO 6WDWHORU 8QLWH În anul 1984, proiectul a fost autorizat de ISO (International Organization for Standardization
  • 116.  &HUFHWULOH DX FRQWLQXDW vQ FDGUXO FRPLWHWXOXL $16, condus de William Davis, cu VXVLQerea comitetului GenCode al GCA, avându-l la conducere pe Sharon Adler de la IBM. ÍQ DQXO  D IRVW SXEOLFDW SURSXQHUHD FD 6*0/ V GHYLQ VWDQGDUG LQWHUQDLRQDO 7H[WXO ILQDO DO VSHFLILFDLLORU 6*0/ D IRVW DSUREDW üL SXEOLFDW în anul 1986, utilizându-se un sistem SGML dezvoltat la CERN de Anders Berglund – ISO 8879: Information Processing – Text and Office Systems – Standard Generalized Markup Language (Goldfarb, 1990). $SURDSH GH ILQDOXO VHFROXOXL ;; &RQVRULXO :HE D GRULW FUHDUHD XQXL limbaj coPSDWLELO FX 6*0/ GDU FDUH V VH SUHWH]H OD XWLOL]DUHD vQ FDGUXO Web-ului, operându-VH R VHULH GH VLPSOLILFUL üL UH]HFLL DOH VSHFLILFDLHL SGML. În 1998, apare prima recomandare a XML (Extensible Markup Language), actualmente fiind în vigoare XML 1.0 – eGLLD D WUHLD %UD et al., D
  • 117. üL ;0/  %UD et al., 2004b). &RQFHSWHGHED]&DUDFWHUL]DUHüLWUVWXUL 3XWHP FRQVLGHUD ;0/ FD ILLQG XQ VWDQGDUG LQWHUQDLRQDO SHntru descrierea de marcaje (markups) privitoare la resursele electronice. În fapt, XML reprezinW
  • 118. Modele de date semistructurate. Familia XML 35 un meta-OLPEDM GHVFULHUH IRUPDO D XQXL OLPEDM FRQIRUP XQHL JUDPDtici DVRFLDWH
  • 119.  /D vQFHSXW D IRVW Y]XW FD XQ OLPEDM GH DGQRWDUH GH IRUPDtare) GH WH[WH GDU VFRSXULOH DFWXDOH GHSüHVF DFHDVW LQWHUSUHWDUH vQJXsW Termenul marcaj (markup
  • 120. D IRVW XWLOL]DW LQLLDO SHQWUX D GHVFULH DQXPLWH DGQRWUL QRWH PDUJLQDOH vQ FDGUXO XQXL WH[W FX LQWHQLD GH D LQGLFD WHKQR- redactorului cum trebuie listat un anumit pasaj ori chiar omis. Exemple de acest gen ar fi sublinierea unor anumite cuvinte, folosirea anumitor simbo- luri speciaOH OLVWDUHD XQRU SUL GH GRFXPHQW FX XQ FRUS GH OLWHU IRQW
  • 121. VSHFLILFDW HWF &XP IRUPDWDUHD üL LPSULPDUHD WH[WHORU DX IRVW DXWRPDWL]DWH termenul s-a extins pentru a acoperi toate tipurile de coduri de marcare inserate în textele electronice cu scopul de a indica modul de formatare, OLVWDUH RUL DOWH DFiuni. Generalizând, putem defini marcajul sau codarea GUHSW RULFH DFLXQH GH D LQWHUSUHWD H[SOLFLW XQ IUDJPHQW GH GDW /D XQ Qivel superficial, toate textele sunt codDWH HOHPHQWHOH GH SXQFWXDLH IRORVLUHD GH PDMXVFXOH GLVSXQHUHD HQXQXULORU vQ SDJLQ FKLDU üL VSDLLOH GLQWUH FXYLQWH SXWkQG IL SULYLWH GUHSW PDUFDMH &RGLILFDUHD XQXL WH[W SHQWUX SURFHVDUHD FRPSXWHUL]DW SRDWH IL FRQVLGHUDW vQ SULQFLSLX FD R WUDQVFriere a unui manuscris din scriptio continua într-un format special, intern, dictat de utilizator prin folosirea, expliFLW VDX QX D XQRU GLUHFWLYHPDUFDMH FDUH GHILQHVF PRGXO GH LQWHU- SUHWDUH D FRQLQXWXOXL WH[WXOXL 'eVLJXU SXWHP JHQHUDOL]D DFHDVW DFiune OD RULFH WLS GH UHVXUV :HE Printr-un limbaj de specificare vQHOHJHP DVWIHO XQ VHW GH FRQYHQLL GH marcare utilizate pentru codificarea textelor 8Q OLPEDM GH PDUFDUH WUHEXLH V specifiFH PXOLPHD GH PDUFDMH REOLJDWRULL SHUPLVH PDQLHUD GH LGHQWLficare D PDUFDMHORU üL FDUH HVWH VHPDQWLFD ILHFUXL PDUFDM GLVSRQLELO VLPLODU SUR- cesului de speciILFDUH D VLQWD[HL üL VHPDQWLFLL XQXL OLPEDM GH SURJUDPDUH
  • 122.  ([LVW XUPWRDUHOH FDUDFWHULVWLFL GHILQLWRULL DOH ;0/ SULPHOH WUHL PRüWH- nite de la SGML: • utilizarea marcajelor descriptive (descriptive markups) – se folosesc PDUFDMH FDUH RIHU QXPH VSeFLDOH SHQWUX D FODVLILFD SUL GH document (de exemplu, <para> SRDWH LGHQWLILFD R SRULXQH GLQWU-un anumit document, în cazul nostru început de paragraf). Prin contrDVW XQ OLPEDM GH PDUFDUH SURFHGXUDO GHILQHüWH R DFLXQH GH îndeplinit la un moment dat – e.g., move(left_margin, 2cm) ori skip(this.line); • adoptarea tipurilor de documente – 6*0/ LQWURGXFH QRLXQHD GH WLS GH GRFXPHQW üL GH GHILQLLH D WLSXULORU GH GRFXPHnte: DTD – Document Type Definition. Documentele sunt privite ca având tipuri, DüD FXP DX RELHFWHOH SURFHVDWH GH FDOFXODWRDUH 8Q WLS GH GRFXPHQW
  • 123. Tehnologii XML36 HVWH GHILQLW IRUPDO GH SULOH VDOH FRQVWLWXHQWH üL GH VWUXFWXUD ORU 'H H[HPSOX GHILQLLD XQXL UDSRUW SRDWH FRQVWD GLQ WLWOX üL QXPHOH DXWRUXOXL XUPDWH GH XQ UH]XPDW üL GH R VHFYHQ GH PDL PXOWH paragrafe. Documentele având asociat un tip, se poate utiliza un analizor (parser) pentru a le verifica valiGLWDWHD DGLF DSDUWHQHQD OD XQ WLS GH GRFXPHQW üL UHVSHFWDrea elementelor specificate în DTD. $VWIHO GRFXPHQWH GH DFHODüL WLS SRW IL SURFHVDWH vQWU-un mod XQLIRUP 3URJUDPHOH SRW H[SORDWD LQIRUPDLLOH vQFDSVXODWH vQ GHILQLLLOH GH VWUXFWXU DOH GRFXPHnWHORU üL VH SRW FRPSRUWD GHFL într-R PDQLHU ÅLQWHOLJHQWµ 5ecomandarea XML nu impune în mod obligatoriu FD R LQVWDQ GH GRFXPHQW V VH FRQIRrmeze unui tip de document (vezi mai jos); • LQGHSHQGHQD GDWHORU – ;0/ DVLJXU WUDQVODWDUHD GRFXPHQWHORU vQ GLYHUVH IRUPDWH VDX FRGLILFUL GH FDUDFWHUH VH DGRSW VWDQGDUGXO UQLFRGH
  • 124.  ILLQG LQGHSHQGHQW GH SODWIRUPD KDUGZDUHVRIWZDUH üL RIHULQG IDFLOLWL GH H[WLQGHUH D PDUFDMHORU GXS FXP YRP YHGHD un document XML poate include elemente provenite din alt document XML); • case-sensitivity – FRQVWUXFLLOH ;0/ VXQW GHSHQGHQWH GH Faz, literele mici diferind astfel de majuscule. $VWIHO SULQWUH WUVWXULOH FDUH DX IFXW PHWD-OLPEDMXOXL ;0/ V DLE XQ ecou însemnat în industria software, reprezentând o tehnologie sine qua non a prezentului, se pot enumera: • suport acordat Web-ului, priQ IDFLOLWDUHD LPSOHPHQWULORU vQ RULFH limbaje de programare actuale; • IDFLOLWL SHQWUX XWLOL]DUHD LQWHUQDLRQDO VXSRUW SHQWUX 8QLFRGH üL LQGHSHQGHQD GH FRGLILFDUH üL OLmE
  • 125.  • meta-limbaj (se permite definirea de noi limbaje, într-R PDQLHU SRUWDELO
  • 126.  • sROXLH SHQWUX UHSUH]HQWDUHD FRQLQXWXOXL UHVXUVHORU :HE LGHQWL- ficate via URI. &RQFKL]kQG ;0/ UHSUH]LQW R PHWRG GH GHVFULHUH XQLYHUVDO D LQIRUPDLHL DVWIHO vQFkW DWkW FRPSXWHUHOH FkW PDL DOHV RDPHQLL V R SRDW vQelege. Scopurile limbajului sunt cele legate de utilizarea lui în Internet, VXSRUWkQG R YDULHWDWH GH DSOLFDLL SVWUkQG FRPSDWLELOLWDWHD FX YHFKLXO SGML, dar fiind mult mai flexibil decât HTML. Fiind R PHWRG XQLYHUVDO SHQWUX UHSUH]HQWDUHD GHVFULHUHD
  • 127. LQIRUPDLLORU KLSHUWH[W ;0/ SRDWH IL Y]XW FD R WHKQRORJLH FRPSOHPHQWDU OLPEDMului HTML, nu drept o înlocuire a sa.
  • 128. Modele de date semistructurate. Familia XML 37 &RQVWLWXHQL 8Q GRFXPHQW ;0/ SRDWH FXSULQGH XUPWRDUHOH FDWHJRULL GH FRQVWLWXHQL (Bray et al., 2004a): • GHFODUDLD SURORJXO VDX SUHDPEXOXO
  • 129.  • elementele; • atributele; • entitLOH • VHFLXQLOH GH PDUFDUH • LQVWUXFLXQLOH GH SURFHVDUH 'HFODUDLD;0/ 'RFXPHQWHOH ;0/ SRW üL DU WUHEXL V vQFHDS FX R GHFODUDLH SURORJ
  • 130. ;0/ FDUH VSHFLILF YHUVLXQHD OLPEDMXOXL ;0/ XWLOi]DW 'HFODUDLD ;0/ vQFHSH FX <?xml üL VH WHUPLQ FX FDUDFWHUHOH ?> ÍQ FD]XO vQ FDUH H[LVW vQ GRFXPHQW GHFODUDLD ;0/ DFHDVWD WUHEXLH V ILH SULPXO HOHPHQW DO GRFXPHQWXOXL 'HFODUDLD QX SRDWH IL SUHFHGDW GH QLFL XQ DOW HOHPHQW üL WUHEXLH V ILH XQLF ([LVW WUHL DWULEXWH FDUH SRW V DSDU vQ GeFODUDLD ;0/ • version – UHSUH]LQW XQD GLQWUH YHUVLXQLOH FXUHQWH DOH ;0/  VDX 
  • 131.  ÍQ PRG X]XDO GHFODUDLD DUH IRUPD <?xml version="1.0" ?>. 'RFXPHQWHOH vQ D FURU GHFODUDLH H[LVW VSHFLILFDW YHUVLXQHD WUHEXLH V VH FRQIRUPH]H DFHVWHL YHUVLXQL DOWIHO SURFHVRDUHOH ;0L care vor prelucra acele documente vor genera eroare. Conformarea FX YHUVLXQHD VSHFLILFDW vQVHDPQ XWLOL]DUHD FRQVWUXFLLORU GHILQLWH în acea versiune sau în versiunile precedente, dar numai în cazul când este specificat acest aspect. • encoding – atributul poate lua valorile UTF-8, UTF-16, ISO-10646- UCS- VDX RULFH DOWH YDORUL FDUH UHSUH]LQW VXEPXOLPL DOH VHWXOXL 8QLFRGH 'DF VH IRORVHüWH GHQXPLUHD XQHL PXOLPL FDUH QX HVWH GHILQLW GH ,62 DWXQFL WUHEXLH IFXW H[SOLFLW UHIHULUH OD DGUHVD OD care se DIO VSHFLILFDW DFHO VHW GH FDUDFWHUH 'DF VH vQWkOQHüWH vQ WH[W o enWLWDWH FDUH QX SRDWH IL SURFHVDW GLQ FDX]D GHILQLULL JUHüLWH D PXOLPLL GH FDUDFWHUH DWXQFL VH JHQeUHD] R HURDUH IDWDO 6HWXO GH FDUDFWHUH $6&,, HVWH R VXEPXOLPH D VHWXOXL 87)-8. Un exemplu WLSLF GH GHFODUDUH D FRGLILFULL HVWH <?xml version="1.0" encoding="UTF-8" ?>. • standalone – atributul poate lua valorile yes sau no. În GRFXPHQWHOH ;0/ SRW H[LVWD DQXPLWH UHIHULQH VSUH DOWH GRFXPHQWH FDUH V FRQLQ GHILQLLL DOH XQRU PDUFDMH DWULEXWH VDX HQWLWL GLQ
  • 132. Tehnologii XML38 document. Când valoarea este yes DWXQFL UHIHULQHOH VSUH DOWH GRFXPHQWH VXQW SURKLELWH 'DF YDORDUHD HVWH no, atunci este posibil V H[LVWH UeIHULQH VSUH DOWH GRFXPHQWH GDU GDF QX H[LVW DWXQFL folosirea atributului nu are seQV ,PSOLFLW VH FRQVLGHU F XQ GRFXPHQW vQ D FUXL GHFODUDLH QX HVWH VSHFLILFDW DWULEXWXO standalone QX FRQLQH UHIHULQH H[WHrne. Elementele Caracterizare &RPSRQHQWD VWUXFWXUDO XQLWDWHD-text) a unui document XML este elemen- tul. Diferite tipuri de elemente au asociate nume diferite. Fiecare element trebuie specificat explicit prin intermediul marcajelor (tag-urilor). Perechea marcaj de început (start tag) – PDUFDM GH VIkUüLW end tag
  • 133. HVWH IRORVLW OD vQFDGUDUHD ILHFUHL LQVWDQH D HOHPHQWXOXL UHVSHFWiv în cadrul unui text VLPLODU XWLOL]ULL GLIHULWHORU WLSXUL GH SDUDQWH]H RUL VHPQH GH SXQFWXDLH GH H[HPSOX vQ & VHFLXQLOH GH vQFHSXW üL GH VIkUüLW GH EORF GH LQVWUXFLXQL VH scriu între {}, iar în limbajul natural folosim ghilimelele pentru a delimita XQ FLWDW
  • 134.  ÍQ ;0/ VH XWLOL]HD] <element> pentru a specifica un tag de vQFHSXW üL </element> SHQWUX FHO GH VIkUüLW XQGH element este numele unui element oarecare (specificat de utilizator ori de autoritatea care a UHGDFWDW VSHFLILFDLLOH OLPEDMXOXL EDzat pe XML folosit). Între caracterul „<” üL QXPHOH SURSULX-zis al elementuOXL QX VXQW SHUPLVH VSDLLOH DOEH 1XPHOH XQXL HOHPHQW SRDWH IL FRQVWLWXLW GLQ OLWHUH FLIUH üL VHPQHOH X]XDOH (e.g., „_”, „-µ ŵ
  • 135.  WUHEXLQG V vQFHDS FX R OLWHU VDX FX FDUDFWHUul „_”), regulile sintactice fiind similare celor privitoare la identificatorii de variabile. Numele începând cu caracterele „xml” (în orice modalitate de scriere, cu majuscule sau minuscule) sunt rezervate. Numele unui element nu poate conLQH VSDLL DOEH. Modele structurale 8Q HOHPHQW SRDWH IL YLG QX FRQLQH QLPLF vQWUH tag-XULOH GH vQFHSXW üL VIkUüLW
  • 136. VDX SRDWH LQFOXGH XQ WH[W üLU GH FDUDFWHUH
  • 137. RUL DOWH HOHPHQWH 0DL PXOWH HOHPHQWH GH DFHODüL WLS SRW IL DüDGDU LPEULFDWH 8Q DVSHFW GHRVHELW GH important HVWH FHO SULYLWRU OD IDSWXO F HOHPHQWHOH WUHEXLH V ILH vQFKLVH üL imbricate corect. &RQLQXWXO WH[WXDO DO XQXL HOHPHQW SRDWH IL FRPSXV GLQ FDUDFWHUHOH SHUPLVH GH FRGLILFDUHD SUHFL]DW GH DWULEXWXO encoding GLQ GHFODUDLD ;0/ RULFH DSDULLH GH VSDLL DOEH PXOWLSOH ILLQG LPSOLFLW UHGXV OD XQ VLQJXU caracter spaLX
  • 138. Modele de date semistructurate. Familia XML 39 5HODLLOH GLQWUH HOHPHQWHOH ;0/ SRW IL Y]XWH vQ WHUPHQL GH • VHFYHQ – HOHPHQWHOH SRW JHQHUD R VHFYHQ ILHFDUH Sutând avea un „frate” (sibling
  • 139. GHVHPQDW GH XUPWRUXO HOHPHQW VLWXDW OD DFHODüL nivel, neimbricat); • DSDULLH – unele elemente pot fi obligatorii, pe când altele pot avea XQ FDUDFWHU RSLRQDO YH]L infra); • ierarhie – un element inclus în altul se va numi copil, iar elementul plasat la nivelul imediat superior este denumit SULQWH (root); ele- PHQWXO FDUH QX DUH SULQWH HVWH QDWXUDO HOHPHQWXO-UGFLQ ILLQG FHO FDUH JHQHUHD] VWUXFWXUD DUERUHVFHQW DO GRFXPHQWXOXL ;0/ • grupare – mai multe elemente pot fi grupate de un element-SULQWH IXQFLRQkQG FD XQ FRQWDLQHU • incluziune – un element poate include alte elemente; elementele YLGH VXQW GHQXPLWH üL elemente-IUXQ]. 3HQWUX D LOXVWUD PDL GHWDOLDW DFHVW DVSHFW FRQVLGHUP XQ model structural IRDUWH VLPSOX 3UHVXSXQHP F GRULP V LGHQWLIiFP R DQWRORJLH SULQWU-o succesiune de poeme, titlurile lor, versurile din care sunt compuse. În termenii XML, antologie UHSUH]LQW XQ WLS GH GRFXPHQW üL HVWH FRPSXV dintr-o serie de poeme. Fiecare poem vQFDSVXOHD] XQ HOHPHQW titlu (unic) üL FkWHYD DSDULLL GH HOHPHQWH VWURI ILHFDUH VWURI FRQLQkQG XQ QXPU GH elemente vers. Astfel, avem: <antologie> <poem> <titlu>...</titlu> VWURI! <vers>...</vers> <vers>...</vers> ... VWURI! </poem> <poem> ... <!-- mai multe poeme... (acesta e un comentariu) --> </poem> </antologie> (YLGHQW H[HPSOXO GH PDL VXV QX QH SUHFL]HD] DQXPLWH UHJXOL GH FRPSXQHUH D XQHL DQWRORJLL GH H[HPSOX QX SXWHP LPSXQH FD XQ WLWOX V QX DSDU GH PDL PXOWH RUL VDX V ILH SODVDW OD ILQDOXO XQXL SRHP
  • 140.  $üDGDU vom avem nevoie de un mecanism de precizare a structurii.
  • 141. Tehnologii XML40 7RWXüL FKLDU üL OD DFHVW QLYHO GRFXPHQWXO GH WLS DQWRORJLH SRDWH IL procesat în anumite moduri, pentru diverse scopuri. Un program de indexare ar putea extrage doar elemente relevante criteriului ales pentru realizarea inGH[XOXL R OLVW GH WLWOXUL R OLVW D FHORU PDL GHV IRORVLWH FXYLQWH dintr-o poezie. Un program de formatare a textului ar putea insera linii vQWUH ILHFDUH VWURI LDU WLWOXO ILHFUXL SRHP DU SXWHD IL WLSULW vQJURüDW Iolosit XQ FRUS GH OLWHU VSHFLILFDW 8Q SURJUDP PDL DPELLRV SHQWUX DQDOL]D OLQJYLVWLF DVLVWaW GH FDOFXODWRU DU SXWHD GHWHUPLQD PHWULFD üL WLSXO GH ULP DOH ILHFUXL Soem. 0RGHOXO HVWH XQXO VHPLVWUXFWXUDW GHRDUHFH QXPUXO GH VWURIHYHUVXUL nu este a priori cunoscut, în cadrul documentulXL SXWkQG DSUHD üL DOWH FRQVWUXFLL ;0/ FDUH LQLLDO QX HUDX Funoscute. 8Q DOW H[HPSOX VH UHIHU OD PDQLHUD GH VWRFDUH D LQIRUPDLLORU SULYLWRDUH OD DXWRULL OXFUULORU SXEOLFDWH GH R HGLWXU <autori> <autor> <nume>Sabin Buraga</nume> <adresa>http://www.infoiasi.ro/~busaco/</adresa> <varsta /> DILOLHUH!)DFXOWDWHD GH ,QIRUPDWLF GLQ ,DúLDILOLHUH! </autor> <autor> ... </autor> <autor> ... </autor> </autori> 'LQ FHOH GHVFULVH GH H[HPSOXO DQWHULRU REVHUYP IRORVLUHD XQXL HOHPent FX FRQLQXW YLG VFULV <varsta /> sau <varsta></varsta>, ambele variante fiind corecte. Atributele Un atribut HVWH XWLOL]DW FX VFRSXO GH D GHVFULH R DQXPLW SURSULHWDWH D XQHL DSDULLL VSHFLILFH SDUWLFXODUH
  • 142. D XQXL HOHPHQW 3XWHP IDFH R DQDORJLH vQWUH DWULEXWH GHVFULLQG HOHPHQWH
  • 143. üL DGMHFWLYH FDUH GHVFULX VXEVWDQWLYH
  • 144.  Atributele sunt localizate în tag-XO GH VWDUW DO XQXL HOHPHQW LPHGLDW GXS QXPHOH HOHPHQWXOXL DFXP HVWH HYLGHQW GH FH QX SRW H[LVWD VSDLL DOEH vQ numele unui element), sunt urmate de „=”, apoi de valoarea atributului,
  • 145. Modele de date semistructurate. Familia XML 41 VFULV vQWUH JKLOLPHOH VDX DSRVWURIXUL 'DF YDORDUHD XQXL DWULEXW QX HVWH VSHFLILFDW vQWUH JKLOLPHOH YD IL VHPQDODW R HURDUH OD IHO FD üL vQ FD]XO vQ FDUH SHQWUX XQ DWULEXW QX DU IL DWDüDW üL YDORDUHD DFHVWXLD 3Hntru un element pot exista oricâte atribute, specificate în orice ordine, atât timp cât sunt declarate corect. 'H H[HPSOX XQ SDUDJUDI SRDWH DFFHSWD FD DWULEXW RSLRQDO PRGXO GH aliniere (la stânga, la dreapta sau centrat), iar alinieUHD QX VH UHDOL]HD] dHFkW SHQWUX SDUDJUDIXO vQ FDX] üL QX DUH HIHFW DVXSUD FHORUODOWH SDUDJUDIH (context loFDO
  • 146.  1XPHOH DWULEXWHORU VH FRQIRUPHD] DFHORUDüL UHJXOL DSOLFDWH vQ FD]XO HOHPHQWHORU $WULEXWHOH YRU DSUHD GRDU vQ FDGUXO tag-ului de start. Pentru exemplele de mai sus, în cazul antologiei se poate specifica data XOWLPHL DFWXDOL]UL üL FRRUGRQDWRUXO LDU SHQWUX OLVWD DXWRULORU Sutem asocia R DEUHYLHUH RSLRQDO DILOLHULL <antologie coordonator="Sabin Buraga" data="Oct 2006"> ... </antologie> <afiliere abreviere="FII!)DFXOWDWHD GH ,QIRUPDWLF GLQ ,DúLDILOLHUH! Atribute XML predefinite 6SHFLILFDLD ;0/ SXQH OD GLVSR]LLH GRX DWULEXWH SUHGHILQLWH 3ULPXO VH UHIHU OD VSHFLILFDUHD UHJXOLORU SULYLWRDUH OD VSDLLOH DOEH ÍQ PRGHODUHD XQRU GDWH HVWH XQHRUL QHFHVDU DSDULLD VSaLLORU DOEH FRQVWLWXLWH GLQ VSDLL tab-XUL OLQLL YLGH HWF
  • 147.  ÍQ XQHOH FRQWH[WH SURFHVDUHD WUHEXLH V VH UHDOL]H]H FX SVWUDUHD DFHsWRU VSDLL DOEH GH H[HPSOX vQ FD]XO H[SULPULL codului-VXUV VDX vQ FHHD FH SULYHüWH SURGXFLLOH OLULFH
  • 148.  8Q Dtribut special, numit xml:space, poate fi inserat în documente pentru a specifica faptul F vQ FDGUXO HOHPHQWXOXL vQ FDUH DSDUH DFHVW DWULEXW VSDLLOH DOEH V ILH tratate în mod semnificativ. Valorile acestuia pot fi default sau preserve. De exemplu, pentru a specifica un text preformatat am putea scrie: <pre xml:space="preserve">...</pre>. $O GRLOHD DWULEXW VHUYHüWH SHQWUX LGHQWLILFDUHD OLPELL vQ FDUH HVWH SUHFL]DW XQ FRQLQXW WH[WXDO 8Q H[HPSOX HVWH XUPWorul: <p xml:lang="en-GB">Any colour you like</p> <p xml:lang="en-US">Any color you like</p> <quote author="Sainte-Beuve" xml:lang="fr">Il n'y a que de vivre; on voit tout et le contraire de tout.</quote> Suplimentar, prin intermediul atributului xml:id, SUHFL]DW GH VSHFLILFDLD GHVFULV GH 0DUVK 9HLOODUG üL :DOVK 
  • 149.  ILHFUXL HOHPHQW ;0/ L VH SRDWH asociat un identificator unic, servind în principal pentru realizarea de
  • 150. Tehnologii XML42 UHIHULQH ORFDOH VDX H[WHUQH
  • 151. vQWUH IUDJPHQWH GH FRQLQXW 'H H[HPSOX vQ contexWXO ;+70/ SUHFL]P – prin name (din HTML), id (dLQ ;+70/
  • 152. üL xml:id – XQ LGHQWLILFDWRU SHQWUX R OHJWXU LnWHUQ <a xml:id="examen" id="examen" name="examen"></a> ... <a href="#examen">Despre examen</a> 5HIHULQHOHODHQWLWL 5HIHULQHOH OD HQWLWL FRQVWLWXLH GH IDSW SRLQWHUL FWUH HQWLWL ÍQ ;0/ enti- WLOH UHSUH]LQW XQLWL GH WH[W XQGH R XQLWDWH SRDWH GHVHPQD RULFH GH OD XQ VLQJXU FDUDFWHU OD XQ vQWUHJ GRFXPHQW VDX FKLDU R UHIHULQ OD XQ DOW document. 2 UHIHULQ OD R HQWLWDWH SUH]LQW FRQVWUXFLD VLQWDFWLF &nume_entitate; (caracterul „&µ XUPDW GH QXPHOH HQWLWLL DSRL GH FDUDFWHUXO ŵ
  • 153.  8QD GLQWUH FHOH PDL IUHFYHQWH XWLOL]UL DOH UHIHULQHORU OD HQWLWL HVWH DWXQFL FkQG VH GRUHüWH IRORVLUHD XQRU FDUDFWHUH FDUH DU FRQGXFH OD HURUL GH SURFHVDUH üL GHFL FDUH QX DU WUHEXL V DSDU vQ IRUPD ORU QRUPDO vQ WH[W ÍQ PRPHQWXO vQ FDUH VH vQWkOQHüWH UHIHULQD OD R HQWLWDWH vQ GRFXPHQW DFHDVWD VH YD VXEVWLWXL FX GDWHOH SH FDUH OH UHIHU üL VH YD UHWXUQD GRFXPHQWXO FX vQORFXLULOH Icute. 7DEHOXO GH PDL MRV LOXVWUHD] HQWLWLOH SUHGHILQLWH GH VSecifiFDLD ;0/ 7DEHOXO  (QWLWLOH SUHGHILQLWH GH ;0/ %UD et al., 2004a) Entitate 5HIHULQD OD HQWLWDWH < &lt; > &gt; & &amp; ' &apos; " &quot; 6HFLXQLOHGHPDUFDUH 2FD]LRQDO DQXPLWH SUL DOH GRFXPHQWXOXL QHFHVLW XQ WUDWament special în ceea FH SULYHüWH PRGXO GH SURFHVDUH $VWIHO H[LVW SRVLELOLWDWHD IRORVLULL VHFLXQLL &'$7$ character data), cu UROXO GH LQKLEDUH D SUHOXFUULL FRQVWUXFLLORU ;0/ 6HcLXQLOH &'$7$ SRW IL LQVHUDWH RULXQGH SRW DSUHD üL GDWHOH GH WLS FDUDFWHU (OH VXQW XWLOL]ate
  • 154. Modele de date semistructurate. Familia XML 43 SHQWUX D LQFOXGH EORFXUL GH WH[W FRQLQkQG FDUDFWHUH FDUH DOWIHO DU IL recunoscute ca marcaje. Acest aspect devine important atunci când documentul include, de exemplu, linii de cod-VXUV VFULVH vQWU-un limbaj de proJUDPDUH FDUH DUH SURSULLOH FRQYHQLL sintactice. 6LQWD[D JHQHUDO D VHFLXQLL &'$7$ DUH IRUPD <![CDATA[ ... ]]>. În LQWHULRUXO VHFLXQLORU &'$7$ QX WUHEXLH V DSDU üLUXO Å]]µ IU V ILH XUPDW de „>µ 'H DVHPHQHD VHFLXQLOH &'$7$ QX SRW IL LQFOXVH XQHOH vQ DOWHOH Un prim exemplu repreziQW XQ IUDJPHQW GLQ ILüLHUXO inetpref.xml, folosit SHQWUX VSHFLILFDUHD LQWHUIHHL FX XWLOL]DWRUXO D DVLsWHQWXOXL GH FXWDUH Search Companion a resurselor Internet inclus de Windows XP: <Label TopMargin="8" Group="1"> <Text><![CDATA[&Select the default search engine:]]></Text> </Label> ÍQ H[HPSOXO XUPWRU QX GRULP FD SURFHVRUXO ;0/ V LQWHrpreteze codul -DYD6FULSW R FRPSOLFDLH H JHQHUDW GH DSDULLD RSHUDWRUXOXL UeODLRQDO Å!µ
  • 155.  <script type="text/javascript"> /*<![CDATA[*/ if (vizite > 10) { // vizitator fidel document.write ("<p>Salut iar!</p>"); } /*]]>*/ </script> ,QVWUXFLXQLOHGHSURFHVDUH ,QVWUXFLXQLOH GH SURFHVDUH UHSUH]LQW XQ WLS VSHFLDO GH PDrFDM FDUH FRQLQH LQIRUPDLL SULYLWRDUH OD DQXPLWH DSOLFDLL FH XUPHD] D IL H[HFXWDWH SHQWUX procesaUHD FRQLQXWXOXL ,QVWUXFLXQLOH GH SURFHVDUH VXQW SUHIL[DWH GH FRQVWUXFLD Å<?µ XUPDW GH QXPHOH DSOLFDLHL üL GH R VSHFLILFDUH D XQRU GDWH VSHFLILFH DFHOHL DSOLFDLL OD ILQDO Gelimitate de „?>”. 1XPHOH DSOLFDLHL GLQ LQVWUXFLXQHD GH SURFHVDUH WUHEXLH V ILH GLIHULW GH xml, XML sau orice alt mod de a scrie cu litere mari sau mici termenul „xmlµ 'XS FXP VH SRDWH UHPDUFD GHFODUDLD ;0/ HVWH WRW R LQVWUXFLXQH de procesare, fiind utili]DW GH SURFHVRUXO ;0/ În exemplul de mai jos, analizorul XML ar putea invoca interpretorul 3+3 SHQWUX H[HFXLD SURJUDPXOXL VSHFLILFDW vQ FDGUXO XQXL GRFXPHQW <script> <?php echo "<p>Salut!n</p>"; ?> </script>
  • 156. Tehnologii XML44 'H DVHPHQHD YLD LQVWUXFLXQL GH SURFHVDUH VH SRW DVRFLD IRL GH VWLOXUL &66 SHQWUX UHGDUHD FRQLQXWXOXL XQXL GRFXPHQW ;0/ GHWDOLL üL vQ %XUDJD 2001): <?xml:stylesheet type="text/css" href="stil.css" ?> 8UPWRDUHD H[HPSOLILFDUH VSHFLILF PRGXO GH FRQWURO DO JHQHUULL codului-VXUV vQ ;63 Extensible Server Pages) via procesorul Apache Cocoon: <?cocoon-process type="xsp" ?> 8Q XOWLP H[HPSOX VH UHIHU OD IRORVLUHD XQRU GLUHFWLYH GH SURFHVDUH vQ cadrul platformei Adobe XMP (Extensible Metadata Platform): <?xpacket begin='...' id='W5M0MpCehiHzreSzNTczkc9d'?> 2.4. Familia XML /LPEDMXO ;0/ RIHU PDL PXOW GHFkW R VLQWD[ FRPRG SHQWUX UHSUH]HQWDUHD GDWHORU VWUXFWXUDWH VDX VHPLVWUXFWXUDWH ;0/ FRQVW GLQWU-o familie de limbaje bazate pe XML pentru reprezentarea dateORU üL UHODLLORU GLQWUH HOH $FHDVW IDPLOLH GH OLPEDMH PHQLWH D DGDSWD FRQFHSWHOH FXUHQWH GH stocare, modHODUH üL SXEOLFDUH SH :HE D GDWHORU HVWH FRPSXV GLQ • XML (Extensible Markup Language) – VXEVHW DO VSHFLILFDLHL 6*0/ FRQFHSXW SHQWUX R LPSOHPHQWDUH PDL XüRDU %UD et al., 2004a; Bray et al. E %UD +ROODQGHU üL /DPDQ 
  • 157.  0RGDOLWLOH GH validare sunt concretizate de schemele XML, specificate în Fallside üL :DOPVH 
  • 158.  • XLL (Extensible Linking Language) – oferind suport pentru specifi- FDUHD GH OHJWXUL KLSHUWH[W FRQFUHWL]DW vQ GoX FRPSRQHQWH PDMRUH – XLink – conceput pentru descrierea legWXULORU VLPSOH VDX PXOWLSOH
  • 159. GLQWUH UHVXUVHOH :HE 'H5RVH 0DOHU üL 2UFKDG 2001; DeRose et al., 2005); – XPointer – DUH FD VFRS SUHFL]DUHD vQ PDQLHU H[WHQVLELO D unor scheme de adresare a datelor XML (Grosso et al., 2003); • XSL (Extensible Stylesheet Language) – permite transformarea documentelor XML în alte tipuri de documente (XML, XHTML, WML etc.) – YH]L &ODUN 
  • 160. üL .D 
  • 161. – üL DWDüDUHD XQRU obiecte de formatare (Adler et al., 2001; Berlung, 2006), în vederea UHGULL FRQLQXWXOXL ;0/ vQ IRUPDWH precum PDF; • XQuery – vPSUHXQ FX OLPEDMXO ;3DWK &ODUN üL 'H5RVH  Berlung et al. 
  • 162. RIHU SRVLELOLWDWHD LQWHURJULL GRFXPHQWHORU XML (detalii în Boag et al., 2005).
  • 163. Modele de date semistructurate. Familia XML 45 $SOLFDLLüLLQVWUXPHQWH;0/ Practic, este imposibil de enumerat toate limbajele bazate pe XML existente OD RUD DFWXDO VWDQGDUGL]DWH VDX QX 9RP SUH]HQWD SULQFLSDOHOH FDWHJRULL vQVRLWH GH XQHOH H[HPSOH • IRUPDWDUHD FRQLQXWXOXL IRUPDWH GH UHGDUH D GDWelor): – în cadrul navigatorului Web: XHTML (Extensible HTML); – în medii mobiOH IU ILU :0/ Wireless Markup Language); – formulare electronice: XForms; – JUDILF YHFWRULDO 69* Scalable Vector Graphics); – lumi tridimensionale: X3D (Extensible Three Dimensions); • UHSUH]HQWDUHD GLIHULWHORU WLSXUL GH FRQLQXW – expresii matematice: MathML; – FRQLQXW PXOWLPHGLD VLQFURQL]DW 60,/ Synchronized Multimedia Integration Language); – LQIRUPDLL YRFDOH VoiceXML; – FRPSRQHQWH DOH LQWHUIHHL FX XWLOL]DWRUXO ;8/ Extensible User-inter- face Language), XAML (Extensible Application Markup Language); – docXPHQWDLL 'RF%RRN Documentation Book); – reguli de realizare a afacerilor electronice: BRML (Business Rules Markup Language); – VWRFDUHD LQIRUPDLLORU SUHOXFUDWH GH VXLWH GH ELURX e.g., Open- Office): OpenDocument; • descrierea resurselor Web: – cadrul general: RDF (Resource Description Framework); – exprimarea vocabularelor de meta-date: RSS (Really Simple Syndication), Atom, DCMI (Dublin Core Metadata Initiative); – exprimarea de ontologii: OWL (Web Ontology Language); – IDFLOLWDUHD LQWHUVFKLPEXOXL GH VSHFLILFDLL XMI (XML Metadata Interchange format); • descrierea serviciilor Web: – serializarea datelor transmise conform paradigmei RPC (Remote Procedure Call): XML-RPC; – descrierea serviciilor Web: WSDL (Web Service Description Language); – exprimarea protocolului de transfer: SOAP (Simple Object Access Protocol); – H[HFXLD SURFHVHORU GH DIDFHUL %3(/:6 Business Process Execution Language for Web Services).
  • 164. Tehnologii XML46 Numeroase alte limbaje utile sunt descrise în lucrarea lui Geroimenko 
  • 165. VDX SRW IL UHJVite la adresa http://xml.coverpages.org/. Figura 1. Editarea unui document XML cu <oXygen /> ÍQ FHHD FH SULYHüWH WLSXULOH GH LQVWUXPHQWH ;0/ SRW IL DPLQWLWH XUPtoa- rele categorii: • analizoare (procesoare, parsers) XML – e.g., Expat, libxml, MSXML, Xerces; • YL]XDOL]DWRDUH üL HGLWRDUH VWUXFWXUDOH – Firefox, OpenOffice, <R;JHQ! 6WOXV ;0/ 6S ;0/6WDUOHW üL PXlte altele; • formatatoare – FOP, Saxon, Xalan, XEP etc.; • instrumente de convertire/arhivare – e.g., Open SP, Tidy, XMill; • sisteme de gestiune a bazelor de date orientate pe text (native XML sau doar oferind suport pentru XML) – dbXML, eXist, Mark Logic’s CIS, Xindice etc.; • DSOLFDLL KLSHUWH[W – Annotea, Hyperwave; • biblioteci/sisteme de procesare a meta-datelor – Carp and Spiral, 'ULYH1(7 -HQD 5HGODQG üL DOWele; • LQVWUXPHQWH GH PRGHODUH FRQFHSWXDO – pOWL, Protégé, SWOOP etc.; • DSOLFDLL GLQ GRPHQLXO VRFLDO blog-uri, portaluri, wiki-uri, adnota- WRDUH GH FRQLQXW PDQDJHUH GH QRWLH üL DGUHVH SHUVRQDOH HWF
  • 166. – Connotea, del.icio.us, Furl, Spurl.net etc.
  • 167. Modele de date semistructurate. Familia XML 47 2.6. O privire de ansamblu 3HQWUX D vQFKHLD DFHDVW SUH]HQWDUH JHQHUDO D IDPLOLHL ;0/ YRP IDFH R expunere de ansamblu a tehnologiei. ÍQ PVXUD vQ FDUH UHIRORVLUHD LQIRUPDLHL UHSUH]LQW R SUHRFXSDUH LPSRU- WDQW PDL DOHV vQ FRQWH[WXO DVLJXUULL LQWHURSHUDELOLWLL GLQWUH DSOLFDLLOH disponibile pe Web, unul dintre aVSHFWHOH SULPRUGLDOH HVWH FHO DO SURPRYULL unei familii de gramatici înrudite. Puterea meta-limbajului XML este UHIOHFWDW WRFPDL GH IOH[LELOLWDWHD vQ JHVWLRQDUHD GRFXPHQWHORU GH WRDWH WLSXULOH GH OD PDQXDOH üL FRPXQLFDWH GH SUHV SkQ OD FRQWUDFWH OHJDOe, QRWDLL PX]LFDOH üL VSHFLILFDLL GH SURLHFWH üL GH SRVLELOLWDWHD UHXtiOL]ULL DFHVWRUD vQ YHGHUHD SURGXFHULL GH FUL UDSRDUWH üL HGLLL HOHFWURnice (pentru CD-ROM/DVD-520 :HE GLVSR]LWLYH PRELOH HWF
  • 168. SRUQLQG GH OD DFHODüL izvor de resurse originDUH IRORVLQG PDUFDMH GHFODUDWLYH DVHPQWRDUH ([LVW R GLOHP IXQGDPHQWDO vQ SULYLQD RSWULL vQWUH SHUIRUPDQD FRVWXO üL FDSDFLWDWHD GH XWLOL]DUH D VWUDWHJLLORU GH FRGLILFDUH XüRU OL]LELOH GH cWUH FDOFXODWRU üL UHVSHFWLY GH FWUH RP $ERUGDUHD ;0/ VWDELOHüWH XQ HFKLOLEUX UH]RQDELO vQWUH FHOH GRX )DFLOD OL]LELOLWDWH SHQWUX RP LPSOLF UREXVWHH LDU SURFHVDUHD UDSLG GH FWUH PDüLQ LPSOLF YDOLGLWDWH DPEHOH caOLWL DGDXJ YDORDUH LQIRUPDLHL üL IDFLOLWHD] HYROXLD GRFXPHQWHORU vQ WLPS FigurD  7HKQRORJLLOH ;0/ OD FRQIOXHQD D WUHL GRPHQLL DSDUHQW GLVWLQFWH ,QWHUQHWXO SURFHVDUHD GRFXPHQWHORU üL ED]HOH GH GDWH Putem considera familia XML ca reprezentând un punct de vedere unificator al unor tehnologii aparent particulare: Internetul, procesarea FRPSXWHUL]DW D GRFXPHQWHORU üL VWoFDUHD üL SURFHVDUHD WUDGLLRQDOH D datelor.
  • 169. Tehnologii XML48 0RGHOXO ED]DW SH ;0/ VH SUHWHD] SHQWUX VWRFDUHD UHSUH]HQWDUHD
  • 170. GDWHORU VHPLVWUXFWXUDOH 6LVWHPHOH WUDGLLRQDOH Ueprezentate de bazele de GDWH UHODLRQDOH QHFHVLW VSHcificarea unei scheme rigide IRORVLW OD PHPRUDUHD üL DFFHVDUHD GDWHORU 9L]LXQHD DGRSWDW HVWH vQ JHQHUDO XQD FHQWUDOL]DW ÍQ FeHD FH SULYHüWH vQV VSDLXO ::: UHVXUVHOH VXQW descentralizate, cu repre]HQWUL HWHURJHQH üL SRW IL – deseori – accesate (chiDU PRGLILFDWH
  • 171. GH FWUH RULFLQH 0DL PXOW GHFkW DWkW UHVXUVHOH GDWH servicii) disponibile la un moment dat nu sunt a priori cunoscute. Astfel, IDPLOLD ;0/ FRQGXFH OD DSDULLD GH formate orientate pe document, în contrast FX VLWXDLD FODVLF RULHQWDW Se înregistrare (record-oriented). 'UHSW GLUHFLL LPSRUWDQWH SULYLWRDUH OD IRORVLUHD SUDFWLF D IRUPDWHORU ;0/ SXWHP PHQLRQD FRQIRUP 'DXP üL 0HUWHQ 
  • 172. üL 'LFN 
  • 173.  • FRPXQLFDLL üL LQWHUDFLXQH – se au în vedere comuniFDLLOH person-to-person (de exHPSOX VLVWHPXO GH VHUYLFLL FRQYHUVDLRQDOH vQ timp real Jabber are protocolul de transfer al datelor bazat pe XML), person-to-computer (amintim aici formatele de mediatizare – syndication – $WRP üL 566
  • 174. üL GHVLJXU computer-to-computer (drept H[HPSOLILFUL FRQFOXGHQWH VH QXPU VHUYLFLLOH :HE üL VXLWD GH tehnologii AJAX); • arhitecturi orientate spre servicii – OLPEDMHOH ;0/ MRDF XQ URO LPSRUWDQW vQ FHHD FH SULYHüWH DVLJXUaUHD LQWHJUULL vQWUH DSOLFDLL (EAI – Enterprise Application Integration), flexibilLWLL VHFXULWLL HWF • FRQHFWDUHD VODE loose coupling) – proliferarea dispozitivelor mobile, IU ILU FRQGXFH OD UH]ROYDUHD XQRU SUREOHPH SULYLQG GLVSR- QLELOLWDWHD UHVXUVHORU FRPSDWLELOLWDWHD vQWUH DSOLFDLL VDWLVIDFHUHD XQRU SUHIHULQH DOH XWLOL]DWRUXOXL üL DOWHOH FX VROXLL ED]DWH SH ;0/ • FXWDUHD üL UHJVLUHD FXQRüWLQHORU knowledge retrieval) – asocierea de meta-GDWH DGRSWDUHD XQRU PRGDOLWL GH VWUXFWXUDUH D UHVXUVHORU IDFLOLWDUHD QDYLJULL üL PHGLDWL]ULL VH ED]HD] WRDWH SH WHKQROogiile XML; • modelarea proceselor – mai ales procesele de afaFHUL QHFHVLW VWDELOLUHD GH UHJXOL üL VSHFLILFDUHD GH FRQWH[WH SHQWUX IOX[XO GH GDWH (data flow
  • 175. üL GH DFWLYLWL work flow), ce pot fi specificate facil în XML.
  • 176. Modele de date semistructurate. Familia XML 49 &RPSRQHQWHGHED]DOHIDPLOLHL;0/ 6SDLLOHGHQXPH;0/ ÍQ XQHOH VLWXDLL SRW DSUHD FRQIX]LL DWXQFL FkQG VH IRORVHVF GDWH GLQ GLYHUVH VXUVH GRFXPHQWH
  • 177. ;0/ FDUH SRW DYHD HOHPHQWHDWULEXWH FX DFHODüL nuPH GDU FX VHPQLILFDLL VHPDQWLFL
  • 178. GLIHULWH 3HQWUX HYLWDUHD DFHVWRU DPELJXLWL VXQW IRORVLWH VSDLLOH GH QXPH DVWIHO vQFkW QXPHOH GH HOHPHQWH üLVDX DWULEXWH YRU IL LGHQWLILFDWH vQ PRG XQLF HYLWkQGX-se conflictele. 1HFHVLWDWHD IRORVLULL VSDLLORU GH QXPH VH SRDWH UHPDUFD GLQ H[HPSOXO XUPWRU vQ FDUH DYHP GRX GRFXPHQWH ;0/ SULPXO FX LQIRUPDLL GHVSUH partenerii de afaceri, al doilea – despre numele furnizorilor de materii prime: <!-- parteneri de afaceri --> <parteneri> <partener> <nume>Marta Gîrdea</nume> <adresa>...</adresa> </partener> ... </parteneri> <!-- furnizori --> <furnizori> <furnizor adresa="http://www.bizbiz.ro/"> <nume>Biz-Biz</nume> </furnizor> ... </furnizori> 'RFXPHQWXO FDUH OH XWLOL]HD] SH SUHFHGHQWHOH üL IRORVHüWH VSDLL GH QXPH SHQWUX HYLWDUHD DPELJXLWLORU Ånume reprezinW XQ QXPH GH SHUVRDQ VDX XQ QXPH GH FRPSDQLH"µ
  • 179. DU SXWHD IL XUPWRUXO <comanda xmlns:p="http://www.undeva.ro/parteneri/"> <partener> <p:nume>Marta Gîrdea</p:nume> <p:adresa>...</p:adresa> </partener> <f:furnizor xmlns:f="http://www.altundeva.ro/furnizori/"
  • 180. Tehnologii XML50 f:adresa="http://www.bizbiz.ro/"> <nume>Biz-Biz</nume> </f:furnizor> </comanda> &RQIRUP VSHFLILFDLHL %UD +ROODQGHU üL /DPDQ 
  • 181.  DWULEXWXO xmlns HVWH IRORVLW SHQWUX GHFODUDUHD VSDLLORU GH QXPH LDU YDORDUHD OXL WUHEXLH V ILH XQ 85, 3ULQ LQWHUPHGLXO DFHVWHL FRQVWUXFLL VH DVRFLD] XQ vocabular, GHQXPLW üL VSDLX GH QXPH (namespace
  • 182.  SHQWUX HOHPHQWHOH vQ FDX] 'XS FXP VH REVHUY QXPHOH XQXL HOHPHQWDWULEXW HVWH SUecedat de un SUHIL[ DO VSDLXOXL GH QXPH VSHFLILFDW Forma prefix:nume VH QXPHüWH üL nume calificat (qualified name sau QName), numele elementului neputând FRQLQH FDUDFWHUXO ŵ 2 IRUP H[SDQGDW HVWH FHD vQ FDUH SUHIL[XO H substituit de URI-XO VSDLXOXL GH QXPH {http://www.undeva.ro/parteneri/} adresa. SSDLLOH GH QXPH VH GHFODU ILH implicit XQ VSDLX GH QXPH SHQWUX WRDWH elementele domeniului lui de vizibilitate) sau explicit (ca prefix ori substitut SHQWUX QXPHOH FRPSOHW DO XQXL VSDLX GH QXPH
  • 183.  8Q H[HPSOX GH GHFODUDUH LPSOLFLW HVWH XUPWRUXO YL]kQG în acest caz PRGHODUHD LQIRUPDLLORU SULYLWRDUH OD IRQGXO GH FDUWH DO XQHL ELEOLRWHFL <library> <!-- /LVWD FULORU GLQ ELEOLRWHF --> <book xmlns="urn:infoiasi.ro:BookInfo" ident="1"> <title>...</title> <year>...</year> ... </book> ... <!-- Totalul general --> <total>107400</total> </library> Elementele <book>, <title> üL <year> üL DWULEXWXO ident fac parte din VSDLXO GH QXPH BookInfo, DFFHVLELO OD DGUHVD GDW GH 851-ul infoiasi.ro $üD cum am precizat, atributul xmlns este cuvânt-FKHLH ;0/ üL VSHFLILF XQ VSDLX GH QXPH FDUH vQ FD]XO QRVWUX YD IL YL]LELO SkQ OD tag-XO GH VIkUüLW </book> 7RL GHVFHQGHQLL QHFDOLILFDL DL OXL <book> VH FRQVLGHU DSDULQkQG DFHVWXL VSDLX GH QXPH (OHPHQWXO <total> nu face parte din VSDLXO GH QXPe BookInfo. ÍQ H[HPSOXO GH PDL MRV VH GHFODU b ca abreviere pentru numele complet DO VSDLXOXL GH QXPH BookInfo. Toate elemenWHOH üL DWULEXWHOH SUHIL[DWH FX b –
  • 184. Modele de date semistructurate. Familia XML 51 GHQXPLWH üL calificate (qualified) – YRU IL FRQVLGHUDWH FD DSDULQkQG VSDLXOXL de nume BookInfo. <b:book xmlns:b="urn:infoiasi.ro:BookInfo" b:ident="74"> <b:title>Tabloul flamand</b:title> <b:year>2003</b:year> </b:book> 'XS FXP VH SRDWH UHPDUFD DFHDVW GHFODUDUH HVWH XQD HxSOLFLW 1XPHOH GH VSDLL GH QXPH MRDF UROXO GH LGHQWLILFDWRUL XQLFL üL QX WUHEXLH V LGHQWLILFH UHVXUVH GLVSRQLELOH YLD SURWRFRDOHOH ,QWHUQHW 3HQWUX DFHVWHD fie se folosesc URN-XUL DüD FXP DP SURFHGDW vQ H[HPSOXO GH PDL VXV
  • 185.  ILH se recurge în continuare la URL-XUL 3HQWUX DFHVW GLQ XUP FD] &RQVRULXO Web propune un format de genul http://subdomeniu.domeniu.org/concept/ [an/luna][arie], unde „[…]” deVHPQHD] R FRQVWUXFLH RSLRQDO ÍQ FHOH FH XUPHD] YRP IXUQL]D XQ H[HPSOX FRPSOHW vQ FDUH VH YRU IRORVL PDL PXOWH YRFDEXODUH ILHFDUH GHVHPQDW GH XQ VSDLX GH QXPH XML. 'RFXPHQWXO VHUYHüWH SHQWUX VWRFDUHD UH]Xltatelor unui chestionar anonim SULYLWRU OD GHVIüXUDUHD XQXL FXUV VH SRDWH REVHUYD üL XWLOL]DUHD UHIHULQHORU OD HQWLWL SOXV D DWULEXWHORU VSHFLDOH xml:id üL xml:lang). <feedback xmlns="urn:infoiasi.ro:busaco:feedbacks" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" type="results" xml:id="feedback1-2005" version="0.1"> <meta> <author uri="http://www.infoiasi.ro/~busaco/"> Sabin-Corneliu Buraga</author> </meta> <issue xml:id="i2"> <question xml:lang="ro"> Care dintre aspectele propuse spre expunere Y VWkUQHVF FHO PDL PXOW Lnteresul? </question> <response xml:lang="ro"> <rdf:Seq> <rdf:li>Baze de date native XML &amp; XQuery</rdf:li> <rdf:li>Cookie-uri &amp; sesiuni</rdf:li> </rdf:Seq> </response> </issue> <issue xml:id="i3">
  • 186. Tehnologii XML52 <question xml:lang="ro"> &H DOWH VXELHFWH DL GRUL V ILH SUH]HQWDWH" </question> <response xml:lang="ro"> <rdf:Seq> <rdf:li>Tehnologii WAP</rdf:li> UGIOL!$QLPDLL SHQtru Web</rdf:li> <rdf:li>E-business</rdf:li> </rdf:Seq> </response> </issue> </feedback> 2 GLVFXLH SULYLQG VSHFLILFDUHD üL XWLOL]DUHD VSDLLORU GH QXPH HVWH GLVSRQLELO vQ 2EDVDQMR 
  • 187.  3.2. Modelul de date XML: XML Infoset XML nu WUHEXLH FRQVLGHUDW D IL GRDU R PDQLHU GH SUHFL]DUH OD QLYHO VLQWDFWLF D VWUXFWXULL üL FRQLQXWXOXL XQRU UHVXUVH 0DL PXOW GHFkW DWkW OD &RQVRULXO :HE V-a pus problema redactULL XQHL UHFRPDQGUL FDUH V specifice un model de date (abstract) pentru XML. $FHDVW UHFRPDQGDUH este XML Information Set – sau XML Infoset &RZDQ üL 7RELQ 
  • 188.  3ULQ LQWHUPHGLXO DFHVWHL VSHFLILFDLL VH RIHU XQ SXQFW GH YHGHUH FRPXQ referitor la: • serializarea datelor semistructurate (vezi infra); • implementarea/folosirea de inteUIHH GH SURJUDPDUH $3,-uri) pentru procesarea XML; • GHILQLUHD XQRU DOWH UHFRPDQGUL GH QLYHO PDL
  • 189. vQDOW SUHFXP ;3DWK üL ;6/7 YH]L VHFLXQHD 
  • 190. RUL ;0/ 6FKHPD D VH FRQVXOWD VHFLXQHD 3.4). $FHVW PRGHO GH GDWH DVLJXU LQWHURSHUDELOLWDWHD GLIHULWHORU Wehnologii, LQWHUIHH GH SURJUDPDUH üL DSOLFDLL ;0/ VWDELOLQG R LQWHUSUHWDUH FRPXQ D conceptelor folosite. 6XQW GHILQLWH XUPWRDUHOH FRQFHSWH GH ED] – conformându-se paradig- mei obiectuale – vPSUWüLWH GH vntreaga familie XML: • document (document information item) – este considerat a fi un arbore, având nodul-UGFLQ GDW GH SURSULHWDWHD [document element]. 'H DVHPHQHD SRVHG SURSULHWDWHD [children], oferind o serie de
  • 191. Modele de date semistructurate. Familia XML 53 „lucruri” de interes (items
  • 192.  vQ RUGLQHD GDW GH DOJoritmul de parcurgere DFS (Depth First Search); • element – VSHFLILF XQ HOHPHQW ;0/ üL DUH DWDüDW SURSULHWDWHD [parent] FRQLQkQG LQIRUPDLL GHspre elementul-SULQWH FUXLD vL DSDULQH $UH DVRFLDW üL SURSULHWDWHD [children], cu semantica GHVFULV PDL VXV 3URSULHWDWHD [local name] speFLILF QXPHOH ORFDO DO HOHPHQWXOXL DO FUXL VFRS YL]LELOLWaWH
  • 193. H GDW 
  • 194. GH SURprietatea [namespace uri], indicând URI-XO VSDLXOXL GH QXPH IRORVLW YLG GDF QX VH VSHFLILF VSDLL GH QXPH
  • 195.  3UHIL[XO VSDLXOXL GH QXPH utilizat este stocat de proprietatea [prefix] $VWIHO VH G SRVLEL- OLWDWHD SUHFL]ULL FDOLILFDWH D QXPHORU HOHPHntelor. Accesul la lista QHRUGRQDW D DWULEXWHORU DVRFLDWH HOHPHntului se face via pro- prietatea [attributes]. De asemenea, proprietatea [namespace attributes] PHQLRQHD] OLVWD QHRUGRQDW D DWULEXWHORU xmlns DWDüDWH • atribut (attribute) – GHVHPQHD] FRQFHSWXO GH DWULEXW ;0/ 1XPHOH üL VSDLXO GH QXPH DWDüDW VXQW VSHFLILFDWH GH SURSULHWLOH [local name] üL [namespace name] UHVSHFWLY (OHPHQWXO FUXLD vL DSDULQH este indicat de proprietatea [owner element], iar valoarea e spe- FLILFDW GH [normalized value] (valoarea normaOL]DW UH]XOWDW GXS H[SDQGDUHD WXWXURU UHIHULQHORU OD HQWLWL
  • 196.  • caractere (characters) – FRUHVSXQG LQIRUPDLLORU WH[WXDOH DOH FRQLQX- turilor elementelor XML. Proprietatea [parent] LQGLF HOHPHQWXO FUXLD vL DSDULQ LDU [children] FRQLQH GDWHOH-caracter propriu- -zise. Setul de caractere utilizat e oferit de proprietatea [character code] 0RGXO GH SURFHVDUH D VSDLLORU DOEH LQGLFDW GH DWULEXWXO xml:space PHQLRQDW vQ VHFLXQHD 
  • 197. HVWH VSHFLILFDW GH SURprie- WDWHD ERROHDQ [element content whitespace]. 'H DVHPHQHD PDL VXQW LQWURGXVH FRQFHSWH SULYLQG &RZDQ üL 7RELQ 2004): • LQVWUXFLXQLOH GH SURFHVDUH processing instruction information item); • comentariile (comment information item); • GHFODUDLD WLSXOXL GH GRFXPHQW document type declaration item). 'UHSW H[HPSOLILFDUH VSHFLILFP FRQVWUXFLD <antologie xmlns= "http://www.infoiasi.ro/antologii" coordonator="Sabin Buraga" />, creia îi corespunde infoset-ul din figura 3.
  • 198. Tehnologii XML54 Figura 3. Infoset-XO DVRFLDW XQHL FRQVWUXFLL ;0/ ([LVW üL DOWHUQDWLYH OD FHOH GHVFULVH PDL VXV $VWIHO DSDUH SURSXQHUHD Fast Infoset (Sandoz et al. 
  • 199. FDUH VSHFLILF XQ IRUPDW ELQDU SHQWUX ;0/ ,QIRVHW FX VFRSXO XQHL GH
  • 200. VHULDOL]UL üL SURFHVUL PDL UDSLGH üL VWRFULL PDL compacte a datelor XML. 3.3. Transformarea documentelor XML Preliminarii 'LQ FHOH GHVFULVH PDL VXV DP Y]XW F vQ PRG X]XDO XQ GRFXPHQW ;0/ VHSDU FRQLQXWXO GH PDQLHUD GH IRUPDWDUHSURFHVDUH VSHFLILF GHVHRUL XQXL DQXPLW VFRS üLVDX XQHL DSOLFDLL
  • 201. 
  • 202. Modele de date semistructurate. Familia XML 55 Pentru a prezenta – într-R PDQLHU GRULW üL FRPRG – datele XML, WUHEXLH VSHFLILFDW R PRGDOLWDWH GH UHGDUH YLD DüD-numita foaie de stiluri (stylesheet
  • 203.  6ROXLLOH DFWXDOH VXQW GDWH GH GRX GLUHFLL LPSRUWDQWH VWDQdar- GL]DWH GH &RQVRULXO :HE – a se conVXOWD üL WDEHOXO  • CSS (Cascading Style Sheets) – IRORVHVF R VLQWD[ QRQ-;0/ SUH]LQW R IOH[LELOLWDWH OLPLWDW üL QX RIHU R UHGDUH GHSHQGHQW GH FRQWH[W %RV et al., 1998); • XSL (Extensible Stylesheet Language) – adRSW R VLQWa[ ;0/ DX R IOH[LELOLWDWH PDL PDUH LDU SURFHVDUHD VH SRDWH IDFH vQ IXQFLH GH FRQWH[W GH DVHPHQHD VH SRW RSHUD PRGLILFUL GH VWUXFWXU RIH- rindu-VH IDFLOLWL SHQWUX UHDOL]DUHD GH LQWHUoJUL VLPSOH 7DEHOXO  &RPSDUDLH vQWUH ;6/ üL &66 GXS %XUDJD 
  • 204. Caracteristica XSL CSS Comentarii Utilizare cu HTML nu da ;6/ SRDWH IL XWLOL]DW V FRQYHUWHDVF ;0/ vQ ;+70/ ;6/ QX IXQFLR- QHD] SHQWUX GRFXPHnte HTML care QX UHVSHFW VWDQGDUGXO ;+70/ CSS se poate folosi ca modalitate de DWDüDUH Ge stiluri indeSHQGHQW GH documentul HTML. Suport pentru scripting da da ;6/ üL &66 RIHU PHFDQLVPH GH programare a foilor de stiluri via ECMAScript. 6LQWD[ ED]DW SH XML da nu )RLOH &66 QX IRORVHVF R JUDPDWLF XML, pe când XSL este bazat pe XML. $ILüDUHD GH LQIRUPDLL ;0/ da da Se pot asocia unor documente XML sau bazate pe XML. Suport al navigatoarelor SDULDO aproape complet 8QHOH QDYLJDWRDUH RIHU VXSRUW pentru XSL. CSS nivelul 1 este suportat aproape total de naviga- toarele actuale, iar CSS nivelul 2 e VXSRUWDW SDULDO
  • 205. Tehnologii XML56 7UDQVIRUPUL GH VWUXFWXU da nu CSS nu poate modifica structura documentelor, fiind doar o moda- OLWDWH GH D DWDüD VWLOXUL GH IRUPDWDUH D XQRU HOHPHQWH 3HQWUX +70/ VROXLD PRGLILFULORU GH VWUXFWXU HVWH RIHUiW de modelul DOM (via ECMAScript). 7UDQVIRUPUL asupra FRQLQXWXOXL da nu ;6/ SRDWH PRGLILFD üL FRQLQXWXO documentelor XML, într-R PDQLHU ED]DW SH UHJXOL GH UHVFULere, folosind modele/filtre. Manipularea datelor XML (e.g., FXWDUH ILOWUDUH sortare etc.) da nu ;6/ SRDWH IL Y]XW FD OLPEDM VLPSOX de interogare pentru documentele XML. De asemenea, XSL este Turing FRPSOHW GHFL RIHU DFHHDüL H[SUH- sivitate ca un limbaj de programare). &66 QX RIHU QLFL R IDFLOLWDWH vQ DFHVW sens, nefiind limbaj de programare. SWUDWHJLLOH FDUH SRW IL DGRSWDWH VXQW XUPWRDUHOH • o foaie de stiluri, N documente – DFHHDüL IRDLH GH VWiOXUL HVWH DSOLFDW XQXL QXPU GH GRFXPHQWH SVWUkQGX-VH DVWIHO FRQVLVWHQD IRUPD- WXOXL üL PRGXO GH LQWHUDFLXQH look & feel
  • 206.  6H SUHWHD] SHntru situri :HE EURüXUL SUH]HQWUL LQWHUDFWLYH HWF (IRUWXO GH FRQFHSLH H PDL UHGXV IRDLD GH VWLOXUL ILLQG XüRU GH GH]YROWDW DSOLFDW üL FRQWURODW VH DGRSW VWUDWHJLD in house style); • N foi de stiluri, 1 document – VH SHUPLW IRUPDWUL GiIHULWH vQ IXQFLH de medLLOH GH UHGDUH HFUDQ LPSULPDQW HWF
  • 207. VDX GH SUHIHULQH WHP FURPDWLF DUDQMDPHQW VSDLDO HWF
  • 208.  'H DVHPHQHD VH SRW produce facil documente derivate – de exemplu, cataloage, indexuri etc. – YLD LQWHURJUL ÅVODEHµ
  • 209.  VHOHFLL VXPDUL]UL LQGH[UL üL Dltele.
  • 210. Modele de date semistructurate. Familia XML 57 )LJXUD  0RGXO GH WUDQVIRUPDUH D FRQLQXWXOXL ;0/ ([LVW GRX GLUHFLL GH WUDQVIRUPDUH D FRQLQXWXOXL ;0/ 3ULPD GLQWUH HOH UHFXUJH OD ;3DWK üL ;6/7 RIHULQGX-se un limbaj descriptiv bazat pe reguli, LDU D GRXD YL]HD] DWDüDUHD GH SUoSULHWL GH IRUPDWDUH YL]XDO SH ED]D unor obiecte de formatare (formatting objects) – XSL-FO. 7HKQRORJLD ;6/ RIHU XUPWRDUHOH • IRUPDWDUHD ED]DW SH PRüWHQLUH VDX FRQWH[W • FUHDUHD GH FRQVWUXFLL GH IRUPDWDUH LQFOXVLY WH[W üL JUDILF
  • 211.  • definirea de template-uri (macro-uri) de formatare; • LQGHSHQGHQD GH GLUHFLD GH VFULHUH VXSRUW SHQWUX LQWHUQDLRQD- lizare); • SRVLELOLWDWHD XWLOL]ULL XQXL VHW H[WHQVLELO GH RELHFWH GH IRUPDWDUH • SXEOLFDUHD LQGHSHQGHQW GH PHGLL
  • 212. Tehnologii XML58 Principiile de proiectare a limbajului XSL au fost cele legate de suportul SHQWUX DSOLFDLLOH GH QDYLJDUH OLVWDUH üL HGLWDUH LQWHUDFWLY SHQWUX SUH]HQWUL YL]XDOH üL QRQ-vizuale de date, de posibilitatea de extindere cu noi elePHQWH üL GHFODUDLL GH XüXULQD GH SDUFXUJHUH DWkW GLQ SXQFW GH YHGHUH FRPSXWDLRQDO, FkW üL GLQ SXQFW GH YHGHUH XPDQ 3UH]HQWDUHDFRQLQXWXOXL;0/YLDIRLGHVWLOXUL&66 ÍQ FDGUXO DFHVWHL VHFLXQL YRP YHGHD FXP SXWHP UHFXUJH OD SURSULHWLOH CSS (Bos et al. 
  • 213. SHQWUX D UHGD FRQLQXWXO Gocumentelor XML. Vom DWDüD ILüLHUHORU ;0/ IRL GH VWLOXUL &66 SULQ LQWHUPHGLXO LQVWUXFLXQLL GH procesare <?xml-stylesheet ...?>. &RQVLGHUP XQ GRFXPHQW ;0/ FXSULQ]kQG LQIRUPDLL SULYLWRDUH OD PHORGLLOH DVFXOWDWH GH XQ PHORPDQ FUXLD vL YRP DWDüD GRX IRL GH VWLOXUL CSS menite a prezenta datele în cadrul naviJDWRUXOXL :HE FRQIRUP GRX teme cromatice: <?xml-VWOHVKHHW WLWOH 7HPD DOE KUHI PHORGLLFVV type="text/css" ?> <?xml-VWOHVKHHW WLWOH 7HPD QHDJU KUHI PHORGLLFVV type="text/css" alternate="yes" ?> <melodii> <melodie ascultari="33" id="HHPF"> <titlu>High Hopes</titlu> <artist>Pink Floyd</artist> <format>MP3 128kbit/s</format> </melodie> <!-- úL DOWHOH --> </melodii> $GRSWP R IRUPDWDUH WDEHODU D FRQLQXWXOXL R SRVLELO VROXLH ILLQG XUPWRDUHD DP FRQVLGHUDW VSUH H[HPSOLILFDUH IRDLD GH VWLOXUL melodii.css). Codul-VXUV DO FHOXL GH-DO GRLOHD ILüLHU &66 DOWHUQDWLY HVWH VLPLODU melodii { display: table; background-color: white; margin: 1em; padding: 0.2em; } melodie { display: table-row;
  • 214. Modele de date semistructurate. Familia XML 59 font-family: Arial, sans-serif; font-size: 14pt; } melodie[ascultari="33"] { background-color: pink; } titlu, artist, format { display: table-cell; border-bottom-style: dotted; border-bottom-width: 1px; border-bottom-color: gray; text-align: center; } titlu, artist { width: 200px; } titlu:first-letter { color: red; } artist { font-weight: bold; } format { width: 100px; } Dup FXP VH REVHUY ILHFUXL HOHPHQW ;0/ vL VXQW DVRFLDWH GLYHUVH SURSULHWL GH VWLO 3HQWUX HOHPHQWXO <melodie> VWDELOLP XQ VWLO FRQGLLRQDW de valoarea atributului ascultari 0RGDOLWDWHD GH DILüDUH D GDWHORU vQ cadrul browser-XOXL HVWH LOXVWUDW vQ ILJXUD 5.
  • 215. Tehnologii XML60 Figura 5. Prezentarea via foi de stiluri CSS a datelor XML 7UDQVIRUPULYLD;6/7 8UPkQG FHOH SUHFL]DWH GH ;0/ ,QIRVHW SHQWUX HIHFWXDUHD WUDQVIRUPULORU VH FRQVLGHU F GRFXPHQWXO ;0/ HVWH XQ DUERUH IRUPDW GLQ QRGXUL GH diverse tipuri, precum element-UGFLQ HOHPHQWH FRQLQXW WH[WXDO DWULEXWH VSDLL GH QXPH LQVWUXFLXQL GH SURFHVDUH FRPHQWDULL HWF 3HQWUX noduri de tip text, caracteUHOH UH]HUYDWH WUHEXLH UHVFULVH FX HQWLWL )LHFDUH IRDLH GH VWLOXUL ;6/ FRQVW VLPSOLVW YRUELQG GLQ Ueguli compuse dintr-un model (pattern
  • 216. üL R DFLXQH, modelul identificând un nod sau grup GH QRGXUL ;0/ DVXSUD FUXLD VH YD DSOLFD DFLXQHD ([SUHVLLOH PRGHOXOXL VXQW H[SULPDWH vQ OLPEDMXO ;3DWK &ODUN üL 'H5RVH 
  • 217.  LDU DFLXQLOH – WUDQVIRUPULOH HIHFWXDWH DVXSra elementelor documentului – sunt specificate în XSLT (XSL Transformations), descris în Clark (1999). Trans- IRUPULOH VH DSOLF UHFXUVLY WXWXURU QRGXULORU ;0/ FDUH VDWLVIDF PRGH- OXOüDEORDQHOH GH UHJXOL pattern-matching).
  • 218. Modele de date semistructurate. Familia XML 61 Limbajul XPath Vom prezenta în cRQWLQXDUH SULQFLSDOHOH WUVWXUL DOH OLPEDMului XPath. 6FRSXO DFHVWXLD HVWH V DGUHVH]H SUL GLQWU-un document XML, oferind IDFLOLWL GH ED] SHQWUX PDQLSXODUHD XQRU WLSXUL GH GDWH VLPSOH üLUXUL GH caUDFWHUH QXPHUH HWF
  • 219. üL RSHUkQG OD QLYHOXO VWUXFWXULi abstracte a documen- tului XML (i.e., arborele). &RQVWUXFLD IXQGDPHQWDO HVWH H[SUHVLD ;3DWK HYDOXDUHD DFHVWHLD realizându-VH vQ IXQFLH GH FRQWH[W $FHVW FRQWH[W SRate fi desemnat de: • un nod al documentului XML; • SR]LLH • R IXQFLH GH ELEOLRWHF • o declDUDLH D XQXL VSDLX GH QXPH ÍQ XUPD HYDOXULL H[SUHVLHL HVWH vQWRUV XQ RELHFW DGLF • R PXOLPH GH QRGXUL node-set); • R YDORDUH ORJLF true, false); • XQ QXPU float); • XQ üLU GH FDUDFWHUH $VXSUD QRGXULORU SRW IL IRORVLL RSHUDWRULL GHVFULüL PDL MRV • / (descendent) – XWLOL]DW V GHILQHDVF R LHUDUKLH GH HOHPHQWH R FDOH de parcurgere a nodurilor din arborele asociat documentului). Câteva exemple: / üL /cuprins/capitol/autor (a se vedea figura urPWRDUH
  • 220.  Figura 6. Utilizarea operatorului „/”pentru selectarea unui element descendent • // WUDYHUVDUH UHFXUVLY
  • 221. – WUDYHUVHD] vQ DGkQFLPH vQWUHJ sub-arborele unui anumit nod; exemple: //capitol üL //cuprins;
  • 222. Tehnologii XML62 • * (wildcard) – IRORVLW X]XDO SHQWUX HOHPHQWH üL DWULEuWH RIHU WRDWH elementele/atributele de pe un anumit nivel al arborelui; drept H[HPSOLILFDUH IXUQL]P capitol/* üL /cuprins/*/nume; • . (nodul curent) – RSHUDWRU FRQWH[WXDO GHVHPQHD] QRGXO FXUHQW exemple: ./capitol üL ./cuprins/*; • @ (atribut) – XWLOL]DW V VSHFLILFH YDORDUHD XQXL DQXPLW DWULEXW GUHSW H[HPSOLILFUL IXUQL]P //capitol/@nr üL table/@*; • : VSDLX GH QXPH
  • 223. – IRORVLW V VHOHFWH]H HOHPHQWHDWULEXWH SH ED]D XQXL VSDLX GH QXPH – pentru //html:* RELQHP UH]XOWDWXO LOXVWUDW de figura de mai jos; Figura 7. Folosirea operatorilor „//”, „:µ üL „*” • [] (filtru/index) – DSOLF XQ ILOWUX VDX ORFDOL]HD] QRGXULOH SH ED]D unui index (numerotarea începe de la 1); de exemplu, pentru expresia /cuprins/capitol[2] YRP RELQH FHOH GHVFULVH GH ILJXUD  R H[SUHVLH FX DFHODüL UH]XOWDW HVWH //capitol[@nr="3"]);
  • 224. Modele de date semistructurate. Familia XML 63 Figura 8. Filtrarea datelor via operatorul „[]” • : VSDLX GH QXPH
  • 225. – IRORVLW V VHOHFWH]H HOHPHQWHDWULEXWH SH ED]D XQXL VSDLX GH QXPH – pentru //html:* RELQHP UH]XOWDWXO LOXVWUDW de figura 7; 'H DVHPHQHD SHQWUX YDORUL ORJLFH üL vQWUHJL SRW IL XWLOL]DL RSHUDWRULL uzuali: • UHODLRQDOL ÅRUµ ÅDQGµ Å µ Å µ Å µ ŵ Å!µ Å! µ • aritmetici: „+”, „–µ Å µ ÅGLYµ üL ÅPRGµ &RPSDUDLLOH GH üLUXUL GH FDUDFWHUH VH UHDOL]HD] vQ PDQLHU case-sensitive. Alte câteva exemple sunt furnizate în continuare: • table/tr[@align="center" or @valign="top"]/* va selecta elementele dintr-un element <tr> având specificate atributele align="center" sau valign="top" din cadrul unui element <table>; • body[pre != "white"] va selecta toate elementele din cadrul unui element <body> FDUH QX FRQLQ R FRQVWUXFLH GH IRUPD <pre>white</pre>; • carti[@subiect="Web"]/autor[@nume="Sabin"][@adresa="busaco@ infoiasi.ro"] YD IXQFLRQD FD XQ ILOWUX IXUQL]kQG WRDWH HOH- mentele incluse într-un element <carti> care are atributul subiect="Web" üL FDre include sub-elementul <autor> având
  • 226. Tehnologii XML64 specificate atributele nume="Sabin" üL adresa="busaco@ infoiasi.ro". Filtrele vide nu sunt permise (e.g., autor[]); • capitol/nume | capitol/autor va furniza toate elementele <nume> üL <autor>, descendente ale lui <capitol>. /LPEDMXO ;3DWK FODVLILF WLSXULOH GH QRGXUL vQ DüD-numitele axe, dintre FDUH PHQLRQP • axa nodului curent (context node): self; • axa nodului-SULQWH parent; • axa nodurilor-copil: child; • axa nodurilor descendente: descendent; • axa nodurilor de tip atribut: attribute; • D[D QRGXULORU VSDLLORU GH QXPH namespace; • axa nodurilor ascendente: ancestor; • axa nodurilor ascendente, inclusiv nodul curent: ancestor-or- -self; • axa nodurilor descendente, inclusiv nodul curent: descendent-or- -self. Figura 9. Selectarea unor noduri prin intermediul axelor XPath
  • 227. Modele de date semistructurate. Familia XML 65 3HQWUX VSHFLILFDUHD XQHL D[H VH IRORVHüWH RSHUDWRUXO :: precedat de numele axei dorite. Un exemplu este //child::*[@nr > 2] FDUH VHOHFWHD] WRDWH nodurile-copil având valori mai mari decât 2 pentru atributul nr, parcurgându-se recursiv întreg arborele XML (vezi figura 9). ÍQ ORFXO SUHFL]ULL DQXPLWRU D[H VH SRDWH UHFXUJH OD VLQWD[D SUHVFXUWDW Astfel, self se poate substitui cu „.”, parent cu „..”, attribute cu „@µ üL namespace prin „:”. 6SHFLILFDLD ;3DWK GHVFULVH üL VXLWD GH IXQFLL GH ED] FDUH SRW IL IRORVLWH vQ FDGUXO XQHL H[SUHVLL /H PHQLRQP SH FHOH PDL Lmportante: • privitoare la noduri: id(), position(), count(), name(), namespace-uri(), last() etc.; • referitoare la tipuri de noduri: node(), text(), comment(), processing-instruction() üL DOWele; • YL]kQG üLUXULOH GH FDUDFWHUH concat(), starts-with(), contains(), substring(), string-length(), translate() etc.; • privitoare la valori logice: not(), true(), false(); • referitoare la numere: sum(), floor(), round(), number() etc. 9RP LOXVWUD GLYHUVH H[HPSOH GH XWLOL]DUH D XQRU IXQFLL vQ XUPWRDUHD VHFLXQH Limbajul XSLT Limbajul XSLT (XSL Transformations) are drept scop transformarea documentelor XML în alte structuri (tipuri) de documente: XML, HTML, text. A fosW JkQGLW LQLLDO V IDF SDUWH GLQ ;6/ ;6/ ;6/7  ;6/)2
  • 228.  vQV VH SRDWH XWLOL]D LQGHSHQGHQW GH DFHVWD 3HQWUX D DYHD HIHFWXO VFRQWDW FRQVWUXFLLOH ;6/7 WUHEXLH V DSDULQ VSDLXOXL GH QXPH GHVHPQDW GH 85,-ul http://www.w3.org/1999/XSL/ Transform (Clark, 1999). O foaie de stiluri XSLT are drept element-UGFLQ <xsl:stylesheet> sau <xsl:transform> üL LQFOXGH GLYHUVH üDEORDQH (template-XUL
  • 229. GH WUDQVIRUPDUH PFDU XQ üaEORQ OD QLYHOXO UGFLQLL 3HQWUX UHDOL]DUHD WUDQVIRUPULORU VH UHFXUJH OD H[SUHVLL ;Path folosite la: • selectarea nodurilor dorite a fi procesate; • VSHFLILFDUHD FRQGLLLORU GH SURFHVDUH FRQWH[WXO
  • 230.  • JHQHUDUHD WH[WXOXL GH LHüLUH e.g., un alt document XML, o pagiQ +70/ RUL WH[W RELüQXLW
  • 231.  0RGHOXO SURFHVULL FRQVLGHU F R OLVW GH QRGXUL-suUV input) este SUHOXFUDW SHQWUX D VH JHQHUD XQ IUDJPHQW GH DUERUH GH QRGXUL OD GHVWLQDLH (output
  • 232.  ,QLLDO VH SURFHVHD] QRGXO-UGFLQ OD FDUH VH LQVHUHD] QRGXUL-copil
  • 233. Tehnologii XML66 JHQHUDWH GH üDEORDQH DSOLFDWH SULQ pattern-matching unei liste de noduri selectate (în manieU UHFXUVLY
  • 234. – via expresii XPath. 5HJXOLOH üDEORDQHORU LGHQWLILF QRGXUL DVXSUD FURUD VH YRU DSOLFD WUDQVIRUPUL VHOHFWDUHD QRGXULORU UHDOL]kQGX-VH SULQ ;3DWK 8Q üDEORQ VH defiQHüWH SULQ HOHPHQWXO <xsl:template> LDU DSOLFDUHD XQXL üDEORQ se UHDOL]HD] FX HOHPHQWXO <xsl:apply-templates>. &UHDUHD DUERUHOXL GH LHüLUH VH UHDOL]HD] LQkQG FRQW GH IDSWXO F vQWU-un üDEORQ RULFH HOHPHQW FH QX DSDULQ VSDLXOXL GH QXPH ;6/7 VH FRSLD] IU D IL RSHUDWH PRGLILFUL vQ DUERUeOH GH LHüLUH 'H DVHmenea, pot fi generate diverse tipuri de noduri: <xsl:element>, <xsl:attribute>, <xsl:text>, <xsl:comment> etc. Pentru a avea acces la rezultatele expresiilor XPath implicând valori ale documentului-VXUV YRP UHFXUJH OD <xsl:value-of>. 'LYHUüL SDUDPHWUL GH FRQWURO DO PRGXOXL GH JHQHUDUH D LHüLULL VH SRW VWDELOL via <xsl:output>. Activitatea de transformare recurge la un procesor XSLT (figura 10). Figura 10. Maniera de transformare a documentelor XML Foile de stiluri XSLT pot fi considerate programe, perPLkQGX-se exprimarea de: • FRQVWUXFLL UHSHWLWLYH <xsl:for-each>;
  • 235. Modele de date semistructurate. Familia XML 67 • FRQVWUXFLL GH WHVW <xsl:if>, <xsl:choose>, <xsl:when> üL <xsl:otherwise>; • copieri de noduri: <xsl:copy> üL <xsl:copy-of>; • VRUWUL GH QRGXUL <xsl:sort>; • includerea de alte foi de stiluri: <xsl:include>; • IRORVLUHD YDULDELOHORU üL SDUDPHWULORU <xsl:variable> üL <xsl:param>. )DFHP REVHUYDLD F VSUH GHRVHELUH GH OLPEDMHOH GH SURJUDPDUH FODVLFH variabilele (declarate via <xsl:variable>) au valori imutabile: valoarea DVRFLDW QX VH VFKLPE GLQ PRPHQW FH D IRVW HYDOXDW $VWIHO GXS R FRQVWUXFLH GH JHQXO <xsl:variable name="ani" select="21 + 12" />, R vQFHUFDUH GH D DWULEXL R DOW YDORDUH YDULDELOHL ani FRQGXFH OD DSDULLD XQHL HURUL 3DUDPHWULL VSHFLILFDL SULQ <xsl:param>
  • 236. vüL SRW PRGLILFD ulterior YDORDUHD $SHODUHD LQYRFDUHD
  • 237. XQXL üDEORQ VH SRDWH UHDOL]D FX SDVDUHD GH valori parametrilor via <xsl:with-param>. Tabelul 3. Principalele elementele XSLT Element Descriere xsl:stylesheet Utilizat ca element-UGFLQ DO XQHL IRL GH VWLOXUL poaWH FRQLQH üDEORDQHOH FDUH YRU IL DSOLFDWH pentru generarea altui document XML ori a unui DOW FRQLQXW xsl:template 'HILQHüWH R VHULH GH WUDQVIRrPULIRUPDWUL FDUH vor fi aplicate pentru un anumit model particular. xsl:apply-templates ,QYRF üDEORQXOüabloanele definite, pe baza unei potriviri implicite sau explicite. xsl:comment ,QVHUHD] XQ FRPHQWDULX vQ FDGUXO GRFXPHQ- tului generat. xsl:pi ,QVHUHD] R LQVWUXFLXQH GH SURFHVDUH vQ GRFXmen- WXO ;0/ GH OD LHüLUH xsl:element ,QVHUHD] XQ HOHPHQW ;0/ în documentul generat de foaia de stiluri. xsl:attribute $WDüHD] XQXL HOHPHQW XQ DQXPLW DWUibut. xsl:value-of ,QVHUHD] vQ FDGUXO GRFXPHQWXOXL GH OD LHüLUH rezultatul unei expresii XPath.
  • 238. Tehnologii XML68 xsl:for-each 5HDOL]HD] R EXFO GH DSOLFDUH D XQXL üDEORQ PDL multor noduri respectând un model XPath. xsl:if 8WLOL]DW SHQWUX DSOLFUL FRQGLLRQDOH GH WLSXO if-then. xsl:choose )RORVLW SHQWUX FRQGLLL PXOWLSOH GH Wipul switch din limbajul C), în conjuncLH FX HOHPHQWHOH xsl:when üL xsl:otherwise. xsl:copy Copie coQLQXWXO YDORULORU XQRU QRGXUL vQ GRFX- mentul (arborele) rezultat la ieüLUH 6XSOLPHQWDU VXQW SXVH OD GLVSR]LLH GLYHUVH IXQFLL GH Ea] • GHVHPQHD] QRGXO FXUHQW current(); • DGUHVHD] XQ DOW GRFXPHQW ;0/ GLIHULW GH FHO FXUHQW document(); • accesarea nodurilor pe baza cheilor specificate via XML Schema – YH]L VHFLXQHD  key(); • YHULILF H[LVWHQD XQHL IXQFLL VXSRUW SHQWUX H[WHnsii): function- available(); • IRUPDWHD] YDORUL QXPHULFH format-number(); • RIHU LQIRUPDLL SULYLWRDUH OD VLVWHPXO GH SURFHVare: system- property(). 9RP DVDPEOD FHOH GHVFULVH SkQ DFXP SULQ LQWHUPHGLXO XQXL VHW GH H[HPSOH 3HQWUX vQFHSXW FRQVLGHUP GRFXPHQWXO projects.xml, care sto- FKHD] R OLVW GH SURLHFWH SURSXVH VSUH LmSOHPHQWDUH üL DUH VWUXFWXUD <?xml-stylesheet href="projects.xsl" type="text/xsl" ?> <projects update="16 octombrie 2006"> <project class="A"> <title>...</title> <desc>...</desc> <stud>...</stud> <url>...</url> </project> </projects> 1H SURSXQHP V JHQHUP XQ GRFXPHQW ;+70/ SHQWUX redarea, în QDYLJDWRU D DFHVWHL OLVWH 'XS FXP VH SRDWH UHPDUFD IRORVLQG LQVWUXFLXQHD de procesare <?xml-stylesheet ...?> ataüP R IRDLH GH VWLOXUL ;6/7 QXPLW projects.xsl üL DYkQG XUPWoUXO FRQLQXW <xsl:stylesheet version="1.0"
  • 239. Modele de date semistructurate. Familia XML 69 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- úDEORQXO-UGFLQ --> <xsl:template match="/"> <html> <head> <title>Proiecte</title> </head> <body> <!-- DSOLFP úDEORQXO SHQWUX YL]XDOL]DUHD SURLHctelor --> <div id="listing"> <xsl:apply-templates /> </div> </body> </html> </xsl:template> <!-- úDEORQXO SHQWUX SURLHFWH --> <xsl:template match="projects"> <ul> <!-- OLVWD QHQXPHURWDW FRQLQkQG GDWH despre fiecare proiect --> <xsl:for-each select="project"> <li> <h5> <!-- titlul proiectului + clasa --> <xsl:value-of select="title" /> (<xsl:value-of select="@class" />) </h5> <p><!-- descrierea proiectului --> <xsl:value-of select="desc" /> </p> <div>Resurse suplimentare: <!-- FRQVWUXLP R OHJWXU --> <a> <!-- LQVHUP DWULEXWXO KUHI --> <xsl:attribute name="href"> <xsl:value-of select="url" /> </xsl:attribute>
  • 240. Tehnologii XML70 <!-- LQVHUP DWULEXtul 'title' --> <xsl:attribute name="title">Mai multe detalii</xsl:attribute> <xsl:value-of select="url" /> </a> </div> </li> </xsl:for-each> </ul> <p>Ultima actualizare: <xsl:value-of select="@update" /></p> </xsl:template> </xsl:stylesheet> &RGXO JHQHUDW HVWH ;+70/ SHQWUX FD IRDLD V ILH FRQVLGHUDW XQ GRFXPHQW ;0/ ELQH IRUPDWDW 6XQW VSHFLILFDWH GRX üDEORDQH SULPXO construind scheletul general al paginii Web, iar al doilea generând lista SULYLWRDUH OD SURLHFWH $O GRLOHD üDEORQ YD IL LQYRcat la potrivirea cu succes a DSDULLHL HOHPHQWXOXL <projects>. Similar, <xsl:for-each> va furniza OLVWD GH QRGXUL UH]XOWDW vQ XUPD HYDOXULL H[SUHVLHL ;3DWK project DFHODüL efect îl avea expresia absoOXW /projects/project). 3ULPXO SDV DO WUDQVIRUPULL YD FRQGXFH OD LQYRFDUHD üDEORQXOXL-UGFLQ în urma potrivirii cu nodul-UGFLQ GHVHPQDW GH RSHUDWRUXO Å/”. Toate QRGXULOH FDUH QX DSDULQ VSDLXOXL GH QXPH xsl YRU IL FRSLDWH OD LHüLUH DVWIHO VH FRQVWUXLHüWH FRGXO-VXUV DO SDJLQLL :HE
  • 241.  SkQ OD DSDULia elementului <xsl:apply-templates />. Acest eveniment va conduce la invocarea üDEORQXOXL SRWULYLW FX H[SUHVLD project, în cazul nostru <xsl:template match="projects"> ...</xsl:template>, care va genera lista nenume- URWDW D SURLHFWHORU DFHDVW DFWLYLWDWH H VXUSULQV vQ ILJXUD  FRQLQkQG captuUD GH HFUDQ D GHSDQDWRUXOXL GH WUDQVIRUPUL ;6/7 RIHULW GH DSOLFDLD oXygen). Cele specificate în cadrul <xsl:for-each> vor fi repetate de DWkWHD RUL FkWH QRGXUL VXQW UHWXUQDWH GH H[SUHVLD VSHFLILFDW FD Yaloare a atributului select al elementului <xsl:for-each>. 6H REVHUY JHQHUDUHD vQ PDQLHU GLQDPLF D XQHL OHJWXUL <a href="..." title="...">...</a>, pentru aceasta recurgând la <xsl:attribute> SHQWUX D DWDüD FHOH GRX DWULEXWH – href üL title – elementului <a> al limbajului XHTML.
  • 242. Modele de date semistructurate. Familia XML 71 )LJXUD  7UDVDUHD SDV FX SDV D SURFHGXULL GH UHDOL]DUH D WUDQVIRUPULORU ;6/7 9RP UDILQD SXLQ FHOH VFULVH PDL VXV üWLLQG F SURLHctele propuse sunt de diverse clase de dificultate, indicate de valorile atributului class al elementului <project> ,QWHQLRQP V DILüP vQ PRG GLIHULW GHVFULHUHD SURLHFWXOXL FRQIRUP FODVHL VDOH 3HQWUX DFHDVWD YRP UHFXUJH OD FRQVWUXFLLOH de test (omitem restul foii de stiluri): <p> <!-- vQ IXQFLH GH FODVD SURLHFWXOXL YRP DILúD GLIHULW descrierea lui --> <xsl:choose> <!-- proiect de clasa 'A' --> <xsl:when test="@class = 'A'"> <span style="color: darkred"> <xsl:value-of select="desc" /> </span> </xsl:when> <!-- SURLHFW GH FODV 'B' sau 'C' --> <xsl:when test="@class = 'B' or @class = 'C'">
  • 243. Tehnologii XML72 <span style="color: navy"> <xsl:value-of select="desc" /> </span> </xsl:when> <!-- SURLHFW GH FODV QHFXQRVFXW --> <xsl:otherwise> <span style="color: black"> <xsl:value-of select="desc" /> </span> </xsl:otherwise> </xsl:choose> </p> 'H DVHPHQHD SXWHP YHULILFD GDF <url> H[LVW VDX DUH R YDORDUH QHQXO pentru a nu insera inutil leJWXUD VSUH UHVXUVHOH VXSOLPHQWDUH SULYLWRDUH OD un proiect: <!-- GDF QX H[LVW HOHPHQWXO XUO QX DILúP OHJWXUD VSUH UHVXUVH VXSOLPHQWDUH --> <xsl:if test="url != ''"> ... </xsl:if> 8UPWRUXO SDV HVWH V RUGRQP OLVWD SURLHFWHORU FRQIRUP XQRU FUiterii. Pentru aceasta, folosim o conVWUXFLH GH JHQXO <!-- OLVWD QHQXPHURWDW FRQLQkQG GDWHOH despre fiecare proiect --> <xsl:for-each select="project"> <!-- VRUWP vQ RUGLQHD GHVFUHVFWRDUH D QXPUului de stuGHQL VRUWDUHD H OH[LFRJUDILF
  • 244. --> <xsl:sort select="stud" order="descending" /> <!-- DSRL DOIDEHWLF GXS WLWOXO SURLHFWXOXL --> <xsl:sort select="title" /> <li> <h5><xsl:value-of select="title" /></h5> </li> </xsl:for-each> 9RP UHFXUJH üL OD YDULDELOe, calculând valoarea RGB a culorii de fundal, SH FDUH R YRP VWDELOL vQ IXQFLH GH QXPUXO PD[LP GH VWXGHQL DURQGDL unui proiect – se utiOL]HD] IXQFLD concat() SXV OD GLVSR]LLH GH ;3DWK
  • 245. Modele de date semistructurate. Familia XML 73 <xsl:for-each select="project"> <xsl:sort select="title" /> <li> <!-- vQ IXQFLH GH QXPUXO GH VWXGHQL JHQHUP R FXORDUH GH IXQGDO --> <xsl:variable name="fundal" select="concat('rgb(',stud*90 ,',', stud*90, ',', stud*30, ')')" /> <p style="background-color: {$fundal}"> <!-- DILúP SR]LLD QXPHURWkQG DVWIHO SUoiectele --> <xsl:value-of select="(position())" />. <xsl:value-of select="title" /> </p> </li> </xsl:for-each> 'XS FXP VH SRDWH UHPDUFD YDORDUHD XQHL YDULDELOH VH DFFHVHD] prefixând numele variabilei cu semnul „$”. Un exemplu relativ mai complex este cel în care vom scrie o foaie de VWLOXUL ;6/7 FDUH SRDWH IL DSOLFDW RULFUXL GRFXPHQW ;0/ vQ YHGHUHD JHQHUULL XQHL UHSUH]HQWUL ;+70/ UHGkQG QRGXULOH DILüDWH GLVWLQFW vQ IXQFLH GH WLSXO DFHVWRUD syntax highlighting). Codul-VXUV FRPSOHW HVWH IXUQL]DW vQ FRQWLQXDUH VWDELOLUHD FXORULORU H vQ FRQFRUGDQ FX FRQYHQLLOH IRORVLWH GH 0R]LOOD )LUHIR[
  • 246.  ILLQG Lnspirat de un exemplu preluat din MSDN: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!-- sablonul-radacina --> <xsl:template match="/"> <html> <head> <title>XML2XHTML</title> <style type="text/css"> .element { color: #909; font-weight: bolder } .atribut { color: black; font-weight: bolder } .text { color: black } .valoare { color: blue } .coment { color: green; font-style: italic }
  • 247. Tehnologii XML74 .instruc { color: pink; font-style: italic } .sursa { font-family: monospace; font-size: 10pt } .prefix { color: navy; font-weight: bolder } .delim { color: black } </style> </head> <body class="sursa"> <xsl:apply-templates /> </body> </html> </xsl:template> <!-- YRU IL WUDQVIRUPDWH GRDU FRQVWUXFLLOH Lncluse în elementul <exemplu-xml> --> <xsl:template match="exemplu-xml"> <dl> <xsl:apply-templates mode="xmlsrc" /> </dl> </xsl:template> <!-- úDEORQ GH DILúDUH D FRQLQXWXOXL XQXL QRG WH[W --> <xsl:template match="text()" mode="xmlsrc"> <xsl:if test="normalize-space(.) != ''"> <dd> <xsl:value-of select="."/> </dd> </xsl:if> </xsl:template> <!-- úDEORQ GH DILúDUH D XQHL LQVWUXF GH SURFesare --> <xsl:template match="processing-instruction()" mode="xmlsrc"> <dd class="instruc"> &lt;?<xsl:value-of select="." />?&gt; </dd> </xsl:template> <!-- úDEORQ GH DILúare a comentariilor --> <xsl:template match="comment()" mode="xmlsrc">
  • 248. Modele de date semistructurate. Familia XML 75 <dd class="coment"> &lt;!-- <xsl:value-of select="." /> --&gt; </dd> </xsl:template> <!-- úDEORQ GH DILúDUH D YDORULL DWULEXWHORU --> <xsl:template match="@*" mode="xmlsrc"> <!-- XQ VSDLX VXSOLPHQWDU vQDLQWHD numelui de atribut --> <xsl:text> </xsl:text> <!-- DILúP QXPHOH DWULEXWXOXL --> <xsl:choose> <!-- QX HVWH SUHIL[DW GH YUHXQ VSDLX GH Qume? --> <xsl:when test="not (namespace-uri (.) = '')"> <!-- este, deci vom scrie separat prefi[XO úL numele elementului --> <span class="prefix"> <xsl:variable name="nume" select="name (.)" /> <xsl:variable name="prefix" select="substring-before($nume,':')" /> <xsl:value-of select="$prefix" /> </span> <span class="delim"> <xsl:text>:</xsl:text> </span> <span class="element"> <xsl:value-of select="local-name (.)" /> </span> </xsl:when> <xsl:otherwise> <span class="atribut"> <xsl:value-of select="name (.)"/> </span> </xsl:otherwise> </xsl:choose> <span class="delim">="</span> <span class="valoare"> <!-- úL YDORDUHD DWULEXWXOXL -->
  • 249. Tehnologii XML76 <xsl:value-of select="."/></span>" </xsl:template> <!-- úDEORQ FDUH DILúHD] FRQLQXWXO HOHPHQWelor --> <xsl:template match="*" mode="xmlsrc"> <!-- început de marcator --> <dd> <span class="delim"> <xsl:text>&lt;</xsl:text> </span> <!-- YHULILFP GDF H SUHIL[DW GH YUHXQ VSDLX GH Qume --> <xsl:choose> <xsl:when test="not (namespace-uri () = '')"> <!-- este, deci vom scrie separat prefixul úL QXPHOH HOementului --> <span class="prefix"> <xsl:variable name="nume" select="name (.)" /> <xsl:variable name="prefix" select="substring-before($nume,':')" /> <xsl:value-of select="$prefix" /> </span> <span class="delim"> <xsl:text>:</xsl:text> </span> <span class="element"> <xsl:value-of select="local-name (.)" /> </span> </xsl:when> <xsl:otherwise> <span class="element"> <xsl:value-of select="name (.)" /> </span> </xsl:otherwise> </xsl:choose> <!-- DILúP úL DWULEXWHOH --> <xsl:apply-templates select="@*" mode="xmlsrc"/> <xsl:choose>
  • 250. Modele de date semistructurate. Familia XML 77 <!-- YHULILFP GDF H FRPSXV úL GLQ DOWH QRGXUL --> <xsl:when test="*"> <span class="delim">&gt;</span> <dl> <xsl:apply-templates select="node()" mode="xmlsrc" /> </dl> <span class="delim">&lt;/</span> <xsl:choose> <xsl:when test="not (namespace-uri () = '')"> <!-- YRP VFULH VHSDUDW SUHIL[XO úL numele elementului --> <span class="prefix"> <xsl:variable name="nume" select="name (.)" /> <xsl:variable name="prefix" select="substring-before($nume,':')" /> <xsl:value-of select="$prefix" /> </span> <span class="delim"> <xsl:text>:</xsl:text> </span> <span class="element"> <xsl:value-of select="local-name (.)" /> </span> </xsl:when> <xsl:otherwise> <!-- DILúP FRQLQXWXO WH[W --> <span class="element"> <xsl:value-of select="name()" /> </span> </xsl:otherwise> </xsl:choose> <span class="delim">&gt;</span> </xsl:when> <!-- final de marcator --> <xsl:when test="text()"> <span class="delim">&gt;</span>
  • 251. Tehnologii XML78 <span class="text"> <xsl:value-of select="text()" /> </span> <span class="delim">&lt;/</span> <span class="element"> <xsl:value-of select="name()" /> </span> <span class="delim">&gt;</span> </xsl:when> <xsl:otherwise> <span class="delim">/&gt;</span> </xsl:otherwise> </xsl:choose> </dd> </xsl:template> </xsl:stylesheet> )LJXUD  5HSUH]HQWDUHD LQGHQWDW üL FRORUDW D XQXL GRFXPHQW ;0/ YLD WUDQVIRUPUL ;6/7 5HDOL]DUHD WUDQVIRUPULORU VH SRDWH IDFH GLUHFW vQ FDGUXO XQXL QDYLJDtor :HE GH XOWLP JHQHUDLH SUHFXP 0R]LOOD )LUHIR[  RUL ,QWHUQHW ([SORUHU  VDX R YHUVLXQH VXSHULRDU YH]L ILJXUD 
  • 252. 
  • 253. Modele de date semistructurate. Familia XML 79 ÍQ DQXPLWH FLUFXPVWDQH UHHWD GH PDL VXV QX IXQFLRQHD] UPkQH vQ VDUFLQD FLWLWRUXOXL GUHSW H[HUFLLX V UHPHGLH]H – acolo unde e cazul – foaia de stiluri prezenWDW ÍQ FRQWLQXDUH QH SURSXQHP V UHDOL]P R SUH]HQWDUH VWDWLVWLF D FRPSRQHQWHORU LQWHUIHHL SULQFLSDOH D SRSularului program Winamp. Specificarea skin-XULORU VH UHDOL]HD] YLD ILüLHUH ;0/ DWHQLD QRDVWU F]kQG asupra documentului system-colors.xml LQFOXV GH WHPD PRGHUQ D :LQDPS  Vom scrie o foaie de stiluri XSLT care va genera un tabel privind valorile FURPDWLFH DOH ILHFUHL SURSULHWL VSHFLILFDWH GH GRFXPHQWXO ;0/ VXUV 3UH]HQWP GRDU FHOH GRX üDEORDQH LPSRUWDQWe, întregul cod-VXUV ILLQG disponibil pe situl deGLFDW DFHVWHL FUL <!-- úDEORQXO SHQWUX H[WUDJHUHD HOHPHQWHORU --> <xsl:template match="elements"> <table align="center" width="600" border="1" summary="Lista de culori"> <xsl:apply-templates> <xsl:sort select="@id" /> <!-- am sortat in ordinea valorii atributelor 'id' --> </xsl:apply-templates> </table> <!-- Afisam unele statistici... --> <p>Am gasit <xsl:value-of select="count(/elements/color[@value='255,255,255'])" /> elemente albe din <xsl:value-of select="count(/elements/color)" /> de elemente.</p> <!-- ...plus informatii privitoare la procesorul XSLT --> <p>Procesorul XSLT folosit este produs de <xsl:variable name="sp" select="system-property('xsl:vendor')" /> <xsl:value-of select="$sp" />, fiind disponibil la URI-ul <xsl:value-of select="system-property('xsl:vendor-url')" />.</p> </xsl:template> <!-- úDEORQXO SHQWUX YL]XDOL]DUHD FXORULORr --> <xsl:template match="color">
  • 254. Tehnologii XML80 <!-- SHQWUX ILHFDUH HOHPHQW FRORU JVLW --> <xsl:for-each select="."> <!-- UHLQHP YDORDUHD FXORULL --> <xsl:variable name="culoare" select="@value" /> <tr> <td width="60%"> <xsl:value-of select="@id" /> </td> <td width="40%" align="center"> <!-- SUHOXP YDORULOH QXPHULFH DOH FHORU WUHL componente RGB --> <xsl:variable name="rosu" select="substring-before($culoare,',')" /> <span style="color: red"> <xsl:value-of select="$rosu" /> </span>, <xsl:variable name="verde" select= "substring-before(substring-after($culoare,','),',')" /> <span style="color: green"> <xsl:value-of select="$verde" /> </span>, <xsl:variable name="albastru" select= "substring-after(substring-after($culoare,','),',')" /> <span style="color: blue"> <xsl:value-of select="$albastru" /> </span> </td> <!-- LQWURGXFHP úL LQIRUPDLLOH UHIHULWRDUH OD JDPPD GDF H[LVW --> <td align="center"> <xsl:variable name="gamma" select="@gammagroup" /> <xsl:choose> <xsl:when test="$gamma"> <xsl:value-of select="$gamma" /> </xsl:when> <xsl:otherwise>
  • 255. Modele de date semistructurate. Familia XML 81 <span style="color: red"> &lt;unknown value&gt;</span> </xsl:otherwise> </xsl:choose> </td> </tr> </xsl:for-each> </xsl:template> 8Q HüDQWLRQ DO WUDQVIRUPULL HIHFWXDWH HVWH GLVSRQLELO vQ ILJXUD DOWXUDW )LJXUD  ,QIRUPDLL SULYLQG SURFHVRUXO ;6/7 IRORVLW 8UPWRUXO H[HPSOX LOXVWUHD] SRVLELOLWDWHD HIHFWXULL GH WUDQVIRUPUL ;6/7 FDUH V JHQHUH]H FRGXO-VXUV DO XQXL SURJUDP -DYD6FULSW 1H SODVP vQ FDGUXO XUPWRUXOXL VFHQDULX SULYLWRU OD LQWHUQDLRQDOL]DUHD DSOLFDLLORU 0HVDMHOH DILüDWH GH QDYLJDWRU YRU IL VWRFDWH vQWU-un document XML de genul: <?xml version="1.0"?> <?xml-stylesheet href="xsldoc.xsl" type="text/xsl" ?> <mesaje> <mesaj xml:lang="en">Good evening!</mesaj> <mesaj xml:lang="ro">Buna seara!</mesaj> <mesaj xml:lang="fr">Bon soir!</mesaj>
  • 256. Tehnologii XML82 <eticheta xml:lang="en">Say greetings</eticheta> <eticheta xml:lang="ro">Saluta</eticheta> <eticheta xml:lang="fr">Emettre un salut</eticheta> </mesaje> 'RULP FD OD DSVDUHD XQXL EXWRQ DYkQG XQ WH[W GDW GH HOHPHQWXO <eticheta> V ILH HPLV XQ PHVDM VWRFDW GH XQ HOHPHQW <mesaj> vQ IXQFLH GH SUHIHULQHOH OLngvistice ale utilizatorului. Documentul xsldoc.xsl va avea în responsabilitate generarea unui script FDUH V VDOXWH YL]LWDWRUXO FRQIRUP OLPELL GRULWH IRORVLP GRDU üDEORQXO-UGFLQ
  • 257.  <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <!-- OLPED GRULW --> <xsl:variable name="limba" select="'ro'" /> <html> <head><title>Salutari</title></head> <body> <script language="javascript" type="text/javascript" defer="true"> IXQFWLRQ VDOXWD
  • 258. ^  VDOXW XWLOL]DWRUXO <xsl:text>alert("</xsl:text> <xsl:value-of select="//mesaje/mesaj[@xml:lang = $limba]" /> <xsl:text>"); }</xsl:text> </script> <!-- construim elementul <input> în mod "dinamic", vQ IXQFLH GH OLPE --> <xsl:element name="input"> <xsl:attribute name="type">button</xsl:attribute> <xsl:attribute name="id">buton_de_salut</xsl:attribute> <xsl:attribute name="name">buton_de_salut</xsl:attribute> <xsl:attribute name="onclick">saluta()</xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="//mesaje/eticheta[@xml:lang = $limba]" /></xsl:attribute>
  • 259. Modele de date semistructurate. Familia XML 83 </xsl:element> </body> </html> </xsl:template> </xsl:stylesheet> Un ultim exemplu SUH]LQW PDQLHUD GH XWLOL]DUH D PDL PXOWRU IRL GH VWLOXUL LPSRUWDWH üL IRORVLUHD üDEORDQHORU SDUDPHWUL]DWH ,QWHQLRQP V FDOFXOP PD[LPXO GLQWU-R PXOLPH GH YDORUL 3HQWUX DFHDVWD YRP VFULH R IRDLH JHQHULF maxim.xsl care va determina recursiv maximul unei mulLPL <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- LHúLUHD UH]XOWDW YD IL vQ IRUPDW +70/ --> <xsl:output method="html" /> <!-- úDEORQ FDUH GHWHUPLQ UHFXUVLY PD[LPXO dintr-R PXOLPH GH valori --> <xsl:template name="furnizeaza_maxim"> <!-- OLVWD GH YDORUL GDW FD SDUDPHWUX GH Lntrare --> <xsl:param name="lista" /> <!-- elementul considerat maxim (o valoarea care nu face parte din intervalul de valori considerat) --> <xsl:param name="maximul" select="'100000'"/> <xsl:choose> <!-- GDF PDL H[LVW HOHPHQWH vQ PXOLPH --> <xsl:when test="$lista"> <!-- pastram lista într-R YDULDELO GLQ FDUH extragem primul element --> <xsl:variable name="lista_r" select="$lista[position() != 1]" /> <!-- FDOFXOP QRXD YDORDUH D PD[LPXOXL --> <xsl:variable name="maximul_nou"> <xsl:choose> <xsl:when test="$lista[1] &gt; $maximul"> <xsl:value-of select="$lista[1]" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$maximul" /> </xsl:otherwise>
  • 260. Tehnologii XML84 </xsl:choose> </xsl:variable> <!-- DSHOP UHFXUVLY úDEORQXO IRORVLQG Qoile valori SHQWUX PD[LP úL OLVW --> <xsl:call-template name="furnizeaza_maxim"> <xsl:with-param name="lista" select="$lista_r" /> <xsl:with-param name="maximul" select="$maximul_nou" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <!-- am epuizat lista de valori, întoarcem maximul determinat --> <xsl:value-of select="$maximul" /> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> 9RP FRQFHSH vQF R IRDLH JHQHULF QXPLW afiseaza.xsl, având rolul de a DWDüD SURSULHWL &66 GRFXPHQWXOXL ;+70/ JHQHUDW FD UH]XOWDW DO WUDQVIRUPULL DVLJXUP DVWIHO VHSDUDUHD SUH]HQWULL GH GDWH üL PDQLHUD GH procesare): <xsl:template name="afiseaza"> <style type="text/css"> body { font-family: Arial, Helvetica, sans-serif; width: 600px; } p { margin-top: 0.1em; margin-bottom: 0.3em; } /* etc. */ </style> </xsl:template> ÍQ DFHVW PRPHQW SXWHP IRORVL ILüLHUHOH ;6/7 GH PDL VXV SHQWUX D FDOFXOD PD[LPXO UH]XOWDWHORU RELQXWH GH DQXPLL VWXGHQL OD R DQXPLW GLVFLSOLQ Punctajele sunt stocate într-un document XML cu structura:
  • 261. Modele de date semistructurate. Familia XML 85 <?xml-stylesheet type="text/xsl" href="afiseaza_maxim.xsl" ?> <punctaje exam="..."> <punctaj stud="..."> <nota tip="test">10</nota> <nota tip="proiect">12</nota> <nota tip="bonus">1</nota> </punctaj> </punctaje> 0DL WUHEXLH V VFULHP afiseaza_maxim.xsl, care va recurge la precedentele foi generice: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes" /> <!-- LQFOXGHP IRDLD FDUH GHWHUPLQ PD[LPXO --> <xsl:include href="maxim.xsl" /> <!-- LQFOXGHP IRDLD FX SURSULHWL &66 --> <xsl:include href="afiseaza.xsl"/> <xsl:template match="/"> <html> <head> <!-- DSHOP úDEORQXO GH IRUPDWDUH --> <xsl:call-template name="afiseaza" /> </head> <body><xsl:apply-templates /></body> </html> </xsl:template> <!-- DILúP SXQFWDMHOH RELQXWH GH VWXGHQL --> <xsl:template match="punctaje"> <h1><xsl:value-of select="@exam" /></h1> S!&HD PDL PDUH QRW RELQXW OD SURLHFW D IRVW <xsl:variable name="maxim_proiect"> <xsl:call-template name="furnizeaza_maxim"> <xsl:with-param name="lista" select="//punctaj/nota[@tip = 'proiect']" /> <xsl:with-param name="maximul" select="'0'" /> </xsl:call-template> </xsl:variable> <b><xsl:value-of select="$maxim_proiect" /></b>
  • 262. Tehnologii XML86 <xsl:for-each select="punctaj/nota[@tip = 'proiect']"> <!-- WHVWP FLQH D OXDW punctaj maxim la proiect --> <xsl:if test=". = $maxim_proiect"> <br />Studentul <xsl:value-of select="../@stud" /> este eminent :-) </xsl:if> </xsl:for-each> </p> </xsl:template> </xsl:stylesheet> /D ILQDOXO DFHVWHL VHFLXQL PHQLRQP PRGDOLWLOH GH UHDOL]DUH D WUDQVIRUPULORU OD QLYHO SURJUDPDWLF YLD SURFHVRDUHOH ;6/7 • Apache Cocoon üL Xalan (bazate pe procesorul Xerces), cu LPSOHPHQWUL vQ & & 3HUO üL -DYD GLsponibile gratuit la http://xml.apache.org; • biblioteca open source libxslt pentru C/C++, parte a libxml IRORVLW vQ cadrul GNOME: http://xmlsoft.org/XSLT; • platforma Oracle-J; • biblioteca Sablotron VFULV vQ &
  • 263.  GLVSRQLELO OD http://www.gingerall. org üL IRORVLW vQ FDGUXO 3+3  IXQFLLOH xslt_*
  • 264. üL GH PRGXOXl Perl XML::Sablotron; • procesorul Saxon (pentru Java): http://saxon.sourceforge.net; • MSXML GH OD 0LFURVRIW FDUH SRDWH IL LQYRFDW üL YLD &20 e.g., ca un control ActiveX în cadrul Internet Explorer); • clasa XslTransform GLQ VSDLXO GH QXPH System.Xml al .NET Framework; • TrAX, parte a platformei de procesare JAXP oferiW GH -'. http://java.sun.com; • modulul XML::XSLT pentru Perl: http://www.cpan.org; 'H DVHPHQHD H[LVW VXSRUW – uneori limitat – în cadrul navigatoarelor Web actuale, via JavaScript. Drept exePSOH GH DSOLFDLL FDUH IRORVHVF WHKQRORJLD ;6/7 DPLQWLP • Adobe Help Center – sistem de ajutor utilizat de suita Adobe Creative 6XLWH  GDU IXQFLRQkQG üL LQGHSHQGHQW GLVSRQLELO JUDWXLW • Apache AxKit – mediu de publicare a datelor implementat în Perl; • Apache Forrest – mediu de dezvoltare de situri Web; • Microsoft InfoPath – editor/procesor de formulare interactive, parte a Microsoft Office 2003;
  • 265. Modele de date semistructurate. Familia XML 87 • OpenOffice – VXLW GH ELURX GLVSRQLELO vQ UHJLP open source; • XSLT Debugger – depanator XSLT oferit de mediul KDE. Extensiile EXSLT Comunitatea dezvoltatorilor de foi de stiluri XSLT a remarcat lipsa unor IXQFLRQDOLWL XWLOH DOH VSHFLILFDLHL RILFLDOH 2 LQLLDWLY LPSRUWDQW D IRVW DFHHD D UHDOL]ULL XQRU PRGXOH H[WHQVLL
  • 266. DOH ;6/7 RIHULQG IDFLOLWL suplimentare, detaliate pe situl www.exslt.org ,PSOHPHQWULOH (;6/7 SRW IL reali]DWH GLUHFW vQ ;6/7 RUL vQ DOWH OLPEDMH X]XDO VH DGRSW VROXLL GH scripting). ([WHQVLLOH PRGXODUL]DWH YL]HD] RIHULUHD GH • extensii comune: Common; • IDFLOLWL SHQWUX UHDOL]DUHD GH FDOcule matematice: Math; • OXFUX FX PXOLPL Sets; • RSHUDLL FX üLUXUL GH FDUDFWHUH Strings; • lucru cu date calendaristice: Dates & Times; • suport pentru expresii regulate: Regexp; • VXSRUW SHQWUX GHILQLUHD GH IXQFLL H[WHUQH Functions; • SRVLELOLWL SHQWUX HYDOXDUHD GLQDPLF D üLUXULORU FRQLQkQG H[SUHVLL XPath: Dynamic; • generare de numere aleatorii: Random. Pentru a folosi un modul EXSLT în cadrul unei foi de stiluri, se va UHFXUJH OD VSHFLILFDUHD VSDLLORU GH QXPH FRUHVSXQ]WRare. De exemplu, pentru a utiliza mRGXOXO UHIHULWRU OD RSHUDLL FX PXOLPL vom scrie: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sets="http://exslt.org/sets"> ... </xsl:stylesheet> 3HQWUX D SUHYHQL LQFOXGHUHD HOHPHQWHORU FRUHVSXQ]WRDUH VSDLLlor de QXPH (;6/7 vQ DUERUHOH JHQHUDW OD LHüLUH YRP XWLOiza atributul exclude- -result-prefixes GXS FXP Yedea în exemplele de mai jos. 7DEHOXO  VXPDUL]HD] PRGHOH (;6/7 SULQFLSDOH RIHULQG üL OLVWD FHORU PDL X]XDOH IXQFLL FH SRW IL IRORVLWH )XQFLLOH VXSOLPHQWDUH SRW V QX ILH implementate de unele procesoare XSLT.
  • 267. Tehnologii XML88 7DEHOXO  )XQFLLOH RIHULWH GH SULQFLSDOHOH PRGXOH (;6/7 Modul URI-XO VSDLXOXL GH Qume )XQFLL GLVSRQLEile Math http://exslt.org/math )XQFLL GH ED] math:min, math:max, math:highest, math:lowest )XQFLL VXSOLPHntare (similare celor ECMAScript): math:abs, math:sqrt, math:power, math:log, math:exp, math:random, math:sin, math:cos, math:tan, math:asin, math:acos, math:atan etc. Sets http://exslt.org/sets )XQFLL GH ED] sets:difference, sets:intersection, sets:distinct, sets:has-same-node, sets:leading, sets:trailing Strings http://exslt.org/strings )XQFLL GH ED] VLPLODUH FHORU ECMAScript): str:tokenize, str:replace, str:concat, str:split, str:align, str:encode-uri, str:decode-uri etc. Dates & Times http://exslt.org/dates-and -times )XQFLL GH ED] date:date-time, date:date, date:time, date:year, date:month-in-year, date:month, date:day-name, date:hour-in-day, date:minute-in-hour etc. )XQFLL VXSOLPHQWDUH date:format-date, date:add, date:sum, date:difference etc. Regexp http://exslt.org/regular-e xpressions )XQFLL GH ED] regexp:test, regexp:match, regexp:replace $FWXDOPHQWH SURFHVRDUHOH FDUH LPSOHPHQWHD] QDWLY GH FHOH PDL PXOWH RUL SDULDO
  • 268. PRGXOHOH (;6/7 VXQW 4XSLT, libxslt, Saxon üL Xalan. Pentru celelalte, se pot folosi sursele modulelor puVH OD GLVSR]LLH GH VLWXO DPLQWLW Revizitând exemplul de mai sus privitor la determinarea maximului SXQFWDMHORU RELQXWH OD SURLHFWH IRORVLQG (;6/7 YRP VFULH XUPWRDUHOH
  • 269. Modele de date semistructurate. Familia XML 89 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://exslt.org/math" exclude-result-prefixes="math"> <xsl:output method="html" indent="yes" /> <xsl:template match="/"> <html> <head> <title>Maximul punctajului la proiect</title> </head> <body> <h1><xsl:value-of select="//@exam" /></h1> S!&HD PDL PDUH QRWD RELQXW OD SURLHFW D IRVW <xsl:value-of select= "math:max(//punctaj/nota[@tip = 'proiect'])" /> </p> </body> </html> </xsl:template> </xsl:stylesheet> Invocând procesorul Saxon din linia GH FRPDQG DLFL vQ :LQGRZV
  • 270.  YRP RELQH D:saxon>java -jar saxon8.jar -novw punctaje.xml maxim.xsl <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Maximul punctajului la proiect</title> </head> <body> K!,QWHUDFLXQH RP-calculator</h1> S!&HD PDL PDUH QRWD RELQXW OD SURLHFW D IRVW S! </body> </html> 2 DOW H[HPSOLILFDUH LOXVWUkQG UHDOL]DUHD RSHUDLLORU FX PXOLPL GH QRGXUL HVWH XUPWRDUHD <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  • 271. Tehnologii XML90 xmlns:set="http://exslt.org/sets" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="set date"> <!-- ,HúLUHD JHQHUDW YD IL vQ IRUPDW WH[W RELúQXLW --> <xsl:output method="text" /> <!-- 0XOLPLOH GH QRGXUL FRQVLGHUDWH SHQWUX RSHUDLile GH LQWHUVHFWLH úL GLIHUHQ --> <xsl:variable name="a" select="//punctaj[contains(@stud,'a')]" /> <xsl:variable name="m" select="//punctaj[contains(@stud,'m')]" /> <xsl:template match="/"> 1XPH FRQLQkQG D úL P <xsl:for-each select="set:intersection($a, $m)"> '<xsl:value-of select="@stud" />' <xsl:text> </xsl:text> </xsl:for-each> 1XPH FRQLQLQG D úL QHFRQLQkQG P <xsl:for-each select="set:difference($a, $m)"> '<xsl:value-of select="@stud" />' <xsl:text> </xsl:text> </xsl:for-each> 1XPH FRQLQkQG P úL QHFRQLQkQG D <xsl:for-each select="set:difference($m, $a)"> '<xsl:value-of select="@stud" />' <xsl:text> </xsl:text> </xsl:for-each> $FHDVW VLWXDLH D IRVW JHQHUDW DFXP <xsl:value-of select="date:time()" />. </xsl:template> </xsl:stylesheet> 'XS FXP VH SRDWH UHPDUFD DP UHFXUV OD IXQFLRQDOLWLOH D GRX module EXSLT: Sets üL Dates & Times. )RUPDWDUHDFRQLQXWXOXL;0/YLD;6/-FO 3kQ DFXP DP Y]XW FXP SXWHP WUDQVIRUPD FRQLQXWXO ;0/ vQ GLYHUVH IRUPDWH HYHQWXDO GH SUH]HQWDUH D GDWHORU ;+70/ 69* RUL WH[W RELüQXLW
  • 272.  O necesitaWH HVWH DFHHD GH D EHQHILFLD GH DQXPLWH IDFLOLWL GH IRUPDWDUH
  • 273. Modele de date semistructurate. Familia XML 91 DYDQVDW D FRQLQXWXOXL GRFuPHQWHORU ;0/ GH H[HPSOX vQ YHGHUHD WLSULULL conform stanGDUGHORU vQ YLJRDUH $FHVWH IDFLOLWL VXQW SXVH OD GLVSR]LLH GH VSHFLILFDLD ;6/-FO (Adler et al., 2001) FDUH VH SRDWH XWLOL]D üL
  • 274. vQ FRQMXQFLH FX WUDQVIRUPULOH ;6/7 Maniera de formatare decurge astfel: dat fiind un arbore de noduri XML, via XSL-)2 VH SRW DWDüD SURSULHWL GH IRUPDWDUH SDJLQDW – conform unui mediu de redare –, astfel încât infoset-ul re]XOWDW V SRDW IL SUH]HQWDW utilizatorului pe ecranul unui dispozitiv (calculator personal, handheld, WDEO HOHFWURQLF HWF
  • 275. RUL OLVWDW vQ GLYHUVH IRUPDWH FDUWH EURüXU FDWDORJ üL DOWHOH
  • 276.  $FHVW SURFHV H GLYL]DW vQ RSHUDLLOH GH transformare, reaOL]DW GH XQ WUDQVIRUPDWRUSURFHVRU ;6/ üL GH formatare, via un formatator XSL. Nu este obligatoriu ca transforPDUHD V ILH XQ SURFHV VHSDUDW GH FHO GH WUDQVIRUPDUH 'DF PDL VXV DP H[SXV DFWLYLWDWHD GH WUDQVIRUPDUH vQ FHOH GH XUPHD] QH YRP FRQFHntra asupra celei de formatare. &RQIRUP 3DZVRQ 
  • 277.  PHWRGRORJLD GH OXFUX FH WUHEXLH DGRSWDW YL]HD] XUPWRDUHOH DVSHFWH • FXQRDüWHUHD VWUXFWXULL GRFXPHQWuOXLGRFXPHQWHORU ;0/ VXUV • VSHFLILFDUHD XQHLXQRU IRUPH GH UHGDUH DILüDUH OLVWDUH HWF
  • 278. üL D XQXL format dorit (XHTML, WML, PDF, PostScript etc.); • VHOHFWDUHD RELHFWHORU GH IRUPDWDUH vQ FRQFRUGDQ FX PRGXO GH UHGDUH • reutilizarea/conceperea documentelor XSL; • optimizarea foilor de stil XSL folosite; • FRPSLODUHD IRLORU GH VWLO FRQFHSXWH vQ YHGHUHD DFFHOHUULL SURFHVULL 'LQ SXQFW GH YHGHUH FRQFHSWXDO üL WHKQLF YD WUHEXL V QH vQVXüLP WHUPHQLL • Documentul UHSUH]LQW UH]XOWDWXO ILQDO RELQXW vQ XUPD IRUPDWULL üL H GLYL]DW GLQ SXQFW GH YHGHUH ORJLF vQ WUHL SUL PDMRUH VLPLOare modelului folosit de LaTeX): – front matter – LQFOXGH SDJLQD GH WLWOX R GHGLFDLH RSLRQDO
  • 279.  SUHIDD FXSULQVXO OLVWD ILJXULORU HWF SDUWH WLSLF SHQWUX R FDUWH
  • 280.  – main matter (corpul) – are caracter obligatoriu, reprezentând FRQLQXWXO SULQFLSDO DO GRFXPHQWXOXL LQGiferent de forma sa; – back matter – FRQLQH XQ LQGH[ JORVDUXO ELEOLRJUDILD XQ FRORIRQ HWF SDUWH WLSLF SHQWUX R FDUWH XQHOH FRPSRQHnWH ILLQG RSLRQDOH
  • 281.  • Aranjamentul (layout
  • 282. HVWH FRUHVSXQ]WRU XQXL VHW GH SDJLQL üL IRORVHüWH GLYHUVH üDEORDQH GH IRUPDWDUH page templates). • )OX[XO SDJLQULL (page flow
  • 283. UHSUH]LQW SURFHVXO GH JHQHUDUH D ILHFUHL SDJLQL vQ IXQFLH GH DUDQMDPHQWXO DGRSWDW GH PHGLXO GH UHGDUH üL GH FODVD GH GRFXPHQW IRORVLW e.g. FDUWH DUWLFRO EURüXU slide-uri etc.). Acest flux are loc în concordDQ FX SURSULHWile de formatare
  • 284. Tehnologii XML92 specificate via obiecte de formatare (formatting objects
  • 285. DWDüDWH FRQLQXWXOXL ;0/ YLD IRaia de stiluri XSL. • Pagina (page
  • 286. SRDWH IL UHGDW FRQIRUP XQHL RULHnWUL – e.g., la 90% SHQWUX D VH JHQHUD R SDJLQ GH WLS SHLVDM landscape) – üL H GLYL]DW vQ XUPWRDUHOH ]RQH GH Lnteres: – SDUWHD VXSHULRDU before) – vQ JHQHUDO UH]HUYDW DQWHWXULORU – SDUWHD LQIHULRDU (after) – uzual, pentru subsoluri; – partea de început (start) – vQ PRG QRUPDO SDUWHD VWkQJ D SDJLQLL – partea de final (end) – vQ PRG X]XDO SDUWHD GUHDSW D Saginii; – corpul propriu-zis (body). Figura 14. Zonele de interes ale unei pagini, conform XSL-FO • &RQLQXWXO (content
  • 287. UHSUH]LQW LQIRUPDLD GLQ FDUH HVWH FRPSXV ÅXPSOXWµ
  • 288. R VHFYHQ GH SDJLQL 3RDWH IL FRQVLGHrat static (folosit
  • 289. Modele de date semistructurate. Familia XML 93 pentru zonele diferite de corpul paginii) sau de tip flux – flow (apare în corpul paginii), incluzând arii (areas
  • 290. GH LQIRUPDLL • Aria (area
  • 291. GHVFULH VWUXFWXUD VSDLDO D LQIRUPDLHL UHGDWH SXWkQG IL JHQHUDW GH   VDX PDL PXOWH RELHFWH GH IRUPDWDUH üL RFXSkQG R ]RQ GUHSWXQJKLXOaU vQ FDGUXO PHGLXOXL GH UHGDUH D VH YHGHD figura 15). O arie poate fi de tip inline – DSUkQG vQ FDGUXO XQXL EORF (block
  • 292. GH LQIRUPDLL DYkQG DVRFLDWH SURSULHWL VWDEilind local PRGXO GH UHGDUH D FRQLQXWului (e.g., o imagine precedând un titlu, un fragment de text scris înclinat etc.) – sau de tip block – GHVHPQkQG LQIRUPDLL VHSDUDWH GH UHJXOL GH IRUPDWDUH ILLQG FRQVWLWXLW GLQ DULL GH WLS inline (exemple tipice: paragrafe, tabele, OLVWH QXPHURWDWH üL Dltele). )LJXUD  &RPSRQHQWHOH XQHL DULL FRQLQXWXO SURSULX-zis (content), VSDLXO vQFRQMXUWRU padding
  • 293. üL FKHQDUXO border) 3URSULHWLOH GH IRUPDWDUH VH ED]HD] SH FHOH VSHFLILFDWH GH &66 %RV et al. 
  • 294.  6XSOLPHQWDU VXQW GHILQLWH PRGDOLWL Pai sofisticate de formatare (e.g. JHQHUDUHD GH OHJWXUL GH FXSULQVXUL GH UHIHULQH vQFUXFLüDWH GH SDJLQUL üL VSDLHUL FRQGLLRQDWH HWF
  • 295.  GXS FXP VH YD SXWHD GHGXFH üL din exemplele pe care le vom prezenta mai jos. 8QLWLOH GH PVXU VXQW VLPLODUH celor de la CSS (cm, mm, in, px, pt, pc üL em), valorile putând fi absolute sau relative. 'LQ SFDWH UH]XOWDWXO IRUPDWULL GHSLQGH GH FHOH PDL PXOWH RUL GH procesorul XSL-FO utilizat, formatele standard suportate în mod uzual fiind PDF (Portable Document Format), PS (PostScript
  • 296. üL 57) Rich Text Format). &RQVWUXFLLOH ;6/-)2 WUHEXLH V DSDULQ VSDLXOXL GH QXPH LQGLFDW GH URI-ul http://www.w3.org/1999/XSL/Format. Un document XSL-FO are drept
  • 297. Tehnologii XML94 UGFLQ HOHPHQWXO <fo:root>, iar aranjamentul paginilor e specificat de <fo:layout-master-set> )LHFDUH VHFYHQ GH SDJLQL HVWH GHILQLW printr-un element <fo:page-sequence> FDUH YD VSHFLILFD üL PRGXO GH JHQHUDUH D FRQLQXWXOXL – fluxul de date via <fo:flow> üL FRQLQXWXO considerat static prin <fo:static-content>. 3URSULHWLOH JHQHUDOH DOH SDJLQLL VH GHILQHVF SULQ <fo:simple-page- -master> LDU ]RQHOH GH SDJLQ YLD <fo:region-body>, <fo:region- -before>, <fo:region-after> üDPG $ULLOH GH WLS EORF VH VSHFiILF SULQ <fo:block>, iar cele de tip inline cu <fo:inline>. 6H SRW LQFOXGH FRQLQXWXUL WDEHODUH SULQ LQWHUPHGLXO XQRU HOHPHQWH FD <fo:table>, <fo:table-column>, <fo:table-row>, <fo:table-cell>, <fo:table-caption> VDX FRQLQXWXUL JUDILFH LQWURGXVH YLD <fo:external- -graphics /> &RQLQXWXULOH GH WLS OLVW VH VSHFLILF SULQ HOHPHQWHOH <fo:list-item>, <fo:list-item-label> üL <fo:list-item-body>. ([LVW SRVLELOLWDWHD LQVHUULL GH OHJWXUL KLSHUWH[W Ftre alte resurse via <fo:basic-link>. De asemenea, notele de subsol sunt indicate prin elementele <fo:footnote> üL <fo:footnote-body>. Specificarea de SURSULHWL GH IRUPDWDUH OD QLYHO GH FDUDFWHU e.g., pentru generarea letrinelor) se reali]HD] YLD <fo:character />, iar alte tipuri de FRQLQXWXUL e.g., SVG) pot fi incluse – daF SURFHVRUXO DUH DVHPHQHD VXSRUW – via <fo:instream-foreign-object />. 3URSULHWLOH GH IRUPDWDUH VH VSHFLILF JUDLH XQRU DWULEXWH DWDüDWH XQRU elemente de interes precum <fo:block> ori <fo:inline>. )XUQL]P vQ FRQWLQXDUH FkWHYD H[HPSOH <!-- specificarea unui element de tip bloc (paragraf) --> <fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" text-align="justify">Salut!</fo:block> <!-- inserarea inline D XQHL LQGLFDLL --> <fo:inline>Vezi remarca <fo:character character="1" baseline-shift="super" font-family="'Arial Narrow'" /> </fo:inline> <!-- includerea unei imagini PNG --> <fo:external-graphic content-height="1cm" content-width="2cm" src="url(images/csb.png)" />
  • 298. Modele de date semistructurate. Familia XML 95 ([LVW GLVSRQLELOH PDL PXOWH IRUPDWDWRDUH ;6/ GLQWUH FDUH PHQLRQP • Antenna House Formatter – www.antennahouse.com; • Apache FOP VFULV vQ -DYD üL GLVSRQLELO vQ UHJLP open source) – xml.apache.org/fop; • Formatting Objects Authoring (pentru Java) – foa.sf.net; • Java XSL-FO for RTF – www.jfor.org; • RenderX XEP (conceput în Java) – www.renderx.com. ([HPSOLILFULOH XUPWRDUH YRU UHFXUJH WRDWH OD $SDFKH )23 SHQWUX JHQHUDUHD GRFXPHQWHORU 3') UH]XOWDWH vQ XUPD IRUPDWULORU 1H SURSXQHP V UHDOL]P GLYHUVH IRUPDWUL SOeFkQG GH OD XUPWRUXO GRFXPHQW ;0/ FH PDUFKHD] GDWHOH SULYLWRDUH OD QLüWH VXELHFWH ÅvQVSLPkQWWRDUHµ"
  • 299. GH examen: <examen> <meta> <desc>Primul test scris la Tehnologii Web</desc> <autor uri="...">...</autor> <data tip="actualizare">...</data> <data tip="creare">...</data> </meta> <subiecte> <subiect punctaj="6" id="1"> <desc xmlns:h="http://www.w3.org/1999/xhtml"> <h:p>...</h:p> <!-- etc. --> </desc> <dep subiect="2" /> </subiect> </subiecte> </examen> Elementul <desc> poate include construcLL ;+70/ e.g., <p>, <ul>, <li>, <tt> etc.). 'RULP V UHGP FRQLQXWXO DFHVWXL GRFXPHQW IRORVLQG IDFLOLWLOH GH ED] oferite de obiectele de formatare. Pentru aceasta, vom scrie o foaie de stiluri ;6/ FDUH YD UHFXUJH OD ;6/7 SHQWUX D VHOHFWD LQIRUPDLLOH GRULWH üL OD XSL-FO pentru a realiza formatarea propriu-]LV $VWIHO YRP FRQFHSH codul furnizat mai jos: <xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
  • 300. Tehnologii XML96 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h="http://www.w3.org/1999/xhtml"> <!-- JHQHUP XQ FRQLQXW ;0/ UHSUH]HQWDW GH FRQVWUXFLLOH ;6/-FO --> <xsl:output method="xml" indent="yes" /> <xsl:template match="examen"> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <!-- aranjamentul general al paginilor --> <fo:layout-master-set> <!-- SDJLQD SULQFLSDO IRUPDW $
  • 301. --> <fo:simple-page-master page-height="297mm" page-width="210mm" margin="15mm 25mm 15mm 25mm" master-name="pag_principala"> <!-- stabilirea corpului paginii YD LQFOXGH FRQLQXWXO SURSULX-zis) --> <fo:region-body margin="20mm 0mm 20mm 0mm" /> </fo:simple-page-master> </fo:layout-master-set> <!-- VWDELOLUHD VHFYHQHL GH SDJLQL pentru pagina principala --> <fo:page-sequence master-reference="pag_principala"> <!-- crearea obiectelor flotante FH YRU DSUHD vQ FRUS --> <fo:flow flow-name="xsl-region-body"> <fo:block> <xsl:apply-templates select="subiecte" /> </fo:block> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <!-- úDEORQ FH JHQHUHD] OLVWD VRUWDW GH VXELHcte --> <xsl:template match="subiecte"> <xsl:for-each select="subiect"> <!-- VRUWP vQ IXQFLH GH LG-ul subiectului -->
  • 302. Modele de date semistructurate. Familia XML 97 <xsl:sort select="@id" /> <fo:block> <!-- JHQHUP VWLOXULOH SHQWUX ILHFDUe subiect --> <fo:block> <fo:inline>Subiectul <xsl:value-of select="position()" /> </fo:inline> </fo:block> <!-- DILúP úL SXQFWDMXO PD[LP DFRUGDW --> <fo:block font-weight="bold" padding-bottom="0.3em"> Punctaj: <xsl:value-of select="@punctaj" /> </fo:block> <xsl:apply-templates /> </fo:block> </xsl:for-each> </xsl:template> <!-- úDEORQ FH VWDELOHúWH SURSULHWLOH GH DILúare pentru <h:p> --> <xsl:template match="h:p"> <fo:block font-size="12pt" font-family="sans-serif" text-align="justify" text-indent="2em" line-height="15pt"> <xsl:apply-templates /> </fo:block> </xsl:template> <!-- úDEORQ VWDELOLQG VWLOXULOH SHQWUX HOHPHQWHOH KL! --> <xsl:template match="h:i"> <fo:inline font-style="italic"> <xsl:apply-templates /> </fo:inline> </xsl:template> <!-- úDEORQ Vtabilind stilurile pentru <h:tt> --> <xsl:template match="h:tt"> <fo:inline font-size="10pt" font-family="monospace">
  • 303. Tehnologii XML98 <xsl:apply-templates /> </fo:inline> </xsl:template> <!-- úDEORQ VWDELOLQG VWLOXULOH SHQWUX KEU ! --> <xsl:template match="h:br"> <fo:block></fo:block> </xsl:template> <!-- úDEORQ VWDELOLQG VWLOXUL SHQWUX KXO!KRO! --> <xsl:template match="h:ul | h:ol"> <fo:list-block> <xsl:apply-templates /> </fo:list-block> </xsl:template> <!-- úDEORQ VWDELOLQG VWLOXULOH SHQWUX KOL! --> <xsl:template match="h:li"> <fo:list-item space-before="0.4em" space-after="0.2em"> <!-- JHQHUP HWLFKHWD GH FRQWRUL]DUH D QXPUului de elemente ale listei de subiecte --> <fo:list-item-label end-indent="label-end()"> <fo:block text-align="end"> <!-- stabilim modul de numerotare --> <xsl:number format="1." /> </fo:block> </fo:list-item-label> <!-- geneUP FRQLQXWXO SURSULX-zis DO XQHL LQWUUL vQ OLVW --> <fo:list-item-body start-indent="body-start()"> <fo:block text-align="justify"> <xsl:apply-templates /> </fo:block> </fo:list-item-body> </fo:list-item> </xsl:template> </xsl:stylesheet> Alte exemple de foi XSL sunt disponibile pe situl dedicat acestui volum.
  • 304. Modele de date semistructurate. Familia XML 99 ÍQ XUPD UXOULL SURFHVRUXOXL )23 SULQWU-o linie de forma: D:fop>fop.bat -xml web-test.xml -xsl test-print4.xsl -awt vom SXWHD RELQH R UHSUH]HQWDUH SUHFXP FHD LOXVWUDW vQ ILJXUD  REVHUYDL F DYHP OD GLVSR]LLH R VROXLH open source de generare coPRG GH GRFXPHQWH 3') SOHFkQG GH OD GDWH VWRFDWH vQ ILüLHUH ;0/ OD QLYHO GH FOLHQW VDX VHUYHU :HE
  • 305.  Figura 16. Redarea inIRUPDLLORU IRUPDWDWH FX )23
  • 306. Tehnologii XML100 6SUHYLLWRU;3DWKüL;6/7 ÍQFKHLHP VXEFDSLWROXO GH ID FX SUHFL]DUHD XQRU GLUHFLL GH YLLWRU SULYLWRDUH OD WUDQVIRUPDUHD üL IRUPDWDUHD FRQLQXWXOXL ;0/ ÍQ PRPHQWXO VFULHULL DFHVWXL PDWHULDO OD &RQVRULXO :HE HUD vQ curs de standardizare varianta XPath 2.0 (Berlung et al. 
  • 307.  $FHDVW QRX YHUVLXQH HVWH FRQVLGHUDW FD ILLQG ED]D DWkW SHQWUX ;6/7 FkW üL SHQWUX XQuery (a se vedea subcapitolul 5). ([SUHVLLOH ;3DWK  RSHUHD] DVXSUD XQHL VWUXFWXUL ORJLFH DEVWUDFWe) a GRFXPHQWXOXL QXPLW data model – a se vizita www.w3.org/TR/ xpath-datamodel/ pentru detalii. Tipurile de date folosite sunt cele precizate de XML Schema DPQXQWH vQ VHFiunea 3.4), iar la traversarea documentului se pot folosi axe suplimentare. XPath  SHUPLWH VSHFLILFDUHD GH VHFYHQH OLVWH
  • 308. üL GH LQWHUYDOH GH valori, precum (8, 10, 1 to 4). 5HODWLY OD VHFYHQH – de noduri ori de valori – apar noii operatori union (prescurtat prin „|”), intersect üL except FH SHUPLW RSHUDLL FX PXOLPL Este intrRGXV üL RSHUDWRUXO idiv care va oferi un rezultat întreg al vPSULULL &RPSDUDLLOH JHQerale se pot face via operatorii =, !=, <, <=, >, >=, iar cele asupra valorilor atomice – prin operatorii eq, ne, lt, le, gt, respectiv ge DFHVW DVSHFW HYLW XQHOH DPEiJXLWL üL GHWHUPLQ VFULHUHD XQXL cod mai clar). 3HQWUX LWHUDLL VH SRDWH IRORVL H[SUHVLD for vQWRUFkQG R OLVW GH valori/noduri, ca în exemplul de mai jos: for $i in (10, 20), $j in (1, 2) return ($i + $j) 0DL PXOW GHFkW DWkW H[SUHVLLOH FRQGLLRQale pot fi exprimate prin if (în H[HPSOX XUPWRU GDF VWDUHD FDWDORJXOXL HVWH PDrFDW FD ILLQG final, DWXQFL VH UHWXUQHD] YDORDUHD HOHPHQWXOXL nota, iar în caz contrar, valoarea elementului prezente): if (catalog[@stare = 'final']) then student/nota else student/prezente De asemenea, se permit expresiile cuantificate, precedate de cuantificatorii some H[LVW
  • 309. RUL every (oricare): some $x in (1, 2, 3), $y in (2, 3, 4) satisfies $x + $y = 4 every $x in (1, 2, 3), $y in (2, 3, 4) satisfies $x + $y = 4
  • 310. Modele de date semistructurate. Familia XML 101 ÍQ FD]XO DFHVWXL XOWLP H[HPSOX SULPHOH GRX OLQLL YRU vQWRDUFH YDORDUHD true LDU XOWLPHOH GRX false. $OWH GHWDOLL GH LQWHUHV SHQWUX FLWLWRULL LQWHUHVDL VXQW GLVSRQLELOH vQ OXFUD- rea Kay (2004). 7RW vQ FXUV GH VWDQGDUGL]DUH VH DIO üL ;6/7 .0 (Kay, 2005), care – printre altele – UHFXUJH OD ;3DWK  RIHU SRVLELOLWL GH VSHFLILFDUH D IXQFLLORU definite de utilizator, aduce suport pentru crearea de arbori multipli la LHüLUH üL SHUPLWH GHFODUDLL GH WLSXUL SHQWUX YDULDELOHSDUDPHWUL ÍQ SOXs, diverse grupuri de noduri pot fi parcurse via <xsl:for-each-group>. 'H DVHPHQHD vQ FRQFRUGDQ FX FHOH GH PDL VXV FRnVWUXFLD <xsl:for-each> SRDWH LWHUD üL VHFYHQH GH YDORUL QX GRDU GH QRGXUL Suplimentar, criteriul de sortare poate fi specificat dH R IXQFLH-utilizator, VXQW LQWURGXVH IXQFLL QRL SHQWUX IRUPDWDUHD GDWHL üL VH SRW FUHD QRGXUL GH WLS VSDLX GH QXPH YLD <xsl:namespace> 'HVLJXU DSDU üL DOWH vPEX- QWLUL /D PRPHQWXO DFWXDO SURFHVRUXO FDUH LPSOHPHQWHD] FHO PDL ILGHO variantele de lucru ale XSLT 2.0 este Saxon. ÍO YRP IRORVL SHQWUX D H[SHULPHQWD R VHULH GLQWUH QRLOH IDFLOLWL SULQ LQWHUPHGLXO XUPWRDUHL IRL GH VWLOXUL REVHUYDL QRXWLOH VXUYHQLWH vQ scrierea codului): <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- OD LHúLUH YD UH]XOWD WH[W RELúQXLW --> <xsl:output method="text" /> <xsl:template match="/"> <xsl:apply-templates select="punctaje" /> </xsl:template> <!-- úDEORQ FDUH FRQVWUXLHúWH UH]XOWDWXO vQ IRUPDW &69 --> <xsl:template match="punctaje"> <xsl:text>Nume si prenume,Proiect,Test,Bonus</xsl:text> <xsl:for-each select="punctaj"> <xsl:variable name="punctaj" select="." /> "<xsl:value-of select="@stud" />"<xsl:text /> <!-- LWHUP WLSXULOH GH SXQFWDMH RELQXWH --> <xsl:for-each select="('proiect', 'test', 'bonus')"> <xsl:variable name="tip" select="." />,"<xsl:text /> <!-- IRUPDWP GDWHOH QXPHULFH RUL JHQHUP -' --> <xsl:value-of select="if ($punctaj/nota[@tip = $tip])
  • 311. Tehnologii XML102 then format-number($punctaj/nota[@tip = $tip], '00.00') else '-'" />"</xsl:for-each> </xsl:for-each><xsl:text></xsl:text> </xsl:template> </xsl:stylesheet> $FHDVW IRDLH GH VWLOXUL H DSOLFDW GRFXPHQWXOXL ;0/ FX SXQFWDMHOH RELQXWH OD R GLVFLSOLQ üL JHQHUHD] R UHSUH]HQWare CSV (Comma Separated Values) a acestora, pentru ca ulteULRU V SRDW IL IRORVLW vQWU-un program de calcul tabelar. 9RP RELQH GH H[HPSOX R LHüLUH GH IRUPD (care poate fi ulterior UHGLUHFLRQDW vQWU-XQ ILüLHU punctaje.csv): D:saxon>java -jar saxon8.jar punctaje.xml csv-xslt2.xsl Nume si prenume,Proiect,Test,Bonus "Abageru Stefan","11.00","09.00","-" "Mocanu Madalina","-","-","01.00" "Moruz Mihai Alex","12.00","-","01.00" "Augustin Roxana Maria","10.00","-","01.00" "Dumbrava Andrei-Liviu","10.50","10.00","01.00" 3.4. Validarea documentelor XML Punerea problemei 2 SULP QHFHVLWDWH vQ FD]XO DGRSWULL WHKQRORJLHL ;0/ HVWH DFHHD FD LQIRUPDLLOH PDUFDWH vQ ;0/ V SRDW IL UHJVLWH UHXWLOL]DWH üL SDUWDMDWH vQWUH diYHUVH DSOLFDLL $VWIHO R FHULQ LPSRUWDQW HVWH GH D FXQRDüWH • setul de elemente/atribute ce pot fi specificate; • modul lor de structurare (e.g. RUGLQHD QXPUXO Pinim/maxim de DSDULLL FRQWH[WXO HWF); • WLSXO FRQLQXWXOXL • FH DQXPH HVWH YDOLG üL FH UHSUH]LQW HURDUH 6ROXLD HVWH DFHHD FD XQXO VDX PDL PXOWH JUXSXUL GH LQGLYL]L V VSHFLILFH PXOLPHD GH HOHPHQWH üL DWULEXWH SHUPLVH üL UHJXOLOH GH PDUFDUH DGLF tocmai modelul structural amintit în cadrul VHFLXQLL  D FDSLWROXOXL GH ID $FHVWH JUXSXUL GH LQGLYL]L UeSUH]LQW • o companie (e.g., Adobe – VHPQDWDUD VSHFLILFDLHL ;03 – ori Sun – definind modul de precizare a bibliotecilor de tag-uri JSP);
  • 312. Modele de date semistructurate. Familia XML 103 • o industrie (precum industria dispozitivelor mobile GLULMDW GH 2SHQ Mobile Appliance, organismul care a standardizat limbajul WML); • SHUVRDQH vPSUWüLQG XQ VFRS FRPXQ GH H[Hmplu, dezvoltatori ai XQHL DSOLFDLL SUHFXP -DEEHU VDX 2SHQ2IILFH
  • 313.  • SURGXFWRUL GH LQVWUXPHQWH VSHFLILFH tool vendors), precum Microsoft ori Oracle; • XQ FRQVRULX VDX RUJDQL]DLH QRQ-SURILW &RQVRULXO :HE VDX 2$6,6
  • 314.  0RGHOXO VWUXFWXUDO VH DSOLF XQHL FODVH GH GRFXPHQWH ;0/ vQ YHGHUHD YHULILFULL YLD XQ DQDOL]RU SURFHVRU VDX parser
  • 315. D FRUHFWLWXGLQLL LQVWDQHORU GH GRFXPHQWH DSDULQknd acelei clase. Se au în vedere aspecte privind: • modul de numire a elementelor/atributelor; • definirea regulilor de utilizare a acestora; • VSHFLILFDUHD VWUXFWXULL üL FRQLQXWXOXL • precizarea anumitor constrângeri; • RIHULUHD XQXL VHW GH FRQYHQLL GH QXPLUH ASDUH DüDGDU QHFHVLWDWHD VSHFLILFULL XQXL VHW GH constrângeri asociate GRFXPHQWHORU DVWIHO vQFkW GDWHOH ;0/ V ILH YHULIiFDWH GDF VXQW valide sau nu din punct de vedere strucWXUDO VDX DO WLSXOXL FRQLQXWXOXL &RQIRUP YDQ GHU 9OLVW 
  • 316.  PRGDOLWLOH GH precizare a constrângerilor se pot baza pe: • descrieri – DQXPLWH FRQVWUXFLL YRU SXWHD SUHFL]D DVHULXQL GH JHQXO ÅH[LVW XQ HOHPHQW <student> având un atribut nume care are FRQLQXWXO«µ DFHDVW PDQLHU H DGRSWDW GH VSHFLILFDLLOH '7' üL XML Schema, descULVH vQ VHFLXQLOH XUPWRDUH • reguli – se pot specifica, într-R PDQLHU DSURSLDW GH ;6/7 GLYHUVH FRQVWUXFLL SUHFXP ÅRULFH HOement <student> va avea un atribut nume LDU FRQLQXWXO DFHVWXL DWULEXW VH YD FRQIRUPD UHJulii…”; acest SXQFW GH YHGHUH H vPSUWüLW GH 6FKHPDWURQ • üDEORDQH – VH DUH vQ YHGHUH IRORVLUHD GH üDEORDQH patterns) structurale, pe baza unor potriviri (match); astfel, se pot preciza FRQVWUXFLL GH IRUPD ÅRULFH GoFXPHQW GLQ FODVD VWXGHQW WUHEXLH V VH SRWULYHDVF XUPWRUXOXL üDEORQ«µ R DVWfel de abordare este VSHFLILF PRGHOXOXL 5(/$; 1* FH YD IL SUH]HQWDW XOWerior. Document Type Definition (DTD) 'XS FXP DP SUHFL]DW vQ FDGUXO VXEFDSLWROXOXL DQWHULRU ILHFUXL GRFXPHQW ;0/ L VH SRDWH DVRFLD FX FDUDFWHU RSLRQDO R GHILQLLH D WLSXOXL GH dRFXPHQW $FHDVW GHILQLLH QXPLW '7' UHSUH]LQW R VSHFLILFDUH IRUPDO
  • 317. Tehnologii XML104 D XQXL WLS GH GRFXPHQW 'DF '7'-XO OLSVHüWH GRFXPHQWXO ;0/ WUHEXLH V respecte un nuPU PLQLP GH FRQVWUkQJHUL DGLF WUHEXLH V ILH GRDU bine formatat (well formed). 2 VSHFLILFDLH '7' SRDWH IL LQWHUQ VDX H[WHUQ GRFXPHQWXOXL ;0/ SH care-O YDOLGHD] 5HJXOLOH VLQWDFWLFH IRORVLWH vQ Fadrul DTD-ului provin de la SGML, adoptându-se definirea unor meta-elemente. Prin intermediul unui '7' VH SRW GHILQL VWUXFWXUD FRQLQXWXOXL PRGXO GH DSDULLH D HOHPHQWHORU üL maniera în care sunt imbricate acestea. '7' HVWH H[SULPDW FD XQ VHW GH DILUPDLL LQVWUXFLXQL
  • 318. GHFODUDWLYH XWLOL]kQG R VLQWD[ VLPSO SUHFL]DW vQ VSHFLILFDLD %UD et al. (2004). Un '7' SUHFL]HD] XQ WLS GH GRFXPHQW YLD R FRnstruFLH GH IRUPD <!DOCTYPE HOHPHQWBUDGDFLQ [ 'HFODUDLL GH HOHPHQWH DWULEXWH HQWLWL ]> Specificarea elementelor Pentru modelul structural privitor la antologia de poezii, am putea scrie GHILQLLD XUPWRDUH <!ELEMENT antologie (poem+)> <!ELEMENT pRHP WLWOX" VWURI
  • 319. ! <!ELEMENT titlu (#PCDATA)> (/(0(17 VWURI YHUV
  • 320. ! <!ELEMENT vers (#PCDATA)> )LHFDUH GHFODUDLH UHSUH]LQW R GHILQLLH IRUPDO D XQXL HOHPHQW 2 GHFODUDLH PHWD-HOHPHQW
  • 321. HVWH GHOLPLWDW GH VHPQHOH ŵ üL Å!µ SULPul FDUDFWHU ILLQG VHPQXO GH H[FODPDLH XUPDW LPHGLDW GH XQ FXYkQW-cheie ;0/ FDUH GHVHPQHD] WLSXO RELHFWXOXL FH YD IL GHILQLW HOHPHQW OLVW GH atribute, enWLWDWH HWF
  • 322.  )LHFDUH GHILQLLH HVWH FRPSXV GLQWU-un nume sau un grup de nume (ne-terminali în jaUJRQXO OLPEDMHORU IRUPDOH
  • 323. üL XQ FRQinut (ne-WHUPLQDOL üL WHUPLQDOL
  • 324.  'XS FXP VH REVHUY ILHFDUH GHILQLLH SRDWH IL asiPLODW FX R SURGXFLH D XQHL JUDPDWLFL IRUPDOH YH]L -XFDQ 
  • 325.  3ULOH FRPSRQHQWH DOH XQHL GHFODUDLL VXQW VHSDUDWH GH VSDLL DOEH VSDLX caractere tab VDX OLQLH QRX
  • 326.  ÍQFDGUDW vQWUH SDUDQWH]H FHD GH-D GRXD SDUWH D GHILQLLHL VH QXPHüWH model-FRQLQXW VSHFLILFkQG FH DOWH HOHPHQWH SRW DSUHD vQ FDGUXO HOHPHQWXOXL VSHFLILFDW &RQLQXWXO XQXL HOHPHQW SRDWH IL • XQ üLU GH FDUDFWHUH (desemnat de constanta #PCDATA – parsed character data); • YLG VH IRORVHüWH FXYkQWXO-cheie EMPTY);
  • 327. Modele de date semistructurate. Familia XML 105 • RULFH DOW PDUFDMüLU GH FDUDFWHUH SUHFL]DW YLD ANY), facilitând H[WLQGHUHD XOWHULRDU D PRGHOXOXL VWUXFWural. 0DQLHUD GH DSDULLH D XQXL HOHPHQW HVWH VSHFLILFDW GH indicatorii de apa- ULLH FRQIRUP WHRULHL H[SUHVLLORU UHJXODWH $VWIHO XQ HOHPHQW SRDWH DSUHD • R VLQJXU GDW VH SUHFL]HD] QXPHOH HOHPHQWXOXL UHVSHFWLY
  • 328.  • GH RULFkWH RUL LQFOXVLY QLFLRGDW VH IRORVHüWH VHmnul „*”); • PFDU R GDW VH XWLOL]HD] operatorul „+”); • de zero sau unu ori (se recurge la „?”). 2UGLQHD DSDULLHL HOHPHQWHORU SRDWH IL SUHFL]DW YLD DüD-QXPLLL conectori: • FDUDFWHUXO YLUJXO ŵ VHPQLILF R VHFYHQ GH HOHPHQWH – FRPSRQHQWHOH WUHEXLH V DSDU REOLJaWRULX vQ RUGLQHD SUHFL]DW • VHPQXO Å_µ GHVHPQHD] R DOWHUQDWLY – doar una dintre compo- QHQWH SRDWH DSUHD OD XQ PRPHQW GDW )LJXUD  'HILQLLLOH '7' DOH HOHPHQWHORU SULYLWRDUH OD PHPRUDUHD XQRU SUoiecte 8Q DOW H[HPSOX FDUH VH UHIHU OD PRGXO GH VWUXFWXUDUH D LnIRUPDLLORU priviWRDUH OD SURLHFWHOH SURSXVH OD R GLVFLSOLQ HVWH LOXVWUDW GH ILJXUD  Precizarea atributelor &D üL HOHPHQWHOH VH GHFODU vQ '7' IRORVLQGX-VH R VLQWD[ VLPiODU De exemplu, pentru a specifica atributele asociate elementului-UGFLQ <antologie> vom scrie: <!ATTLIST antologie coordonator CDATA #REQUIRED data CDATA #IMPLIED >
  • 329. Tehnologii XML106 Tipul valorii unui atribut poate fi: • XQ üLU GH FDUDFWHUH – desemnat de CDATA – character data; • un identificator unic – precizat prin ID; • R UHIHULQ OD XQ LGHQWLILFDtor – VSHFLILFDW YLD IDREF; • R UHIHULQ OD R HQWLWDWH – VWDELOLW SULQ ENTITY; • XQ üLU GH FDUDFWHUH DOIDQXPHULFH – precizat de NMTOKEN; • o enumerare de valori – GHVHPQDW GH ILHFDUH YDORDUH vQ SDUWH GHOLPLWDW GH FDUDFWHUXO Å_µ Un atribut poate fi declaraW V DSDU • obligatoriu – VH IRORVHüWH FODX]D #REQUIRED; • RSLRQDO – se recurge la #IMPLIED; • fix – VH IRORVHüWH vQWRWGHDXQD R YDORDUH a priori VSHFLILFDW YLD #FIXED. 3HQWUX VSHFLILFDUHD DWULEXWHORU UHIHULWRDUH OD SURLHFWH SXWHP DGRSWD VROXLD din figura 18. )LJXUD  'HILQLLLOH '7' DOH DWULEXWHORU UHIHULWRDUH OD SURLHFWH 8Q DOW H[HPSOX SULYHüWH VSHFLILFDUHD JHQHDORJLHL XQRU SHUVRDQH SHQWUX fiecare individ putând fi precizate diverse evenimente importante (e.g., QDüWHUHD
  • 330. – definite via elemente – üL DQXPLWH LQIRUPDLL XQ LGHQWLILFDWRU JHQXO VSDLXO GH QXPH Iixat) – desemnate de atribute. <!ELEMENT person (name | birth | death | note | father | mother)*> <!ATTLIST person id ID #REQUIRED gender (M | F) #IMPLIED xmlns CDATA #FIXED "http://person.org/gen/" >
  • 331. Modele de date semistructurate. Familia XML 107 'HILQLUHDHQWLWLORU 'XS FXP DP Y]XW PDL VXV ;0/ RIHU R PHWRG IOH[LELO üL IDFLO GH FRGLILFDUH üL UHIHUHQLHUH D GLIHULWHORU SUL DOH FRQLQutului unui document, într-un mod portabil. Cuvântul entitate are un sens special: însHDPQ R SDUWH GH WH[W FDUH DUH DVLJQDW XQ QXPH R HQWLWDWH SRDWH IL XQ üLU GH FDUDF- tere ori conLQXWXO XQXL ILüLHU WH[W H[WHUQ
  • 332.  (QWLWLOH VH FODVLILF vQ GRX WLSXUL HQWLWL JHQHUDOH üL HQWLWL FX SDUDPHWUL (QWLWLOH JHQHUDOH VH împart, la rândul ORU vQ HQWLWL LQWHUQH DQDOL]DWH HQWLWL H[WHUQH DQDOL]DWH üL HQWLWL H[WHUQH QHanalizate. ÍQ FDGUXO XQXL '7' HQWLWLOH VXQW GHILQLWH SULQ FRQVWUXcLD <!ENTITY. (QWLWLOH LQWHUQH DQDOL]DWH VH UHIHU vQ JHQHUDO OD XQ WH[W SH FDUH WUHEXLH V îl expanGH]H SURFHVRUXO ;0/ DWXQFL FkQG vQWkOQHüWH R UHIHULUH OD DFHD HQWLWDWH ,DW XQ H[HPSOX vQ FDUH DYHP GHILQLWH XUPWRDUHOH <!ELEMENT pictor (#PCDATA)> <!ENTITY sdali "Salvador Felipe Jacinto Dali i Domenech"> Entitatea sdali DU SXWHD IL XWLOL]DW DVWIHO: <pictor>&sdali;</pictor> 9DORDUHD XQHL HQWLWL FDUH YD IL H[SDQGDW GH SURFHVRUXO ;0/ QX WUHEXLH V FRQLQ FDUDFWHUHOH Å µ ŵ VDX DSRVWURI üL SRDWH IDFH UHIHULQH OD DOWH HQWLWL (QWLWLOH H[WHUQH DQDOL]DWH H[SULP XQ WH[W FDUH WUHEXLH H[SDQGDW GLIHUHQD ID GH FHOH DQWHULRDUH ILLQG DFHHD F HQWiWLOH H[WHUQH UHSUH]LQW UHIHULQH care pot fi utilizate de mai multe documente. Orice schimbare care are loc într-R DVWIHO GH HQWLWDWH HVWH LPHGLDW DFWXDOL]DW vQ GRFXPHQWHOH FDUH R XWLOL]HD] ([LVW GRX WLSXUL GH HQWLWL H[WHUQH DQDOL]DWH HQWLWL SULYDWH FDUH VH GHFODU IRORVLQG FXYkQWXO-cheie SYSTEM üL HQWLWL SXEOLFH Geclarate prin PUBLIC (QWLWLOH SULYDWH VXQW XWLOH vQ FD]XULOH vQ FDUH XQ JUXS GH SHUVRDQH UHVWUkQV IRORVHüWH DFHVWH HQWLWL (ntiWLOH SXEOLFH DX JDPD GH XWLOL]DUH PXOW PDL ODUJ 2 H[HPSOLILFDUH DU SXWHD IL XUPWRDUHD <!ENTITY CapDoi SYSTEM "cap2.xml"> (QWLWLOH H[WHUQH QHDQDOL]DWH VH UHIHU OD GRFXPHQWH FDUH QX VXQW GH WLS ;0/ üL GHFL QX WUHEXLH V ILH SUHOXFUDWH GH DQDOL]RDrele XML. Analog HQWLWLORU SUHFHGHQWH HQWLWLOH GH DFHVW WLS SRW IL SULYDWH VDX SXEOLFH (QWLWLOH LQWHUQH FX SDUDPHWUL pot fi utilizate doar în interiorul DTD-ului, în locul prefixului „&” fiind folosit „%”. Suplimentar, între cuvântul-cheie ENTITY, SURFHQW üL QXPHOH HQWLWLL WUHEXLH V DSDU REOLJDWRULX VSDLL DOEH 8Q H[HPSOX HVWH FHO GH PDL MRV vQ FDUH VH SUHFL]HD] SHQWUX XQ HYHQLPHQW DVRFLDW XQHL SHUVRDQH R UHIHULQ XQ ORF üL R GDW FDOHQGDULVWLF
  • 333. Tehnologii XML108 <!ENTITY % event "(reference*, place?, date?)"> <!ELEMENT birth %event;> <!ELEMENT death %event;> (QWLWLOH H[WHUQH FX SDUDPHWUL VXQW DVHPQWRDUH HQWLWLORU H[WHUQH JHQHUDOH DQDOL]DWH XWLOL]HD] DFHOHDüL FXYLQWH-FKHLH üL DX DFHODüL VFRS FD HQWLWile interne cu parametri: <!ENTITY % student SYSTEM "http://www.infoiasi.ro/std.dtd"> /D DGUHVD VSHFLILFDW H[LVW ILüLHUXO std.dtd vQ FDUH HVWH GHILQLW HQWLWDWHD student $FHDVW HQWLWDWH SRDWH IL XWLOL]DW GRDU vQ LQWHULRUXO '7'-ului documentului. ÍQ ;0/ H[LVW DQXPLWH FDUDFWHUH FDUH QX WUHEXLH V DSDU vQ IRUPD ORU QRUPDO vQ DQXPLWH ORFXUL GLQ WH[W 7RWXüL SHQWUX D OH SXWHD VSHFLILFD VH folosesc HQWLWLOH SUHGHILQLWH FDUH UHIHU DFHVWH FDUDFWHUH SUHFL]DWH vQ FDGUXO VHFLXQLL  D DFHVWXL FDSLWRO 'H DVHPHQHD VH SRW IRORVLGHILQL üL UHIHULQH GH tip caracter, care SUHFL]HD] XQ FDUDFWHU SULQ LQWHUPHGLXO FRGXOXL VX QXPHULF SUHIL[DW GH Å µ üL XUPDW GH ŵ ,DW XQ H[HPSOX <!ENTITY quot "&#34;"> ÍQ vQFKHLHUHD DFHVWHL VHFLXQL LQGLFP IDSWXO F DQXPLWH HQWLWL SRW IL publice, în general înregistrate de ISO sau alte orgaQL]DLL <!ENTITY % ISOpub PUBLIC "ISO 8879-1986//ENTITIES Publishing//EN"> <!ENTITY % IBMchars PUBLIC "+//IBM//ENTITIES IBM PC Character Set//EN"> 0DUFD ŵ VHPQLILF IDSWXO F HQWLWDWHD VDX UHVXUVD IRORVLW HVWH înregiVWUDW (QWLWLOH QHvQUHJLVWUDWH DX Å-//” în compoQHQ Folosirea DTD-urilor 2 LQVWDQ GH GRFXPHQW SRDWH DYHD DWDüDW R GHFODUDLH D WLSXOXL FUXLD vL DSDULQH $FHDVW GHFODUDLH VH LQFOXGH YLD <!DOCTYPE ...>. DTD-ul poate fi specificat chiar în cadruO GRFXPHQWXOXL GXS FXP VH poate rePDUFD GLQ H[HPSOXO XUPWRU <?xml version="1.0"?> <!-- 3HQWUX YDOLGDUH VH IRORVHúWH XQ '7' LQWHUQ --> <!DOCTYPE projects [ <!ELEMENT projects (project+)> <!ELEMENT project (title, desc?, stud, url?)> <!ELEMENT title (#PCDATA)> <!ELEMENT desc (#PCDATA)>
  • 334. Modele de date semistructurate. Familia XML 109 <!ELEMENT stud (#PCDATA)> <!ELEMENT url (#PCDATA)> <!ATTLIST projects update CDATA #FIXED "23 octombrie 2005" > <!ATTLIST project class (A|B|C) "A" > ]> <projects> <project class="A"> <title>Super</title> <desc>Un super proiect</desc> <stud>1</stud> <url>http://www.super.ro/</url> </project> </projects> 'H DVHPHQHD DYHP SRVLELOLWDWHD V IDFHP UHIHULUH OD XQ '7' H[WHUQ stocat într-XQ ILüLHU ORFDO <!DOCTYPE projects SYSTEM "projects.dtd"> <projects>...</projects> 6H SRDWH IRORVL üL XQ '7' GHFODUDW SXEOLF GLVSRQLELO RULFXL – în cele de PDL MRV R LQVWDQ GH GRFXPHQW +70/ VH GHFODU FD DSDULQkQG WLSXOXL GH GRFXPHQW +70/  SURILOXO WUDQ]LLoQDO
  • 335. VSHFLILFDW GH &RQVRULXO :HE <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 'HVLJXU VH SRDWH SUHFL]D üL 85,-XO OD FDUH VH JVHüWH '7'-ul documentului: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 9DOLGDUHD XQHL LQVWDQH GH GRFXPHQW FRQIRUP '7'-ul precizat se poate realiza prin intermediul unui procesor XML cu suport pentru validare (e.g., OLE[PO ;HUFHV 06;0/ HWF
  • 336.  D VH YHGHD üL FHOH GHVFULVH vQ FDSLWROXO  3XWHP YDOLGD GRFXPHQWHOH ;0/ üL YLD XWLOLWDUXO xmllint rulând sub Linux üL FDUH SRDWH IL XWLOL]DW GLUHFW GLQWU-un editor de text precum Kate. În figura XUPWRDUH VH REVHUY OLVWD GH HURUL GH YDOLGDUH VHPQDODWH 3URJUDPXO xmllint poate realiza validarea conform mai multor scheme (DTD, XML 6FKHPD 5(/$; 1* üL 6DEORWURQ
  • 337. 
  • 338. Tehnologii XML110 Figura 19. Validarea unui document XML direct în cadrul editorului Kate din mediul KDE Folosind un DTD, avem posibilitatea convertirii documentelor SGML (de H[HPSOX SDJLQLOH :HE FDUH QX VH FRQIRUPHD] QRXOXL VWDQGDUG ;+70/ aliniat XML) în format conform speciILFDLLORU ;0/ vQ YLJRDUH ÍQ DFHVW sens, putem recurge la programul osx SXV OD GLVSR]LLH Ge Open SP, IRORVLQG XQ '7' GRULW vQ H[HPSOXO GH PDL MRV XWLOL]P '7'-ul oferit de Screem, un mediu de dezvoltare Web rulând în Linux). De la prompterul
  • 339. Modele de date semistructurate. Familia XML 111 interpretorului de comenzi bash, vom tasta (numele elementelor vor fi scrise cu litere mici, iar tag-uULOH YLGH YRU IL SVWUDWH
  • 340.  (infoiasi)$ osx -xempty -xlower -l/usr/share/screem/dtd/loose.dtd pagina.html >pagina.xml 'RFXPHQWXO GH WHVW SRDWH DYHD XQ FRQLQXW GH JHQXO SHUPLV GH 6*0/ dar incorect din punctul de vedere al XML): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/usr/share/screem/dtd/loose.dtd"> <!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> --> <HTML> <head> <title>O pagina de test</title> <link href=stiluri.css type='text/css' rel=stylesheet> <body bgColor=white text=blue> <p align=center>Aceasta este o pagina de <b>test</b>. <hr size=1> </body> </HTML> 5H]XOWDWXO RELQXW HVWH YL]LELO vQ ILJXUD  Figura 20. Documentul XML rezultat în urma conversiei
  • 341. Tehnologii XML112 Schemele XML &DUDFWHUL]DUHüLXWLOL]UL 6SHFLILFDLLOH XML Schema )DOOVLGH üL :DOPVOH 
  • 342. DX GUHSW VFRS RIHULUHD unei sintaxe XML pentru specificarea unei scheme de validare a strucWXULL üL WLSXOXL FRQLQXWXOXL GRFXPHQWHORU ;0/ O VFKHP UHSUH]LQW R VSHFLILFDLH IRUPDO D JUDPDWLFLL DVRFiate unui GRFXPHQW ;0/ RIHULQG R IOH[LELOLWDWH VSRULW vQ FRPSDUaLH FX '7'-urile. 2 DVWIHO GH VFKHP UHSUH]LQW Xn document XML stocat într-XQ ILüLHU FDUH de obicei are extensia xsd (XML Schema Definition). &D üL XQ GRFXPHQW '7' R VFKHP ;0/ GHILQHüWH R FODV GH GRFXPHQWH XML conformându-se unui model structural, suplimentar specificând un sistem de tipuri de date în termenii infoset-XOXL 3HQWUX D SXWHD IL YHULILFDW YDOLGLWDWHD R LQVWDQ D XQHL FODVH GH GRFXPHQWH ;0/ WUHEXLH V DLE DVRFLDW R VFKHP ;0/ $FHVWH DVSHFWH VXQW DVHPQWRDUH FHORU GH OD SDUD- digPD RULHQWDW SH RELHFW 2 VFKHP YD VSHFLILFD PRGXO GH DSDULLH üL WLSXULOH GH GDWH SH FDUH OH SRW OXD YDORULOH FRQVWUXFLLORU ;0/ 5H]XOWDWXO REiQXW vQ XUPD XQHL YDOLGUL soldate cu succes este numit PSVI (Post-Schema Validation Infoset). 6FKHPHOH ;0/ vüL JVHVF YDULDWH XWLOL]UL vQ GLYHUVH GRPenii precum: • verificarea tipurilor de date în contextul sistemelor de baze de date UHODLRQDOH
  • 343.  PDüLQLORU YLUWXDOH -90 &/5
  • 344. HWF • VHULDOL]DUHD DXWRPDW D GDWHORU – vezi cele expuse în capitolul 3; • LQYRFDUHD OD GLVWDQ D PHWRGHORU 50, – Remote Method Invocation, SOAP – Simple Object Access Protocol); • generarea de cod-VXUV • editoare „inteligente”; • validatoare generale de date (e.g., validarea formularelor electronice). &RQVWUXFLLOH ;0/ 6FKHPD WUHEXLH V DSDULQ VSDLXOXL GH QXPH LQGLFDW de adresa http://www.w3.org/2001/XMLSchema. Atributele privitoare la scheme care apar în cadrul unei instanH D XQHL FODVH GH GRFXPHQWH YRU SURYHQL GLQ VSDLXO GH QXPH GHVHPQDW GH http://www.w3.org/2001/ XMLSchema-instance. &RQVWUXFLLGHED] 8Q GRFXPHQW ;0/ 6FKHPD DUH GUHSW UGFLQ HOHPHQWXO <xsd:schema>. 'HILQLUHD VDX LQVWDQLHUHD XQXL HOHPHQW VH YD IDFH SULQ <xsd:element>, iar în cazul unui atribut, via <xsd:attribute>.
  • 345. Modele de date semistructurate. Familia XML 113 9DORULOH SHUPLVH SHQWUX XQ HOHPHQWDWULEXW DSDULQ XQXL WLS GH GDWH (simplu sau complex), specificat prin <xsd:simpleType> üL UHVSHFWLY <xsd:complexType>. Tipuri de date XML Schema $VHPQWRU GHILQLULL XQRU WLSXUL GH GDWH üL YDULDELOH vQWU-un limbaj de programare, într-R VFKHP ;0/ ILHFDUH LQVWDQ GH HOHPHQW WUHEXLH V DSDULQ XQHL FODVH WLS
  • 346. GH HOHPHQWH Tipurile simple, predefinite ori derivate din cele predefinite, descriu FRQLQXWXO GDWHORU WH[WXDOH ÍQ DFHVW FD] QX SHUPLWH FD XQ HOHPHQW V LQFOXG DOWH HOHPHQWH üL QLFL V DLE DVRFLDWH DWUibute. Tipurile simple pot fi folosite üL SHQWUX VSHFLILFDUHD FRQinutului atributelor. Tipurile complexe descriu datele (semi)structurate. Se permite ca HOHPHQWHOH V LQFOXG DOWH HOHPHQWH YLD UHJXOL GH DSDULLH
  • 347. üL V DLE asociate atribute. Elementele de tip comSOH[ YRU SXWHD FRQLQH • GHFODUDLL GH HOHPHQWH <element name="nume" type="tip" />; • UHIHULQH OD HOHPHQWH GHMD GHILQLWH <element ref="nume" reguli_aparitie="valori" />; • GHFODUDLL GH DWULEXWH <attribute name="nume" type="tip" />. Firesc, tipurile complexe nu pot fi folosite în contextul speciILFULL WLSului valorilor atributelor XML. &RQVRULXO :HE D SXV OD GLVSR]LLH R SDOHW ODUJ GH WLSXUL SUHGHILQLWH SULPLWH üL GHULYDWH
  • 348. – GHWDOLL vQ %LURQ üL 0DOKRWUD 
  • 349.  2 SDUWH GLQWUH HOH sunt enumerate în continuare: • numerice: byte, unsignedByte, hexBinary, integer, positiveInteger, negativeInteger, int, unsignedInt, long, decimal, float, double üL Dltele; • logice: boolean; • SULYLWRDUH OD GDW üL WLPS time, dateTime, duration, date, gYear, gMonth, gDay etc.; • üLUXUL GH FDUDFWHUH string, token, Name, QName üL DOtele; • adrese: anyURI; • FRQVWUXFLL ;0/ ID, IDREF, ENTITY etc. ,HUDUKLD WLSXULORU GH GDWH ;0/ 6FKHPD HVWH LOXVWUDW vQ Iigura 21.
  • 350. Tehnologii XML114 Figura 21. Tipurile de date XML Schema Putem defini tipuri simple derivate din cele predefinite via <xsd:simpleType>. Noul tiS GH GDWH VSHFLILFDW SRDWH IL R UHVWULFLH D XQXL WLS deja existent prin intermediul unor constrângeri (facets). De asemenea, putem recurge la precizarea unei liste de valori (via <xsd:enumeration>) ce va forma tipul sau a unui interval de valori (construcLLOH <xsd:minInclusive>, <xsd:maxInclusive>, <xsd:minExclusive> üL <xsd:maxExclusive>). Constrângerile (facets) permise vor putea preciza: • lungimea: <xsd:length> • OXQJLPHD PLQLP <xsd:minLength> • OXQJLPHD PD[LP <xsd:maxLength> • un model (pattern): <xsd:pattern> • FRQWUROXO VSDLLORU DOEH <xsd:whiteSpace> • QXPUXO GH FLIUH <xsd:totalDigits> • QXPUXO GH FLIUH ]HFLPDOH <xsd:fractionDigits>
  • 351. Modele de date semistructurate. Familia XML 115 8Q H[HPSOX HVWH XUPWRUXO vQ FDUH YRP VSHFLILFD GRX Wipuri simple. Primul va putea fi folosit pentru a verifica valorile SUHFL]kQG QXPUXO GH FDSLWRO DO FXSULQVXOXL XQHL FUL LQWHUYDO GH OD  OD 
  • 352.  LDU DO GRLOHD YD reprezenta adresa de e-mail D XQHL SHUVRDQH üLU GH FDUDFWHUH FDUH WUHEXLH V inFOXG Å@µ üL V VH WHUPLQH FX XQ Å.µ üL XQ VXIL[ GH GRX-patru caractere): <xsd:simpleType name="nrcapType"> <!-- UHVWULFLRQP WLSXO GH ED] LQWHJHU --> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="0" /> <xsd:maxInclusive value="8" /> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="addrType"> <!-- UHVWULFLRQP WLSXO GH ED] VWULQJ --> <xsd:restriction base="xsd:string"> <!-- H[SUHVLH UHJXODW vQ VWLOXO 3HUO --> <xsd:pattern value=".+@.+.(.){2,4}" /> </xsd:restriction> </xsd:simpleType> Tipurile VLPSOH QRL YRU IL IRORVLWH V GHVFULH YDORULOH HOHPHQWH- ORUDWULEXWHORU DWDüDUHD DFHVWRUD XQRU FRQVWUXFLL ;0/ SXWkQG DYHD ORF ILH vQ FDGUXO VFKHPHL OD GHFODUDUHD XQXL HOHPHQW ILH vQ FDGUXO LQVWDQHL YLD atributul xsi:type. Pentru primul caz, putem scrie (aici e cazul unui atribut de tip nrcapType): <xsd:attribute name="numar" type="nrcapType" /> ÍQ D GRXD VLWXDLH YRP GHFODUD – folosim un URI propriu pentru a VSHFLILFD VSDLXO GH QXPH SULYLWRU OD YRFDEXODUXO ;0/ SULYLQG FXSULQVXO XQHL FUL YRFDEXODU FH YD SXWHD IL YDOLGDW JUDLH XQHL VFKHPH ;0/ <capitol xmlns:c='http://www.infoiasi.ro/cuprins/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='c:numar'>5</capitol> 'H DVHPHQHD YRP SXWHD SUHFL]D VLPEROXO Å_µ VHPQLILF R DOWHUQDWiY
  • 353. : • UHJXOL UHVWULFLL
  • 354. GH DSDULLH D XQHL LQVWDQH GH HOement: minOccurs="QXPU" üL maxOccurs="QXPU | unbounded"; • UHJXOL GH DSDULLH D XQXL DWULEXW use="required | optional | prohibited";
  • 355. Tehnologii XML116 • YDORDUHD SUHGHILQLW D XQXL DWULEXW YLD default; • stabilirea de valori particulare pentru elemente sau atribute: fixed. 'LQ FHOH SUHFL]DWH SkQ DFXP GHGXFHP F WLSXULOH VLPSOH SRW IL XWLOL]DWH doar pentru a descrie date-caracter. Vom recurge la tipurile complexe pentru a descrie structura unui document, recurgând la <xsd:complexType>. Un WLS FRPSOH[ SRDWH DYHD XQ FRQLQXW VLPSOX <xsd:simpleContent>) sau unul complex. &RQLQXWXO VLPSOX vQVHDPQ F XQ HOHPHQW YD SXWHD LQFOXGH DWULEXWH extinzând astfel modelul-FRQLQXW 2 SULP PHWRG HVWH GHULYDUHD SULQ H[WHQVLH YLD HOHPHQtul <xsd:extension>. 'H H[HPSOX GRULP V VSHFLILFP F XQ DXWRU DO XQXL FDSLWRO GH FDUWH SRVHG R DGUHV GH e-mail 'DF LQLLDO DYHDP <xsd:element name="autor" type="xsd:string" />, în acest moment vom putea scrie: <xsd:element name="autor"> <xsd:complexType> <!-- GHULYP GLQWU-un tip simplu --> <xsd:simpleContent> <xsd:extension base="xsd:string"> <!-- VSHFLILFP DSDULLD RSLRQDO
  • 356. a atributului "email" --> <xsd:attribute name="email" type="addrType" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:element> Atributele vor fi definite prin intermediul <xsd:attribute>, putând fi declarate global (la nivelul schemei) sau local (în cadrul unui tip complex). De asemenea, ele pot fi FDOLILFDWH SUHIL[DWH GH VSDLXO GH QXPH DOHV
  • 357. VDX QX 6H SHUPLWH üL VSHFLILFDUHD JUXSXULORU GH DWULEXWH YLD <xsd:attributeGroup>. 'HVLJXU FRQVWUXFLLOH minOccurs üL maxOccurs nu au sens. Valorile DWULEXWHORU WUHEXLH vQWRWGHDXQD V ILH ED]DWH SH WLSXUL VLmple. Un atribut poate fi specificat, interzis (prohibited
  • 358.  RSLRQDO optional) sau obligatoriu (required). 2 D GRXD PHWRG GH VSHFLILFDUH D XQXL WLS FRPSOH[ FX FRQLQXW VLPSOX HVWH FHD SULQ GHULYDUH SULQ UHVWULFLH UHDOL]DW SULQ LQWHUPHGLXO constrângerilor (facets
  • 359.  'H H[HPSOX SXWHP FRQVWUkQJH XQ üLU GH FDUDFWHUH la o anumiW OXQJLPH PD[LP – XWLO DWXQFL FkQG GRULP FD GDWHOH ;0/ V ILH stocate ulterior într-R WDEHO
  • 360. Modele de date semistructurate. Familia XML 117 'H H[HPSOX SXWHP LPSXQH FD XQ WLWOX GH FDSLWRO V ILH GH PD[LPXP  GH caractere, având un atribut limba desemnând limba în care e scris textul: <!-- LQLLDO --> <xsd:complexType name="titluType"> <xsd:simpleContent> <xsd:extension base="xsd:token"> <xsd:attribute name="limba" type="xsd:language"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <!-- acum --> <xsd:element name="titlu"> <xsd:complexType> <xsd:simpleContent> <xsd:restriction base="titluType"> <xsd:maxLength value="50"/> <xsd:attribute name="limba" type="xsd:language"/> </xsd:restriction> </xsd:simpleContent> </xsd:complexType> </xsd:element> Ulterior, putem declara ca atributul limba V ILH LQWHU]LV <xsd:attribute name="limba" use="prohibited"/> Conchizând, derivarea prin extensie este folositoare doar pentru a DGXJD DWULEXWH XQXL HOHPHQW QX SRDWH VFKLPED WLSXO GH GDWH DO HOHPHQWXOXL sau al atributelor deja specificate). Cea prin UHVWULFLH VH GRYHGHüWH PDL IOH[LELO SXWkQG UHVWULFLRQD FRQLQXWXO QRGXULORU GH WLS WH[W VDX DO DWULEXWHORU GLQ FRPSRQHQD XQXL HOHPHQW 'H DVHPHQHD SULQ UHVWULFLH VH pot elimina atribute nedorite. 6SHFLILFDUHD XQXL WLS FX FRQLQXW FRPSOH[ YL]HD] GHILQLUHD OLVWHL üL ordinii sub-HOHPHQWHORU üL DWULEXWHORU VDOH &RQLQXWXO XQXL HOHPHQW SRDWH IL VSHFLILFDW V ILH üL • mixt (sub-elemente sau date-caracter): <xsd:complexType mixed="true">; • YLG QX YD FRQLQH GHFkW GHFODUDLL GH DWULEXWH
  • 361.  Pentru a preciza dLYHUVH PRGHOH DOH FRQLQXWXOXL VH UHFXUJH OD FRQVWUXFLL UHIHULWRDUH OD • DOWHUQDWLY <xsd:choice>;
  • 362. Tehnologii XML118 • VHFYHQ <xsd:sequence>; • grupare: <xsd:group>; • DSDULLH D WXWXURU HOHPHQWHORU vQ RULFH RUGLQH <xsd:all>. 6H SHUPLWH FD üL FRQLQXWXO FRPSOH[ V SRDW IL GHULYDW SULQ UHVWULFLL VDX extensii, dintr-un tip complex. 3UHFL]DUHDOHJWXULORUXQLFLWLLüLFKHLORU 3ULQ LQWHUPHGLXO LGHQWLILFDWRULORU üL UHIHULQHORU OD LGHQWLILFDWRUL DYHP posibiliWDWHD V UHDOL]P OHJWXUL vQWUH GLYHUVH FRnVWUXFLL ;0/ YLD LGentifi- FDWRUL XQLFL $FHDVWD VH UHDOL]HD] FX DMXWRUXO WLSXULORU ID üL IDREF speci- ILFDWH GH UHFRPDQGDUHD ;0/ ÍQ FDGUXO VFKHPHORU ;0/ SXWHP SUHFL]D üL SUHIL[XO XQXL VSDLX GH QXPH SHQWUX D HYLWD DPELJXLWLOH 'H DVHPenea, se permite ca tipul ID V ILH SUHFL]DW DWkW SHQWUX DWULEXWH FkW üL SHQWUX HOHPHQWH 6XSOLPHQWDU ;0/ 6FKHPD RIHU SRVLELOLWDWHD FD YDORDUHD XQXL HOHPHQWDWULEXW V ILH UHVWULFLRQDW V DSDU GRDU R VLQJXU GDW $FHDVW resWULFLH VH LPSXQH YLD <xsd:unique> $VWIHO UHODWLY OD R PXOLPe de ele- PHQWH VHOHFWDWH SULQ H[SUHVLL ;3DWK VH LGHQWLILF XQ ÅFkPSµ DO HOHPHQWX- lui/atributului a cUXL YDORDUH WUHEXLH V ILH XQLF vQ FDGUXO XQHL LQVWDQH de document. În jargonul bazelor de date, acest „câmp” e considerat cheie. Un exemplu tipic este DFHOD vQ FDUH LPSXQHP FD R FDUWH V DLE XQ DWULEXW ISBN unic în cadrul unei biblioteci. În cele de mai jos, în contextul unui catalog de produse, imSXQHP F QX SRW H[LVWD GRX VXEFDWHJRULL GH SURGXVH FX DFHODüL QXPH üL FDUH DX DFHODüL SULQWH SHQWUX ILHcare element <subcateg> FDWHJRULD FUHLD vL DSDULQH üL QXPHOH WUHEXLH V ILH XQLFH
  • 363.  <xsd:element name="subcateg" type="subcategType"> <xsd:unique name="subcateg_unica_nume_id_parinte"> <!-- VHOHFWP HOHPHQWXO FUXLD vL LPSXQHP FRQGLLD Ge unicitate a perechii atributelor 'id_parinte', 'nume' --> <xsd:selector xpath="./subcateg" /> <xsd:field xpath="@id_parinte" /> <xsd:field xpath="@nume" /> </xsd:unique> </xsd:element> Mai mult, un element/atribut poate fi constrâQV V ILH YDOLG GDF üL QXPDL GDF YDORDUHD OXL VH DIO vQ PXOLPHD YDORULORU DOWXL HOHPHQWDWULEXW Acest aspect permite specificarea unei relaLL vQWUH FKHL YLD <xsd:key> üL <xsd:keyRef> (vezi exemplul de mai jos). Alte detalii sunt furnizate în van der Vilst (2002).
  • 364. Modele de date semistructurate. Familia XML 119 Suportul pentru abstractizare Într-un mod similar paradigmei obiectuale, putem impune – prin atributul abstract="true" – FD DQXPLWH HOHPHQWHDWULEXWH V ILH FRQVLGHUDWH DEVWUDFWH DVWIHO vQFkW V QX SRaW IL XWLOL]DWH vQWU-R LQVWDQ GH GRFXPHnt, ci GRDU V SRDW IL UDIiQDWH SULQ GHULYDUH YLD R VFKHP VXSOLPHQWDU SULQ <xsd:include>). Anumite tipuri, simple sau complexe, pot fi redefinite via <xsd:redefine>. De asemenea, specificarea unor elemente/atribute generice (ale altor tipuri de documenWH
  • 365. VH UHDOL]HD] SULQ HOHPHQWHOH <xsd:any> üL <xsd:anyAttribute>. Documentarea schemelor Suportul pentru documentare recurge la elementul <xsd:annotation>, care poate include <xsd:documentation> FRQLQkQG LQIRUPDLL GHVWLQDWH XWLOL]DWRULORU XPDQL üL <xsd:appInfo> SUHFL]kQG GLYHUVH LQIRUPDLL IRORVL- toare instrumentelor de procesare. 2 DGQRWDUH SRDWH DSUHD FD SULP HOHPHQW-copil al unor elemente ca <xsd:schema>, <xsd:element>, <xsd:attribute> sau <xsd:simpleType>. Utilizarea unei scheme ÍQ YHGHUHD YDOLGULL R LQVWDQ GH GRFXPHQW WUHEXLH V GeFODUH XQ VSDLX GH nume cu un URI desemnând schema utili]DW 3UHFL]DUHD IDSWXOXL F HOHPHQWHOH üL DWULEXWHOH GHILQLWH GH VFKHPD QRDVWU DSDULQ XQXL VSDLX GH QXPH VH UHDOL]HD] YLD DWULEXWXO schemaLocation în cadrul elementului <xsd:schema> ÍQ FDGUXO GHILQLLHL VFKHPHL VH SRDWH VSHFLILFD IDSWXO FD HOHPHQWHOHDWULEXWHOH V ILH SUefixate obligatoriu – prin prin elementFormDefault üL attributeFormDefault – GH FWUH VSaLXO GH nume ales. De exemplu, pentru cuprinsXO FULL YRP VFULH <xsd:schema xmlns="urn:infoiasi.ro:xsdCuprins" targetNamespace="urn:infoiasi.ro:xsdCuprins" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">...</xsd:schema> /D QLYHO GH LQVWDQ GH GRFXPHQW YRP IRORVL R FRQVWUXFLH GH JHQXO <s:radacina xmlns:s="uri_schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri_schema doc_schema.xsd">
  • 366. Tehnologii XML120 ... </s:radacina> 'H DVHPHQHD SXWHP DVRFLD XQHL LQVWDQH R VFKHP IU D SUHFL]D XQ VSDLX GH QXPH ;0/ 8Q H[HPSOX HVWH XUPWorul: <cuprins xsi:noNamespaceSchemaLocation="cuprins.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... </cuprins> Folosirea valorilor nule Valorile nule (nil sau null) sunt în principal utilizate în cadrul modelului UHODLRQDO 3HQWUX D SHUPLWH DOLQLHUHD OD DFHVW PoGHO VSHFLILFDLD ;0/ 6FKHPD RIHU SRVLELOLWDWHD GH D SUHFL]D FD YaORDUHD XQXL HOHPHQW V ILH nil (i.e. QXO
  • 367. vQ FDGUXO GHILQLLHL DFHVWXLD YLD DWULEXWXO nillable="true". Acest DWULEXW VH SRDWH XWLOL]D SHQWUX RULFH WLS VLPSOX FX FRQLQXW PL[W VDX WLS comSOH[ DYkQG FRQLQXW VLPSOX $SDULLD OXL nillable="true" are prioritate asupra modelului-FRQLQXW DO HOHmentului în cau] Atributele nu pot fi declarate ca având valori nule. 'H QRWDW IDSWXO F XQ HOHPHQW YLG empty) nu este întotdeauna nul, pe FkQG XQ HOHPHQW QXO WUHEXLH REOLJDWRULX V ILH YLG 8Q H[HPSOX HVWH XUPWRUXO <xsd:element name="project" type="projectType" minOccurs="1" maxOccurs="unbounded" /> <xsd:complexType name="projectType" nillable="true"> <xsd:sequence> <!-- VHFYHQ GH HOHPHQWH --> </xsd:sequence> <xsd:attribute name="class" type="classType" /> </xsd:complexType> /D QLYHO GH LQVWDQ GH GRFXPHQW YRP GHFODUD YDORUL QXOH SULQ <project xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/> $FHVW OXFUX H SRVLELO vQ FLXGD IDSWXOXL F LQLLDO HOHPHQWXO QX DYHD FRQLQXW YLG &LWLWRULL LQWHUHVDL pot parcurge multe alte detalii oferite de van der Vlist 
  • 368. üL GH WXWRULDOHOH GH OD DGUHVHOH www.zvon.org üL www.xfront.com.
  • 369. Modele de date semistructurate. Familia XML 121 Exemple ÍQ FRQWLQXDUH YRP LOXVWUD R SDUWH GLQWUH IDFLOLWLOH GH ED] DOH ;0/ 6FKHPD 3HQWUX vQFHSXW QH SURSXQHP V HODERUP R VFKHP ;0/ IoORVLW SHQWUX YDOLGDUHD GRFXPHQWHORU UHIHULWRDUH OD SURLHFWHOH VWXGHQHüWL SURSXVH OD R GLVFLSOLQ 9RP LPSXQH FD HOHPHQWHOH üL DWULEXWHOH V ILH SUHIL[DWH GH VSDLXO GH QXPH FURUD DSDULQ vQ FD]XO QRVWUX DP DOHV GUHSW DGUHV D VSDLXOXL de nume URN-ul urn:infoiasi.ro:xsdProjects. 'LQ SXQFW GH YHGHUH JUDILF VWUXFWXUD VFKHPHL HVWH LOXVWUDW GH ILJXUD  JHQHUDW GH HGLWRUXO R;JHQ! FDUH SRDWH IL IRORVLW üL FD YDOLGDWRU
  • 370.  )LJXUD  5HSUH]HQWDUHD JUDILF D VFKHPHL SULYLWRDUH OD SURLecte Codul-VXUV DO VFKHPHL HVWH XUPWRUXO <xsd:schema xmlns="urn:infoiasi.ro:xsdProjects" targetNamespace="urn:infoiasi.ro:xsdProjects" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified">
  • 371. Tehnologii XML122 <xsd:annotation> <xsd:documentation xml:lang="ro"> ([HPSOX GH VFKHP XWLOL]DW OD YDOLGDUHD SURLHFWelor </xsd:documentation> </xsd:annotation> <!-- definirea elementului-UGFLQD SURMHFWV --> <xsd:element name="projects" type="projectsType" /> <xsd:complexType name="projectsType"> <xsd:sequence> <!-- PFDU R DSDULLH D HOHPHQWXOXL SURMHFW --> <xsd:element name="project" type="projectType" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="update" type="xsd:string" /> </xsd:complexType> <!-- tipul complex "projectType" --> <xsd:complexType name="projectType"> <!-- VHFYHQ GH HOHPHQWH --> <xsd:sequence> <xsd:element name="title" type="xsd:string" /> <xsd:element name="desc" type="xsd:string" minOccurs="0" maxOccurs="1" /> <xsd:element name="stud" type="studType" /> <xsd:element name="url" type="xsd:anyURI" minOccurs="0" maxOccurs="1" /> </xsd:sequence> <xsd:attribute name="class" type="classType" /> </xsd:complexType> <!-- definirea tipului simplu "studType" folosit pentru specificarea valorilor elementului "stud" --> <xsd:simpleType name="studType"> <!-- QXPUXO GH VWXGHQL YD IL vQ LQWHUYDOXO >
  • 372. --> <xsd:restriction base="xsd:unsignedInt"> <xsd:minInclusive value="1" /> <xsd:maxExclusive value="5" /> </xsd:restriction> </xsd:simpleType> <!-- definirea tipului simplu "classType" folosit pentru a specifica valorile atributului "class" -->
  • 373. Modele de date semistructurate. Familia XML 123 <xsd:simpleType name="classType"> <xsd:restriction base="xsd:string"> <xsd:length value="1" fixed="true" /> <!-- SURLHFWHOH YRU IL GH FODV $ % VDX & --> <xsd:enumeration value="A" /> <xsd:enumeration value="B" /> <xsd:enumeration value="C" /> </xsd:restriction> </xsd:simpleType> </xsd:schema> ,QVWDQD YD WUHEXL V DLE FDOLILFDWH DWkW HOHPHQWHOH FkW üL DWULEXWHOH FX VSDLXO GH QXPH stabilit. Un fragment de document XML valid conform VFKHPHL GH PDL VXV HVWH VH REVHUY F HOHPHQWXO <desc> nu a fost precizat, HO ILLQG RSLRQDO
  • 374.  <p:projects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "urn:infoiasi.ro:xsdProjects projects.xsd" xmlns:p="urn:infoiasi.ro:xsdProjects"> <p:project p:class="A"> <p:title>Super</p:title> <p:stud>1</p:stud> <p:url>http://www.super.ro</p:url> </p:project> </p:projects> $O GRLOHD H[HPSOX VH UHIHU OD YDOLGDUHD FXSULQVXOXL XQHL FUL &RPSR- nentele schemei XML sunt disponibile în figura 23. )LJXUD  (OHPHQWHOH WLSXULOH VLPSOH üL FRPSOH[H VSHFLILFDWH vQ FDGUXO XQHL VFKHPH ;0/
  • 375. Tehnologii XML124 ÍQWUXFkW R SDUWH GLQWUH GHILQLLLOH GH WLSXUL DX IRVW SUHFL]DWH PDL VXV e.g., addrType üL nrcapType), nu le vom mai include în codul furnizat în continuare: <xsd:schema xmlns="urn:infoiasi.ro:xsdCuprins" targetNamespace="urn:infoiasi.ro:xsdCuprins" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <!-- definirea elementului-UGFLQ FXSULQV --> <xsd:element name="cuprins" type="cuprinsType" /> <!-- tipul complex "cuprinsType" --> <xsd:complexType name="cuprinsType"> <xsd:sequence> <!-- include "coordonator" (care poate lipsi) --> <xsd:element name="coordonator" type="xsd:string" minOccurs="0" maxOccurs="1" /> <!-- FRQLQH UHIHULQ OD HOHPHQWXO FXSULQV FDUH WUHEXLH V DSDU FHO SXLQ R GDW --> <xsd:element ref="capitol" minOccurs="1" maxOccurs="unbounded" /> </xsd:sequence> <!-- FRQLQH GLYHUVH DWULEXWH --> <xsd:attribute name="titlu" type="xsd:string" use="required" /> <xsd:attribute name="editura" type="xsd:string" /> <xsd:attribute name="an" type="anType" /> </xsd:complexType> <!-- definirea tipului simplu "anType" folosit pentru specificarea valorilor atributului "an" --> <xsd:simpleType name="anType"> <xsd:restriction base="xsd:integer"> <xsd:enumeration value="2004"/> <xsd:enumeration value="2005"/> </xsd:restriction> </xsd:simpleType> <!-- definirea elementului "capitol" --> <xsd:element name="capitol" type="capitolType" /> <!-- tipul complex "capitolType" --> <xsd:complexType name="capitolType">
  • 376. Modele de date semistructurate. Familia XML 125 <!-- HOHPHQWHOH YRU DSUHD vQ RUGLQHD VSHFLILFDW --> <xsd:sequence> <xsd:element name="nume" type="xsd:string" /> <xsd:element ref="autor" minOccurs="1" maxOccurs="unbounded" /> <xsd:element name="descriere" type="xsd:string" /> </xsd:sequence> <!-- FRQLQH XQ DWULEXW REOLJDWRULX --> <xsd:attribute name="numar" type="nrcapType" use="required" /> </xsd:complexType> <!-- specificarea elementului "autor" --> <xsd:element name="autor"> <xsd:complexType> <!-- GHULYP GLQWU-un tip simplu --> <xsd:simpleContent> <xsd:extension base="xsd:string"> <!-- VSHFLILFP DSDULLD RSLRQDO
  • 377. a atributului "email" --> <xsd:attribute name="email" type="addrType" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:element> </xsd:schema> ,QVWDQD YD DYHD FDOLILFDWH GRDU QXPHOe de elemente. AtribuWHOH SRW V QX ILH SUHIL[DWH GH DGUHVD VSDLXOXL GH QXPH 8Q Sosibil exemplu este: <c:cuprins xmlns:c="urn:infoiasi.ro:xsdCuprins" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infoiasi.ro:xsdCuprins cuprins.xsd" titlu="Situri Web la cheie" editura="Polirom" an="2004"> <c:coordonator>Sabin Buraga</c:coordonator> <c:capitol numar="5"> <c:nume>Noua provocare în grafica 2D - SVG</c:nume> FDXWRU!&WOLQ %XODQFHDFDXWRU! <c:descriere>...</c:descriere> </c:capitol> <!-- úL DOWHOH --> </c:cuprins>
  • 378. Tehnologii XML126 8UPWRDUHD H[HPSOLILFDUH DYkQGX-l ca autor pe absolventul Daniel 2QDF LOXVWUHD] PRGXO GH GHILQLUH D XQHL UHODLL vQWUH R FKHLH SULPDU üL R FKHLH VWUiQ vQWU-un document XML. &RQVLGHUP VLWXDLD vQ FDUH WUHEXLH V PHPRUP GDWH SULYiWRDUH OD R OLVW GH FUL GLQWU-R ELEOLRWHF üL VHSDUDW GHVSUH DXWRULL ORU 9RP LPSXQH DQXPLWH FRQVWUkQJHUL vQ OLVWD GH DXWRUL QXPHOH DFHVWRUD WUHEXLH V DSDU GRDU R VLQJXU GDW DU IL UHGXQGDQW FD DFHODüL DXWRU V ILH VWRFDW GH PDL PXOWH RUL
  • 379. üL vQ SOXV WUHEXLH V DSDU GRDU QXPHOH GH DXWRUL DL XQRU FUL existenWH vQ ELEOLRWHF 6FKHPD ;0/ DUH VWUXFWXUD <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="biblioteca"> <xsd:complexType> <!-- VHFYHQ GH FDUWL! úL DXWRUL)DLPRVL! --> <xsd:sequence> <xsd:element name="carti"> <xsd:complexType> <xsd:sequence> <xsd:element name="carte" type="carteType" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="autoriFaimosi"> <xsd:complexType> <xsd:sequence> <xsd:element name="autor" type="autorType" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> <!-- GHILQLP FKHLD SULPDU FD ILLQG XQ DXWRU DO XQHL FUL GLQ OLVWD GH FUL --> <xsd:key name="cheiePrimara"> <xsd:selector xpath=".//carte/autor" /> <xsd:field xpath="." /> </xsd:key>
  • 380. Modele de date semistructurate. Familia XML 127 <!-- GHILQLP FKHLD VWULQ FD ILLQG XQ autor GLQ OLVWD GH DXWRUL IDLPRúL --> <xsd:keyref name="cheieStraina" refer="cheiePrimara"> <xsd:selector xpath=".//autoriFaimosi/autor" /> <xsd:field xpath="." /> </xsd:keyref> <!-- VWDELOLP úL R FRQVWUkQJHUH GH XQLFLWDWH vQ OLVWD GH DXWRUL IDLPRúL --> <xsd:unique name="unique"> <xsd:selector xpath=".//autoriFaimosi/autor" /> <xsd:field xpath="." /> </xsd:unique> </xsd:element> <xsd:complexType name="carteType"> <xsd:sequence> <xsd:element name="titlu" type="xsd:string" /> <xsd:element name="autor" type="autorType" minOccurs=maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="autorType"> <xsd:sequence> <xsd:element name="nume" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:schema> 2 LQVWDQ GH GRFXPHQW LQYDOLG SRDWH IL XUPWRDUHD <biblioteca xsi:noNamespaceSchemaLocation="biblioteca.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- OLVWD FULORU --> <carti> <carte> <titlu>Proiectarea siturilor Web</titlu> <autor><nume>Sabin Buraga</nume></autor> </carte> <carte> <titlu>Macromedia Flash</titlu> <autor><nume>Cosmin Vârlan</nume></autor>
  • 381. Tehnologii XML128 </carte> <carte> <titlu>Securitatea sistemelor Linux</titlu> <autor><nume>Dragoú $FRVWFKLRDLHQXPH!DXWRU! </carte> </carti> <!-- OLVWD DXWRULORU IDLPRúL --> <autoriFaimosi> <!-- corect --> <autor><nume>Sabin Buraga</nume></autor> <!-- corect --> DXWRU!QXPH!'UDJRV $FRVWFKLRDLHQXPH!DXWRU! <!-- incorect: QX VH UHVSHFW FRQVWUkQJHUHD GH XQLFLWate --> <autor><nume>Sabin Buraga</nume></autor> <!-- incorect: QX VH UHVSHFW FRQWUkQJHUHD GH H[LVWHQ --> <autor><nume>Octavian Dospinescu</nume></autor> </autoriFaimosi> </biblioteca> 8OWLPXO H[HPSOX VH UHIHU OD SRVLELOLWDWHD UHIRORVLULL üL UHGHILQLULL VFKHPHORU ;0/ 0DL VXV DP VSHFLILFDW R VFKHP SULYLWRDUH OD FXSULQVXO XQHL FUL ÍQ FDGUXO ILHFUHL FDSLWRO DP GRUL V LQFOXGHP üL GLYHUVH DGQRWUL (comentarii). Astfel, YRP VFULH R VFKHP VXSOLPHQWDU FDUH YD GHILQL WLSXO UHIHULWRU OD DGQRWUL HD YD SXWHD IL XWLOL]DW üL vQ DOW FRQWH[W
  • 382.  $FHDVW VFKHP – nuPLW adnotari.xsd – QX UHFXUJH OD VSDLL GH QXPH LDU HOHPHQWHOH üL DWULEXWHOH YRU SXWHD IL IRORVLWH IU FDOLILFDUe. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified"> <!-- definim doar tipul complex "adnotType" --> <xsd:simpleType name="adnotType"> <xsd:restriction base="xsd:string"/> </xsd:simpleType> </xsd:schema> 0DL WUHEXLH V PRGLILFP GHILQLLD LQLLDO D WLSXOXL capitolType pentru D SXWHD LQFOXGH üL HOHPHQWH GH WLS adnotType 9RP VFULH R VFKHP cuprins-adnotat.xsd FX XUPWRUXO FRQLQXW
  • 383. Modele de date semistructurate. Familia XML 129 <xsd:schema targetNamespace="urn:infoiasi.ro:xsdCuprins" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified" xmlns:c="urn:infoiasi.ro:xsdCuprins"> <!-- importuri --> <xsd:import schemaLocation="adnotari.xsd" /> <xsd:redefine schemaLocation="cuprins.xsd"> <!-- tipul complex "capitolType" (redefinit) --> <xsd:complexType name="capitolType"> <xsd:complexContent> <!-- tipul trebuie calificat, DúD DP VSHFLILFDW vQ Fuprins.xsd --> <xsd:extension base="c:capitolType"> <xsd:sequence> <!-- folosim tipul de date din adnotari.xsd --> <xsd:element name="adnotare" type="adnotType" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:redefine> </xsd:schema> Schema adnotari.xsd HVWH LPSRUWDW LDU cuprins.xsd HVWH UHGHILQLW ÍQ QRXD VFKHP SUHFL]P DFHODüL VSDLX GH QXPH FX FHO GLQ cuprins.xsd 2 LQVWDQ de document valid conformându-se noii scheme este: <c:cuprins xmlns:c="urn:infoiasi.ro:xsdCuprins" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "urn:infoiasi.ro:xsdCuprins cuprins-adnotat.xsd" titlu="Situri Web la cheie"> <c:capitol numar="8"> <c:nume>Hattrick - simularea meciurilor pe Web</c:nume> <c:autor>Daniel Puiu</c:autor> <c:autor>Marian Bostan</c:autor> <c:descriere>...</c:descriere>
  • 384. Tehnologii XML130 <!-- elementul <adnotare> nu trebuie calificat cu nici un prefix GH VSDLX GH QXPH GHRDUHFH H SUHFL]DW elementFormDefault="unqualified" --> <adnotare>Codul-VXUV H VFULV vQ &DGQRWDUH! </c:capitol> </c:cuprins> RELAX NG 6SUH GHRVHELUH GH SUHFHGHQWD PHWRG 5(/$; 1* Regular Language for XML Next Generation
  • 385. UHSUH]LQW XQ VWDQGDUG 2$6,6 VSHFLILFDW GH &ODUN üL 0XUDWD D
  • 386.  $FWXDOPHQWH 5(/$; 1* HVWH IRORVLW FKLDU üL SHQWUX XQHOH UHFRPDQGUL DOH &RQVRULXOXL :HE GH H[HPSOX ;+70/  üL 5')
  • 387.  GDU üL penWUX VSHFLILFDUHD üL YDOLGDUHD DOWRU FODVH Ge documente, precum DocBook sau TEI (Text Encoding Initiative). 3XQFWXO IRFDO HVWH FHO DO YDOLGULL VWUXFWXULL ;0/ üL PDL SXLQ D FRQLQXWXOXL VWRFDW vQWU-XQ GRFXPHQW ;0/ 'DF vQ FD]XO VFKHPHORU ;0/ exista poVLELOLWDWHD FODVLILFULL HOHPHQWHORU üL DWULEXtelor pe baza unor tipuri GH GDWH üL VHULDOL]ULL RELHFWHORU 5(/$; 1* VH ED]HD] SH SXWHUHD expresiilor reguODWH üL SH FRPSXQHUHD XQRU üDEORDQH VWUXFWXUDOH VLPSOH ÍQ plus, via RELAX NG se pot specifica modele structurale nedeterministe. 8QHOH IDFLOLWL aduse de RELAX NG nu sunt disponibile în Schema XML. ûDEORDQHVWUXFWXUDOH ûDEORDQHOH pattern-XULOH
  • 388. UHSUH]LQW FROHFLL GH QRGXUL DYkQG R VWUXFWXU LQWHUQ VSHFLILF – D VH UHYHGHD FHOH GHVFULVH vQ VHFLXQHD SULYLWRDUH OD ;0/ ,QIRVHW 6H LDX vQ FRQVLGHUDLH üDEORDQHOH GH ED] SULYLWRDUH OD QRGXULOH WH[W FRQLQXW SURSULX-]LV
  • 389.  HOHPHQWH üL DWULEXWH $FHVWH FRQVWUXFLL SH FDUH OH SXWHP YHGHD FD ILLQG DWRPLFH
  • 390. VXQW VSHFLILFDWH GH XUPWRDUele elemente: • <text /> GHVHPQHD] XQ üDEORQ WH[WXDO text pattern); • <element name="nume">úDEORQ*</element> VHPQLILF XQ üDEORQ SULYLWRU OD DSDULLD XQXL HOHPHQW nume care include 0, 1 sau mai PXOWH DSDULLL DOH XQXL üDEORQ; • <attribute name="nume"><text /></attribute> UHSUH]LQW üDEORQXO SULYLWRU OD XQ DWULEXW QXPH DYkQG QDWXral, drept valoare XQ üDEORQ WH[WXDO 6SHFLILFDUHD PRGXOXL GH DSDULLH D HOHPHQWHORU VH UHDOL]HD] YLD elementele <optional> DSDULLH RSLRQDO
  • 391.  <oneOrMore> PFDU R GDW
  • 392. üL <zeroOrMore> GH ]HUR VDX PDL PXOWH RUL
  • 393.  2 DOWHUQDWLY VH SUHFL]HD] SULQ <choice> LDU XQ JUXS GH HOHPHQWH VHFYHQ
  • 394. SULQ LQWHUPHGLXO OXL <group>.
  • 395. Modele de date semistructurate. Familia XML 131 'HVLJXU VH SRW GHILQL üDEORDQH QRL YLD HOHPHQWXO <define> care ulterior pot fi referite prin <ref />. Un exemplu este cel de mai jos, în care VSHFLILFP üDEORQXO elementul-student, care va include elementul <student> FX FRQLQXW WH[W üL RSLRQDO HOHPHQWXO <adresa> DYkQG FRQLQXW WH[W <define name="elementul-student"> <element name="student"> <text /> </element> <optional> <element name="adresa"> <text /> </element> </optional> </define> 5HIHULUHD OD DFHVW üDEORQ VH YD UHDOL]D FX <ref name="elementul- -student"/>. 'HILQLLLOH WXWXURU üDEORDQHORU VXQW LQFOXVH vQWU-R JUDPDWLF YLD elementul <grammar>
  • 396. SHQWUX FDUH WUHEXLH SUHFL]DW üL HOHPHQWXO GH VWDUW FH desemQHD] UGcina documentului XML specificat. $VWIHO VWUXFWXUD JHQHUDO D XQHL VFKHPH 5(/$; 1* HVWH XUPWRDUHD <grammar xmlns="http://relaxng.org/ns/structure/1.0"> <start> <element name="..."> ... </element> </start> <define name="..."> ... </define> </grammar> 'XS FXP VH SRDWH REVHUYD GLQ DFHVW H[HPSOX D IRVW SUHFL]DW üL VSDLXO de nume folosit de RELAX NG. Un exemplu În acest moment, putem oferi un exemplu complet. Vom preciza schema 5(/$; 1* SHQWUX DQWRORJLD GH SRH]LL GHVFULV vQ VXEFDSLWROXO  <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary= "http://www.w3.org/2001/XMLSchema-datatypes"> <!-- elementul-UGFLQ --> <start> <element name="antologie"> <oneOrMore><ref name="poeme" /></oneOrMore> <attribute name="data">
  • 397. Tehnologii XML132 <!-- valoarea atributului e tipul string specificat de XML Schema --> <value type="string"></value> </attribute> </element> </start> <!-- VSHFLILFDUHD FHORUODOWH úDEORDQH --> <define name="poeme"> <oneOrMore><ref name="elem-poem" /></oneOrMore> </define> <define name="elem-poem"> <element name="poem"> <!-- JUXSP R VHULH GH úDEORDQH --> <group> <element name="titlu"><text /></element> <oneOrMore><ref name="elem-vers" /></oneOrMore> </group> </element> </define> <define name="elem-vers"> <element name="vers"><text /></element> </define> </grammar> 9DULDQWD JUDILF D VFKHPHL 5(/$; 1* H LOXVWUDW vQ ILJXUD  FLJXUD  )RUPD JUDILF D VFKHPHL 5(/$; 1* SULYLWRDUH OD DQWRORJLD GH SRezii 6LQWD[DFRPSDFW ([LVW SRVLELOLWDWHD IRORVLULL XQHL VLQWD[H DOWHUQDWLYH FRPSDcWH PDL XüRU GH parcurs de cititorii umani – DPQXQWH vQ &ODUN üL 0XUDWD D
  • 398. üL YDQ GHU Vlist (2003).
  • 399. Modele de date semistructurate. Familia XML 133 Nu vom intra în detalii, ci vom oferi un exemplu din care se poate GHGXFH XüRU VHWXO GH FRQYHQLL GH QRWDLL IRORVLW $VWIHO SHQWUX VFKHPD GH PDL VXV VLQWD[D VLPSOLILFDW FRUHVSXQ]WRare este: start = element antologie { poeme+, attribute data { xsd:string "" } } poeme = elem-poem+ elem-poem = element poem { element titlu { text }, elem-vers+ } elem-vers = element vers { text } $VLJXUDUHDLQWHURSHUDELOLWLL 'HVHRUL vQ FDGUXO XQRU DSOLFDLL GLYHUVHOH PDQLHUH GH VSHFLILFDUH D modelelor de validare trebuie (re)convertite în alte formate (de exemplu, din format DTD în RELAX NG ori XML Schema), pentru a se asigura interoperabilitatea. ([LVW PDL PXOWH LQVWUXPHQWH GH FRQYHUVLH DXWRPDW vQ ILJXUD  ILLQG SUH]HQWDW LQWHUIDD XQXLD GLQWre cele mai populare: Trang. 'UHSW VWXGLX GH FD] YRP FRQVLGHUD XUPWRUXO '7' FDUH VSHFLILF vQ PDQLHU UHFXUVLY FDWHJRULLOH GH SURGXVH LQFOXVH vQ FDWDORJXO XQXL VLW GH FRPHU HOHFWURQLF <!ELEMENT catalog (categ+)> <!ELEMENT categ (categ*)> <!ATTLIST categ id ID #REQUIRED desc CDATA #REQUIRED > 'XS FXP VH SRDWH GHGXFH GLQ '7'-ul prezentat, catalogul este compus din elemente <categ> FDUH SRW FRQLQH DOWH VXE-elemente <categ>.
  • 400. Tehnologii XML134 Figura 25. Conversia cu Trang a unui DTD în formatul precizat de XML Schema ÍQ XUPD FRQYHUVLHL FX 7UDQJ VFKHPD ;0/ UH]XOWDW DUH IRUPD VXILFLHQW GH ÅVWXIRDVµ
  • 401.  <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="catalog"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="categ"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="categ"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="unbounded" ref="categ"/>
  • 402. Modele de date semistructurate. Familia XML 135 </xs:sequence> <xs:attributeGroup ref="attlist.categ"/> </xs:complexType> </xs:element> <xs:attributeGroup name="attlist.categ"> <xs:attribute name="id" use="required" type="xs:ID"/> <xs:attribute name="desc" use="required"/> </xs:attributeGroup> </xs:schema> 'LQ SXQFW GH YHGHUH JUDILF VWUXFWXUD VFKHPHL HVWH LOXVWUDW GH ILJXUD  )LJXUD  )RUPD JUDILF D VFKHPHL ;0/ UH]XOWDWH vQ XUPD FRQYHUVLHL *HQHUkQG R VSHFLILFDLH 5(/$; 1* YRP RELQH UHSUH]HQWDUHD JUDILF HVWH GLVSRQLELO vQ ILJXUD 
  • 403.  <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <define name="catalog"> <element name="catalog"> <ref name="attlist.catalog"/> <oneOrMore> <ref name="categ"/> </oneOrMore> </element> </define> <define name="attlist.catalog" combine="interleave"> <empty/> </define> <define name="categ">
  • 404. Tehnologii XML136 <element name="categ"> <ref name="attlist.categ"/> <zeroOrMore> <ref name="categ"/> </zeroOrMore> </element> </define> <define name="attlist.categ" combine="interleave"> <attribute name="id"> <data type="ID"/> </attribute> <attribute name="desc"/> </define> </grammar> )LJXUD  5HSUH]HQWDUHD JUDILF D VFKHPHL 5(/$; 1* JHQHUDWH )RUPD 5(/$; 1* FRPSDFW HVWH XUPWRDUHD catalog = element catalog { attlist.catalog, categ+ } attlist.catalog &= empty categ = element categ { attlist.categ, categ* } attlist.categ &= attribute id { xsd:ID }, attribute desc { text } /D ILQDOXO DFHVWHL VHFLXQL SUHFL]P F R VHULH GH FRQVLGHUDLL SULYLQG compatibilitatea schemelor RELAX NG cu DTD-urile sunt oferite de Clark üL 0XUata (2001b). Modul de utilizare a tipurilor de date XML Schema în
  • 405. Modele de date semistructurate. Familia XML 137 FDGUXO 5(/$; 1* HVWH GHWDOLDW vQ &ODUN üL .DZDJXFKL 
  • 406.  'H DVHmenea, se pot vizita siturile de la adresele http://relaxng.org/ üL http://dsdl.org/. ([SULPDUHDOHJWXULORUYLD;/LQk Limbajul XLink (XML Linking Language
  • 407. IXUQL]HD] GLYHUVH SoVLELOLWL GH D GHILQL VHPDQWLFD XQHL OHJWXUL KLSHUWH[W QX GRDU VLQWD[D HL LQWURGXFkQG üL QRLXQHD GH OHJWXUL H[WLQVH vQ FDUH VXQW LPSOLFDWH PDL PXOW GH GRX resurse (nu doar o sinJXU VXUV üL R VLQJXU GHVWLQDLH
  • 408.  ;/LQN LQWURGXFH üL SRLQWHUL H[WLQüL – via XPointer – RIHULQG R PHWRG VRILVWLFDW GH D ORFDOL]D resursele. ;/LQN 'H5RVH 0DOHU üL 2UFKDG 
  • 409. VHUYHüWH DüDGDU SHQWUX H[SULPDUHD de structuri hipertext bazate pe XML. Un document ;/LQN DSDULQH VSDLXOXL GH QXPH GDW GH http://www.w3.org/1999/xlink 7RDWH OHJWXULOH VSHFLILFDWH vQ ;/LQN YRU DSDULQH DFHVWXL VSDLX GH QXPH XWLOL]DWRUXO GH IDSW UHDOL]kQG R LQVWDQLHUH D XQRU HOHPHQWH üL DWULEXWH ;/LQN VLPLODU tehnicilor din programDUHD RELHFWXDO &RQFHSWHOH GH ED] VXQW XUPWRDUHOH • traversarea vQVHDPQ XWLOL]DUHD VDX XUPDUHD XQHL OHJWXUL LPSOLFkQG întotdeauna o pereche de resurse sau fragmente de resurse; • arcul GHVHPQHD] LQIRUPDLLOH UHIHULWRDUH OD PRGDOLWDWHD GH WUDYHU- sare a unei perechi de resurse (e.g. GLUHFLD GH WUDYHUVDUH FRPSRUWD- PHQWXO DSOLFDLHL DWXQFL FkQG VH DFWLYHD] R OHJWXU HWF
  • 410.  Caracterizare 6SUH GHRVHELUH GH PHFDQLVPXO GH VSHFLILFDUH D OHJWXULORU DGRptat de HTML, în cazul limbajului XLink se pot specifica: • OHJWXUL H[WLQVH – RIHU vQWUHDJD IXQFLRQDOLWDWH D OLPEDMXOXL i.e., OHJWXUL OD FDUH SDUWLFLS XQ QXPU DUEitrar de resurse locale sau DIODWH OD GLVWDQ
  • 411.  • OHJWXUL VLPSOH – VXQW OHJWXULOH OD FDUH SDUWLFLS QXPDL GRX UHVXUVH ILLQG XQLGLUHFLRQDOH e.g. OHJWXUile din HTML clasic). 2 OHJWXU H[WLQV SRDWH FRQLQH R PL[WXU GH WLSXUL GH HOHPHQWH ;/LQN în orice ordine, dintre cele descrise în continuare: • locator – VSHFLILF UHVXUVHOH DIODWH OD GLVWDQ FDUH SDUWLFLS vQ UHDOL- ]DUHD OHJWXULL • arc – oIHU UHJXOL GH WUDYHUVDUH D UHVXUVHORU SDUWLFipante (modul de acces la resursele hipertext);
  • 412. Tehnologii XML138 • title – VWDELOHüWH R HWLFKHW WH[WXDO SHQWUX R OHJWXU XWLOL]DW FX VFRSXO GH D DVRFLD R GHVFULHUH vQ OLPEDM QDWXUDO D OHJWXULL
  • 413.  • resource – VSHFLILF UHVXUVHOe locale care pot participa la realizarea legturii. ,QWHUGHSHQGHQD GLQWUH WLSXULOH GH HOHPHQWH ;/LQN HVWH LOXVWUDW vQ tabelul de mai jos: Tabelul 5. Tipurile de elemente XLink Tip element-printe Tipuri de elemente-copil care pot fi precizate simple - extended locator | arc | resource | title locator title arc title resource - title - Exemplu 3UHVXSXQHP F SULQWU-R OHJWXU H[WLQV YRP ÅOHJDµ GLIHULWH UHVXUVH FRQLQkQG LQIRUPDLLOH GHVSUH FXUVXULOH XUPDWH GH XQ DQXPLW VWXGHQW profesorii care predau aceste cursuri, despre datele personale ale studentului etc. $VWIHO SXWHP VFULH XUPWRUXO '7' DGDSWDW GXS %XUDJD 
  • 414.  <!-- cursurile urmate de un student --> <!ELEMENT cursuri ((desc | pers | curs | gr | go)*)> <!ATTLIST cursuri -- atributele cursurilor -- xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink" -- obligatoriu -- xlink:type (extended) #FIXED "extended" -- OHJWXU H[WLQV -- xlink:role CDATA #IMPLIED xlink:title CDATA #IMPLIED > <!-- descrierea cursurilor --> <!ELEMENT desc ANY> <!ATTLIST desc xlink:type (title) #FIXED "title" xml:lang CDATA #IMPLIED
  • 415. Modele de date semistructurate. Familia XML 139 > <!-- LQIRUPDLL GHVSUH R SHUVRDQ VWXGHQW SURIesor) --> <!ELEMENT pers EMPTY> <!ATTLIST pers xlink:type (locator) #FIXED" "locator" xlink:href CDATA #REQUIRED -- URI-ul resursei -- xlink:role CDATA #IMPLIED xlink:title CDATA #IMPLIED xlink:label NMTOKEN #IMPLIED -- eticheta -- tip (prof | stud) "prof" -- tipul persoanei -- > <!-- inIRUPDLL GHVSUH XQ FXUV --> <!ELEMENT curs EMPTY> <!ATTLIST curs xlink:type (locator) #FIXED" "locator" xlink:href CDATA #REQUIRED -- URI-ul resursei -- xlink:role CDATA #FIXED "http://cursuri.ro/" xlink:title CDATA #IMPLIED xlink:label NMTOKEN #IMPLIED -- eticheta resursei – > <!-- LQIRUPDLL GHVSUH R JUXS GH VWXGLX --> <!ELEMENT gr EMPTY> <!ATTLIST gr xlink:type (locator) #FIXED" "locator" xlink:href CDATA #REQUIRED -- URI-ul resursei -- xlink:role CDATA #FIXED "http://studii.ro/" xlink:title CDATA #IMPLIED xlink:label NMTOKEN #IMPLIED -- eticheta resursei -- > <!-- HOHPHQW GH WUDYHUVDUH YL]LWDUH
  • 416. D OHJWXULL --> <!ELEMENT vizita EMPTY> <!ATTLIST vizita xlink:type (arc) #FIXED" "arc" xlink:arcrole CDATA #IMPLIED xlink:title CDATA #IMPLIED xlink:show ( new -- PRGXO GH DILúDUH D UHVXrsei -- | replace
  • 417. Tehnologii XML140 | embed | other | none) #IMPLIED xlink:actuate ( onLoad | onRequest | other | none) #IMPLIED -- HYHQLP DFWLYULL OHJ -- xlink:from NMTOKEN #IMPLIED -- sursa -- xlink:to NMTOKEN #IMPLIED -- GHVWLQDLD -- > 8Q GRFXPHQW H[SORDWkQG OHJWXUD H[WLQV SRDWH IL XUPWRUXO D VH YHGHD üL ILJXUD 
  • 418.  <cursuri xlink:title="Cursurile urmate de Sergiu Dumitriu"> <!-- ,QIRUPDLL GHVSUH VWXGHQW --> <pers xlink:href="sergiu.dumitriu.xml" xlink:label="stud33" xlink:role="http://students.infoiasi.ro/~sdumitriu/" xlink:title="Sergiu Dumitriu" tip="stud" /> <!-- ,QIRUPDLL SULYLWRDUH OD XQ FDGUX GLGDFWLF --> <pers xlink:href="busaco.xml" xlink:label="prof03" xlink:role="http://www.infoiasi.ro/~busaco/" xlink:title="Sabin Corneliu Buraga" tip="prof" /> <!-- HYHQWXDO úL DOWH UHVXUVH --> <!-- specificarea unui curs --> <curs xlink:href="courses/web/web.html" xlink:label="SWeb" xlink:title="Semantic Web" /> <!-- Mai multe resurse despre cursuri, seminarii etc. --> <!-- Grupa din care face parte studentul --> <gr xlink:label="grupa">MSD-1</gr> <!-- /HJWXU VWXGHQW-JUXS --> <vizita xlink:from="stud33" xlink:to="grupa" xlink:show="new" xlink:actuate="onRequest" xlink:title="Grupa lui Sergiu Dumitriu" /> <!-- /HJWXU VWXGHQW-curs -->
  • 419. Modele de date semistructurate. Familia XML 141 <vizita xlink:from="SWeb" xlink:arcrole="http://www.infoiasi.ro/membru" xlink:to="stud33" xlink:show="replace" xlink:actuate="onRequest" xlink:title="Sergiu Dumitriu, participant la cursul 'Semantic Web'" /> <!-- /HJWXU VWXGHQW-coordonator --> <vizita xlink:from="stud33" xlink:arcrole="http://www.infoiasi.ro/prof" xlink:to="prof03" xlink:show="replace" xlink:actuate="onRequest" xlink:title="Sabin Corneliu Buraga, coordonator" /> </cursuri> )LJXUD  6SHFLILFDUHD XQHL OHJWXUL H[WLQVH vQWUH PDL PXOWH UHVXUVH
  • 420. Tehnologii XML142 $WULEXWHOH ;/LQN DX XUPWRDUHOH GHVFULHUL 'H5RVH 0DOHU üL 2UFKDG 2001): • type – ideQWLILF WLSXO HOHPHQWHORU ;/LQN üL HVWH REOLJDWRULX YDORULOH permise fiind simple, extended, locator, arc, resource, title sau none. 'H H[HPSOX R OHJWXU VLPSO YD IL GHILQLW vQ PDQLHUD <!ATTLIST xlink:simple xlink:type (simple) #FIXED "simple" > 'DF VH IRORVHüWH none HOHPHQWXO QX SRVHG R VHPDQWLF ;/LQN üL RULFH alte atribute XLink pe care le are nu vor fi luate în consideraLH • href – IXUQL]HD] GDWHOH FDUH SHUPLW XQHL DSOLFDLL DYkQG VXSRUW SHQWUX ;/LQN V JVHDVF R UHVXrV VDX XQ IUDJPHQW GH UHVXUV
  • 421. DIODW OD GLVWDQ 3RDWH IL XWLOL]DW SHQWUX OHJWXUL VLPSOH üL WUHEXLH V DSDU vQ HOHPHQWH GH WLS locator. Valoarea lui href este un URI; • atributele semantice role, arcrole üL title – VSHFLILF VHPDQWLFD resurselor participante la o leJWXU $WULEXWHOH role üL title pot fi utilizate în elemente de tip extended, simple, locator üL resource. Atributele arcrole üL title SRW V DSDU vQ HOemente de tip arc. Valoarea atributelor role üL arcrole WUHEXLH V ILH XQ 85, LDU valoarea lui title va IL XQ üLU GH FDUDFWHUH GHVWLQDW FLWLWRUXOXL XPDQ GH H[HPSOX DSOLFDLD DU SXWHD RIHUL XQ WH[W GH DMXWRU
  • 422.  • atributele comportamentale show üL actuate – SRW DSUHD RSLRQDO vQ HOHPHQWH GH WLS VLPSOH VDX DUF üL SHUPLW FRQWUROXO DVupra comporta- PHQWXOXL OHJturii. Atributul show VSHFLILF GDF GRFXPHQWXO LQGLFDW GH R OHJWXU HVWH LQFOXV vQ GRFXPHQWXO Furent, înlocuindu-l VDX DILükQGX-l într-R DOW IHUHDVWU DWXQFL FkQG OHJWXUD HVWH DFWLYDW Atributul actuate GHWHUPLQ FXP YD IL DFWLYDW R OHJWXU e.g., în mod automat sau doar când este seOHFWDW GH XWLOL]DWRU
  • 423.  • DWULEXWHOH SULYLWRDUH OD WUDYHUVDUHD OHJWXULL label, from üL to – atributul label VH XWLOL]HD] SHQWUX HOHPHQWH GH WLS resource üL locator LQGLFkQG R HWLFKHW $WULEXWHOH from üL to apar în elemente de tip arc üL GHVHPQHD] VXUVD UHVSHFWLY GHVWLQDLD OHJturii. /HJWXULVLPSOH 2 OHJWXU VLPSO SRDWH IL UHSUH]HQWDW SULQ LQWHUPHGLXO XQHL OHJWXUL H[WLQVH FRPELQkQG IXQFLLOH GH ED] DOH HOHPHQWHORU GH WLS extended, locator, arc üL resource.
  • 424. Modele de date semistructurate. Familia XML 143 O exePSOLILFDUH HVWH XUPWRDUHD OHJWXUD YD IL XUPDW OD DFLXQHD H[SOLFLW D XWLOL]DWRUXOXL
  • 425.  <a xlink:type="extended"> <resursa xlink:type="resource" xlink:label="local"> Sergiu Dumitriu </resursa> <localizator xlink:type="locator" xlink:href="http://students.infoiasi.ro/~sdumitriu/" xlink:label="remote" xlink:role="..." [OLQNWLWOH 9L]LWDL VLWXO OXL 6HUJLX ! <vizita xlink:type="arc" xlink:from="local" xlink:to="remote" xlink:arcrole="..." xlink:show="replace" xlink:actuate="onRequest" /> </a> Acest exemplu în (X)HTML putea fi scris: <a href="http://students.infoiasi.ro/~sdumitriu/"> Sergiu Dumitriu</a> 'DF SHQWUX DWULEXWXO show aveam valoarea new, atunci în HTML IRORVHDP FRQLQXWXO UHVXUVHL-GHVWLQDLH VH vQFDUF vQWU-R QRX IHUHDVWU D navigatorului): <a href="http://students.infoiasi.ro/~sdumitriu/" target="_blank">Sergiu Dumitriu</a> )D GH OHJWXULOH H[WLQVH R OHJWXU VLPSO QX SRDWH RIHUL • posibilitatea de a avea resurse multiple (locale VDX OD GLVWDQ
  • 426.  • VSHFLILFDUHD XQXL DUF GH OD R UHVXUV OD GLVWDQ VSUH R UHVXUV ORFDO • asocierea unui titlu sau rol unei resurse locale; • DWDüDUHD XQXL WLWOX VDX URO OHJWXULL OXDWH vQ DQVDmblu. /D ILQDOXO DFHVWHL VHFLXQL WUHEXLH V SUHFL]P F ;/LQN vüL JVHüWH XWLOL]UL vQ SUHFL]DUHD GH OHJWXUL KLSHUWH[W vQ FDGUXO Dltor tipuri de documente XML standardizate, precum SVG sau SMIL. 4. Limbaje bazate pe XML. Exemple În continuare, vom prezenta succint o serie de limbaje bazate pe XML, dezvoltate în vederea îndeplinirii unor diverse scopuri specifice.
  • 427. Tehnologii XML144 ,QWHUDFWLYLWDWHDFXXWLOL]DWRUXO)LOLHUD;+70/üL;)RUPV Viziunea noii versiuni XHTML 2.0 (Axelsson et al., 2005), în curs de VWDQGDUGL]DUH OD &RQVRULXO :HE HVWH FHD GH D VH RIHUL XQ FDGUX JHQHUal SHQWUX LQFOXGHUHD GH FRQLQXW VHUYLQG XQXL DQXPLW VFRS YLD XQ GRFXPHQW (e.g., o foaie de calFXO XQ FDSLWRO GH FDUWH R SLHV PX]LFDO XQ IUDJPHQW dintr-un blog R LPDJLQH YHFWRULDO XQ PHVDM GH SRüW HOHFWURQLF HWF
  • 428.  Acest document poate fi creat, SURFHVDW üL UHGDW GH R DSOLFDLH ,QWHUQHW 6SUH GHRVHELUH GH FODVLFXO +70/ DWHQLD VH FRQFHQWUHD] DVXSUD VWUXF- WXULL üL QX D SUH]HQWULL FDUH SRDWH IL UHDOL]DW JUDLH IRLORU GH VWLOXUL
  • 429.  D FUHüWHULL XWLOL]DELOLWLL üL RIHULULL XQXL VXSRUW DGHFYDW vQ FHHD FH SULYHüWH accesibilitatea. De asemeQHD VH XUPUHVF vPEXQWLUHD LQGHSHQGHQHL GH GLVSR]LWLY R PDQLHU PDL EXQ GH LQWHUDFLXQH FX XWLOL]DWRUXO UHGXFHUHD QHFHVLWLL GH D DWDüD VFULSWXUL üL LQWHJUDUHD FX DOWH WHKQRORJLL ;0/ 8UPULQG OLQLLOH GH SURLHFWDUH DOH ;+70/  FRQVWUXFLLOH VLQWDFWLFH VXQW grupaWH SH PRGXOH ILHFDUH RIHULQG R DQXPLW IXQFLRQDOLWDWH VSHFLILF GH exemplu, modulul Structural SULYHüWH PDQLHUD GH VWUXFWXUDUH D LQIRUPDLLORU iar Tables SXQH OD GLVSR]LLH VXSRUWXO SHQWUX VSHFLILFDUHD FRQLQXWXOXL tabelar). 8Q H[HPSOX GH GRFXPHQW ;+70/  HVWH XUPWRUXO <html xmlns="http://www.w3.org/2002/06/xhtml2/" xml:lang="ro"> <head> <title>Fotografii personale</title> <meta property="dc:creator">Sabin Buraga</meta> </head> <body> <section> <h>Fotografii personale</h> <separator /> <p src="foto" type="image/png, image/*"> Fotografia mea</p> <meta about="#csb" property="title"> Situl personal</meta> Alte fotografii <p id="csb" href="http://www.infoiasi.ro/~busaco/">aici.</p> </section> </body> </html>
  • 430. Modele de date semistructurate. Familia XML 145 2 PDL EXQ VWUXFWXUDUH D LQIRUPDLLORU VH SRDWH UHDOL]D YLD XQRU FRQVWUXFLL QRL <section> GHILQHüWH R VHFLXQH GH FRQLQXW LDU <h> VSHFLILF XQ WLWOX heading
  • 431.  6XQW SVWUDWH üL HOHPHQWHOH <h1>, …, <h6>, pentru compatibilitatea cu versiunile anterioare. Elementul <separator> VHUYHüWH SHQWUX D VHSDUD ORJLF VHFLXQL ILLQG FRQVLGHUDW FD VXEVWLWXHQW DO YHFKLXOXL <hr>. Un paragraf, specificat via <p> SRDWH LQFOXGH üL DOWH FRQVWUXFLL – de exemplu, liste – FDUH SkQ DFXP QX HUDX SHUPLVH (OHPHQWXO <l> desemQHD] R OLQLH üL SRDWH IL DGUHVDW YLD &66 SH FkQG YHFKLXO <br />, nu. Imaginile nu sunt incluse cu <img />, ci pot fi specificate prin intermediul atributului src vQ RULFH DOWH FRQVWUXFLL GH WLS FRQWDLQHU GH FRQLQXW VH SRDWH SUHFL]D vQ SOXV üL WLSXO MIME al imaginii). Mai mult, atributul href SRDWH DSUHD vQ FDGUXO PDL PXOWRU HOHPHQWH QX QHDSUDW <a> 'H DVHPHQHD VH RIHU <nl> FDUH SUHFL]HD] R OLVW GH OHJWXUL QDYLJDLRQDOH FROHFLH GH LQIRUPDLL VHOHFWDELOH GHVWLQDWH UHDOL]ULL XQXL meniu de navigare). 3HQWUX D VH SHUPLWH SUHFL]DUHD GH FRQVWUXFLL VHPDQWLFH – D VH YHGHD üL capitolul 5 –, elementul <meta> SRDWH DYHD DWDüDW DWULEXWXO property, iar rel SRDWH VSHFLILFD UHODLD GRFXPHQWXOXL FX DOWH UHVXUVH e.g., glosar, index, FDSLWRO VHFLXQH DQH[ SURILO FLWDW FXSULQV
  • 432.  $FHVWH DWULEXWH VXQW SHUPLVH üL vQ FDGUXO DOWRU FRQVWUXFLL üL VXSOLPHQWDU HOHPHQWXO <meta> SRDWH DSUHD üL vQ FRUSXO GRFXPHQWXOXL ÍQ FHHD FH SULYHüWH DFFHVLELOLWDWHD SRDWH IL IRORVLW DWULEXWXO role, care SUHFL]HD] UROXO unui anumit element (de exemplu, rol de navigare printr-o VWUXFWXU KLSHUWH[W VDX GH QRW GH VXEVRO
  • 433.  $FHVW DWULEXW SRDWH IL IRORVLW üL SHQWUX D DWDüD VHPDQWLFL GiYHUVHORU FRQLQXWXUL 8Q DOW H[HPSOX HVWH XUPWRUXO vQ FDUH VH REVHUY F GRFXPHQWXO desemneD] XQ PHVDM GH e-mail: <html xmlns="http://www.w3.org/2002/06/xhtml2/" xmlns:email="http://www.faqs.org/rfcs/rfc2822.html#"> <head> <meta property="email:From">Sabin Buraga &lt;busaco@infoiasi.ro>&gt;</meta> <meta property="email:To">Viorel Bunduc &lt;vbunduc@polirom.ro&gt;</meta> <meta property="email:Subject">Cartea</meta> <meta property="email:Date"> Fri, 24 Feb 2006 09:55:06-0200</meta> <meta property="email:Message-ID"> &lt;id@mail.infoiasi.ro&gt;</meta> <title>Un e-mail privitor la carte</title>
  • 434. Tehnologii XML146 </head> <body xml:lang="ro">Salut, cum decurge editarea?<body> </html> ,QWHUDFLXQHD FX XWLOL]DWRUXO UPkQH vQ UHVSRQVDELOLWDWHD VSHFLILFDLHL XForms (Boyer et al. 
  • 435.  3RVLELOLWLOH IRUPXODUHORU :HE FODVLFH VXQW limitate, neputându-se specifica tipuri de date, cauzând probleme de DFFHVLELOLWDWH üL ED]kQGX-se pe scripting. De asemenea, formularele sunt RULHQWDWH VSUH SUH]HQWDUH QX VSUH VWUXFWXUDUHD ORJLF D FkPSXULORU GH LQWUDUH üL QX H[LVW VXSRUW QDWLY SHQWUX UHDOL]DUHD GH LQWHUDFLXQL vQ PDL PXOL SDüL Un document XForms va fi compus din trei componente importante: • modelul UHIHU RULFH DVSHFWH QHSUH]HQWDLRQDOH DOH LQWHUDFLXQLL FX utilizatorul (datele preluate de la utilizator, constrângerile SULYLWRDUH OD YDOLGDUHD LQWUULL PHWD-date privitoare la comunicarea FX VHUYHUXO
  • 436.  $VWIHO PRGHOXO VSHFLILF YDORULOH GDWHORr ce vor fi FROHFWDWH Y]XWH FD LQVWDQH; • LQWHUIDD FX XWLOL]DWRUXO VH SUHFL]HD] YLD FRQVWUXFLL Dbstracte, posibil DJUHJDWH DFFHQWXO HVWH SXV SH PDQLHUD GH LQWHUDFLXQH üL PDL SXLQ SH PRGXO GH SUH]HQWDUH D LQWHUIHHL &RQWURDOHOH GH LQWHUID VXQW ataüDWH YDORULORU GLQ FDGUXO LQVWDQHORU GHILQLWH vQ PRGHO • modul de transmitere (submit
  • 437. GHVHPQHD] LQIRUPDLLOH UHIHUitoare la WUDQVIHUXO GDWHORU FWUH VHUYHUXO :HE FH YD HIHFWXD SUelucrarea HIHFWLY D DFHVWRUD VH SRW VSHFLILFD GH DVHPHQHD FH DFLXQL YRU SXWHD IL H[HFXWDWH OD DSDULLD XQXL UVSXQV GLQ SDUWHD VHUYHUXOXL
  • 438.  Modelul apare în antetul unui document XHTML via <model>. &RPSRQHQWHOH GH LQWHUID SRW DSUHD RULXQGH vQ FRUSXO GRFXPHntului (nu doar în <form> FXP VH vQWkPSO OD +70/
  • 439.  LDU PDQLHUD GH Wransmitere a dateORU H GHILQLW SULQ HOHPHQWXO <submission> (pot fi efectuate mai multe RSHUDLL GH WLS submit). Se permite specificarea câmpurilor ce trebuie completaWH REOLJDWRULX üL GHSHQGHQD GH DOWHOH VFHQDULXO GH LQWHUDFLXQH FX formularul). Accesul üL FDOFXODUHD YDORULORU VH UHDOL]HD] YLD ;3DWK LDU WLSXULOH GH GDWH VH VSHFLILF SULQ ;0/ 6FKHPD 'H DVHPHQHD GDWHOH LQLLDOH SRW IL SUHvQFUFDWH GLQ VXUVH Hxterne. 6 FRQVLGHUP IRUPXODUXO :HE GH FXWDUH D XQXL SURGXV GHFODUDW vQ XHTML 1.0 astfel: <html> KHDG!WLWOH!&XWDUHWLWOH!KHDG! <body> <form action="http://www.sit.org/cautare" method="get">
  • 440. Modele de date semistructurate. Familia XML 147 &DXW LQSXW WSH WH[W QDPH SURGXV ! <input type="hidden" name="linii" value="10" /> <input type="submit" value="!" /> </form> </body> </html> 9DULDQWD ;)RUPV LQWHJUDW vQWU-un document XHTML 2.0, poate fi: <html xmlns=<http://www.w3.org/2002/06/xhtml2/" xml:lang="ro"> <head> WLWOH!&XWDUHWLWOH! <!-- PRGHOXO GH LQWHUDFLXQH --> <model> <!-- spre server va fi trimis GRDU QXPHOH SURGXVXOXL FXWDW --> <instance> <data xmlns="http://www.sit.org/produse"> <produs /> <!-- un câmp ascuns --> <linii>10</linii> </data> </instance> <submission action="http://www.sit.org/cautare" method="get" id="s" /> </model> </head> <body> <p> <!-- LQWHUIDD FX XWLOL]DWRUXO SHQWUX UHGDUH se va recurge la stiluri) --> <input ref="produV!ODEHO!&DXWODEHO!LQSXW! <submit submission="s"><label>!</label></submit> </p> </body> </html> 'DWHOH LQLDOH SRW IL SUHOXDWH GLQWU-XQ ILüLHU ;0/ H[WHUQ <instance src="http://www.sit.org/date/cautari.xml" /> Via atributul ref pot fi preluate date din documente XML cu structuri GLYHUVH JUDLH H[SUHVLLORU ;3DWK 'H H[HPSOX SXWHP DYHD DFFHV OD WLWOXO unei pagini Web printr-R FRQVWUXFLH GH IRUPD
  • 441. Tehnologii XML148 <input ref="h:html/h:head/h:title">...</input> &RQWURDOHOH ;)RUPV RIHU WRDWH SRVLELOLWLOH de introducere a datelor din +70/ vQV QX DX DWDüDWH LQIRUPDLL SULYLWRDUH OD PRGXO GH UHGDUH vQ cadrul browser-ului. Astfel, un control XForms de selectare a unei valori dintr-R OLVW GH LQIRUPDLL SRDWH IL UHSUH]HQWDW SH HFUDQ vQ PDL PXOWH maniere (e.g., folosind butoane radio, printr-R OLVW GH VHOHFLH JUDLH XQXL PHQLX VDX SULQ LQWHUPHGLXO XQRU LPDJLQL
  • 442.  vQ IXQFLH GH GLVSR]LWLY üLVDX de proSULHWLOH GH VWLO DVRFLDWH 6XSOLPHQWDU VH RIHU XQ FRQWURO GH WLS slider: <range ref="volum" start="1" end="20" step="0.5"> üL XQ control pentru includerea în document a datelor introduse <output>. 3HQWUX D SXWHD FUHD DVLVWHQL wizards
  • 443. GH LQWHUID VH LQWURGXF elementele <switch> üL <toggle>, iar repetarea unor date se poate realiza via <repeat>. Gruparea unor controale se face prin elementul <group>. 8Q DOW DVSHFW LPSRUWDQW vO UHSUH]LQW PRGXO GH FRQWURO DO FRPSRUWDPHQ- WXOXL IRUPXODUXOXL 2 DQXPLW YDORDUH LQWURGXV GH XWLOL]DWRU SRDWH IL UHOHYDQW QXPDL vQWU-XQ FRQWH[W GDW SRDWH IL GRDU FRQVXOWDW SRDWH Ii REOLJDWRULX VSHFLILFDW VDX WUHEXLH V VH FRQIRUPH]H XQXL WLS GH GDWH i.e., FDQWLWDWHD WUHEXLH V ILH XQ QXPU SR]LWLY
  • 444.  'H DVHPHQHD YDORDUHD SRDWH IL FDOFXODW GLQ DOWH YDORUL e.g. WRWDOXO GH SODW DO SURGXVHORU FRPDQGDWH
  • 445. VDX poate avea asociate diYHUVH FRQVWUkQJHUL GH SLOG GDWD GH QDüWHUH WUHEXLH V QX ILH XOWHULRDU GDWHL FXUHQWH
  • 446.  $FHVW FRQWURO DUH ORF SULQ LQWHUPHGLXO XQRU SURSULHWL FH YRU IL DWaüDWH YLD <bind> LQVWDQHORU ÍQ H[HPSOXO GH PDL MRV VH VSHFLILF IDSWXO F QXPUXO FULL GH FUedit va IL VROLFLWDW GRDU GDF XWLOL]DWRUXO SOWHüWH XQ FUHGLW ÍQ SOXV VH LPSXQH FD YDORDUHD VXPHL V ILH PDL PDUH GHFkW  üL V ILH REOLJDWRULX LQWURGXV <model> <instance> <data xmlns=""> <suma /><plata /> <card> <numar /><data_expirare /> </card> </data> </instance> <bind nodeset="card" relevant="../plata='credit'" /> <bind nodeset="suma" constraint=". &gt; 100" required="true()" type="xs:unsignedInt" /> </model>
  • 447. Modele de date semistructurate. Familia XML 149 5VSXQVXO OD HYHQLPHQWH VH UHDOL]HD] SULQ LQWHUPHGLXO PHFDQLVPXOXL XML Events 0F&DUURQ 3HPEHUWRQ üL 5DPDQ 
  • 448.  SXWkQGX-se realiza un comportament dinamic al formuODUXOXL ÍQ H[HPSOXO GH PDL MRV VH YRU DILüD alternativ „AscunGHµ üL Å$ILüHD]µ OD DFLRQDUHD XQXL FRQWURO GH LQWHUID <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events"> ... <xforms:group ref="contractat"> <xforms:trigger> [IRUPVODEHO!$ILúHD][IRUPVODbel> <xforms:action ev:event="DOMActivate"> <!-- VWDELOLP FD HOHPHQWXO DILVDUH! V DiE valoarea 'expandat' --> <xforms:setvalue ref="afisare">expandat</xforms:setvalue> </xforms:action> </xforms:trigger> </xforms:group> <xforms:group ref="expandat"> <xforms:trigger> <xforms:label>Ascunde</xforms:label> <xforms:action ev:event="DOMActivate"> <xforms:setvalue ref="afisare">contractat</xforms:setvalue> </xforms:action> </xforms:trigger> </xforms:group> ... </html> Alte detalii privitoare la XForms SRW IL UHJVLWH vQ %RHU et al. 
  • 449. üL Raman (2003). ÍQ FHHD FH SULYHüWH LPSOHPHQWULOH DFWXDOPHQWH H[LVW FOLHQL ;)RUPV precum FormsPlayer üL XSmiles FDUH SURFHVHD] IRUPXODUHOH OD QLYHO GH FOLHQW /D QLYHO GH VHUYHU VXQW GLVSRQLELOH DSOLFDLL SUHFXm Chiba, FormFaces üL OXF.
  • 450. Tehnologii XML150 4.2. Specificarea structurii hipertext a unui sit Web 0DQLHUD FODVLF GH D FRQWUROD PRGXO GH DFFHV DO XQXL URERW :HE OD FRQLQXWXO XQXL VLW :HE HVWH YLD ILüLHUXO robots.txt, specificat de standardul de excludere D URERLORU GHWDlii în Buraga, 2005). Unul dintre serviciile Google recente este Google Sitemaps SHUPLkQG XQXL GH]YROWDWRU GH VLW :HE V H[SHGLH]H XQ GRFument XML privitor la VWUXFWXUD KLSHUWH[W D VLWXOXL vQ YHGHUHD XQHL LQGH[UL PDL FXSULQ]WRDUH D FRQLQXWXOXL DFHVWXLa. SoluLD *RRJOH HVWH FRPSOHPHQWDU VWDQGDUGXOXL GH excludere a roERLORU SULQ LQWHUPHGLXO ;0/ SXWkQGX-se specifica modul de YL]LWDUH D VLWXOXL GH FWUH URERLL GH FXWDUH 8Q H[HPSOX GH DVWIHO GH GRFXPHQW ;0/ HVWH XUPWRUXO <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"> <url> <!-- ORFDLD UHVXUVHL --> <loc>http://www.infoiasi.ro/~busaco/</loc> <!-- ultima modificare --> <lastmod>2006-02-19T12:33:03+02:00</lastmod> <!-- SULRULWDWHD ID GH vQWUHJ FRQLQXWXO sitului: YDORUL vQWUH  úL  --> <priority>1.0</priority> </url> <url> <!-- ORFDLD DOWHL UHVXUVH --> <loc>http://www.infoiasi.ro/~busaco/paint/</loc> <!-- IUHFYHQD DFWXDOL]ULORU --> <changefreq>weekly</changefreq> </url> </urlset> Serviciul Google Sitemaps DFFHSW FD DFHVWH LQIRUPDLL V ILH GDWH üL vQ Dlte IRUPDWH WH[W RELüQXLW 566 $WRP HWF $OWH GHWDOLL VXQW RIHULWH GH 2JEXML (2005). 3URWRFROXOGHFRPXQLFDLHIRORVLWGH-DEEHU Jabber reprH]LQW XQ VLVWHP open source GH IDFLOLWDUH D FRQYHUVDLLORU instantanee, pe baza tehnologiilor Internet actuale. 3URWRFROXO GH FRPXQLFDLH UHFXUJH OD ;0/ &RQIRUP VSHFLIiFDLLORU -DEEHU RULFH UHVXUV FH SRDWH IL DGUHVDW vQ FDGUXO VLVWHPXOXL VH QXPHüWH
  • 451. Modele de date semistructurate. Familia XML 151 entitate XQ VHUYHU R FRPSRQHQW VRIWZDUH XQ XWLOL]DWRU HWF
  • 452.  )LHFDUH HQWLWDWH DUH DWDüDW XQ LGHQWLILFDWRU XQLF -,' – Jabber ID), de forma XWLOL]DWRU#JD]GUHVXUVD (de exemplu, busaco@jabber.org/Laptop). 2 UHVXUV VSHFLILF SRDWH DYHD vQ FRPSRQHQ DQXmite date, specificate tot prin intermediul JID-ului. De exemplu, yak/announce/online desemQHD] IDSWXO F UHVXUVD announce/online HVWH GLVSRQLELO SH VHUYHUXO yak üL VHPQLILF WUDQVPLWHUHD XQXL DQXQ PHVDM
  • 453. FWUH WRL XWLOL]DWRULL GLVSRQLELOL DIODL online) pe serverul indicat. În exemplul 959967024@update.jabber.org/ 1.6.0.3 este specificat un JID pe care-l trimite clientul indicat de 959967024 FWUH VHUYHUXO GH DFWXDOL]DUH D VRIWZDUH-XOXL DQXQkQG F YHUVLXQHD OXL FXUHQW HVWH 1.6.0.3. $FHüWL LGHQWLILFDWRUL VXQW YHKLFXODL SULQ LQWHUPHGLXO XQRU IOX[XUL (streams) XML între punctele finale ale conexiunii, pe baza stivei de SURWRFRDOH 7&3,3 6XQW IRORVLWH DQXPLWH VSDLL GH QXPH GHVHPQkQG clientul (jabber:client), serverul (jabber:server
  • 454. VDX R FRPSRQHQW (jabber:component:accept üL jabber:component:exec). De exemplu, pentru o cerere de conectare din partea unui client la un server Jabber, se va trimite un document de forma: <stream:stream to="jabber.org" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams"> ... </stream:stream> 8Q UVSXQV WUDQVPLV GH VHUYHU DU SXWHD IL DWULEXWXO id VHUYHüWH SHQWUX autorizarea accesului): <stream:stream from="jabber.org" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" id="3AFD5712"> ... </stream:stream> Atributele from üL to GHVHPQHD] ORJLF QXPHOH FHORU GRX SXQFWH ILQDOH DOH FRQYHUVDLHL SXWkQGX-se recurge la alias-uri via <alias>. &RQLQXWXO PHVDMHORU YHKLFXODWH HVWH vQFDSVXODW GH HOHPHQWXO <message>, tipul unui mesaj putând fi un fragment de dialog (chat
  • 455.  R WHOHFRQIHULQ (groupchat
  • 456.  XQ DQXQ headline) sau o eroare (error). În cazul în care nu e VSHFLILFDW WLSXO VH FRQVLGHU F PHVDMXO HVWH QRUPDO QX QHFHVLW XQ UVSXQV
  • 457.  8Q H[HPSOX HVWH XUPWRUXO vQ FDUH VH UHPDUF üL DSDULLD XQXL element opLRQDO
  • 458. Tehnologii XML152 <message to="busaco@yak" from="dragos@yak" type="chat"> <body>Ce faci?</body> </message> 8Q PHVDM SRDWH LQFOXGH üL PDUFDMH ;+70/ FDUH WUHEXLH V DSDULQ VSDLXOXL GH QXPH VSHFLILFDW GH &RQVRULXO :HE De asemenea, se pot grupa prin <thread> fragmente dintr-R FRQYHUVDLH (set de replici), iar elementul <x> permite specificarea unor extinderi Jabber VDX RIHULWH GH WHUH RUJDQL]aLL ,QIRUPDLLOH SULYLWRDUH OD GLVSRQLELOLWDWHD XQHL HQWLWL SUH]HQ prioritate etc.) sunt stocate de <presence>. De exemplu, pentru ca un XWLOL]DWRU V FXQRDVF GDF XQ DOWXO V-D FRQHFWDW OD VLVWHP WUHEXLH V DLE acces la inIRUPDLLOH GHVSUH SUH]HQD DFHVWXLD <presence type="subscribe" to="dragos@jabber.org" /> 0HVDMXO GH UVSXQV DU SXWea fi: <presence type="subscribed" to="busaco@yak/Laptop" from="dragos@jabber.org/firma" /> 'DWHOH SULYLWRDUH OD LQIRUPDLL üL LQWHURJUL VXQW PHPRUDWH vQ FDGUXO XQXL element <iq> (info/query
  • 459.  SHUPLkQG UHDOL]DUHD GH FRQYHUVDLL VWUXFWXUDWH întUH GRX HQWLWL -DEEHU $WULEXWXO type DVRFLDW DFHVWXL HOHPHQW VSHFLILF GDF H YRUED GH R FHUHUH get
  • 460. VDX GH R SODVDUH D XQHL LQIRUPDLL set). În caz GH VXFFHV VH RIHU XQ UH]XOWDW result), altfel – o eroare (error). Pentru a solicita accesul la cameUD GH FRQIHULQ blabla VH JHQHUHD] <iq type="get" id="conf" to="blabla@conference.yak"> <query xmlns="jabber:iq:conference" /> </iq> 8Q UVSXQV DU SXWHD IL XUPWRUXO vQ FDUH VH VSHFLILF IDSWXO F SHQWUX D se permite accesul trebuie furnizate date privitoare la un pseudonim (<nick />
  • 461. üL R SDURO <secret />): <iq type="result" id="conf" to="busaco@yak/Laptop" from="blabla@conference.yak"> <query xmlns="jabber:iq:conference"> <name>Cafeneaua Blabla</name> <nick /> <secret /> </query> </iq> 1XPHURDVH DOH GHWDOLL üL H[HPSOH VXQW GLVSRQLELOH OD www.jabber.org.
  • 462. Modele de date semistructurate. Familia XML 153 ,QWHURJUL;0/ 5.1. Preliminarii ÍQ VHQV UHVWUkQV XQ GRFXPHQW ;0/ SRDWH IL SULYLW FD ILLQG R ED] FROHFLH
  • 463. de date, adoptându-VH R YL]LXQH FHQWUDW SH Gocumente (document centric). Pentru managementul eficient al datelor XML, trebuie – minimal – V H[LVWH suport pentru: • stocare – documente/arbori XML; • scheme – VSHFLILFDLL '7' ;0/ 6FKHPD 5(/$; 1* HWF • limbaje de interogare – ;3DWK ;4/ ;4XHU üL Dltele; • interfHH GH SURJUDPDUH $3,-uri) – DOM, SAX etc. $FHVWH DVSHFWH VH UHJVHVF GLQ SXQFW GH YHGHUH FRQFHSWXDO üL SUDFWLF üL în cadrul bazelor de date comune. Suplimentar, mai trebuie asigurate (Daum & Merten, 2003): • PRGDOLWL GH VWRFDUH HILFLHQW • mecanisme de indexare; • VXSRUW SHQWUX DVLJXUDUHD VHFXULWLL GDWHORU • UHDOL]DUHD GH WUDQ]DFLL • integritatea datelor; • accesul multi-user; • suportul pentru trigger-e; • HIHFWXDUHD GH LQWHURJUL vQ GRFXPHQWH PXOWLSOH 5.2. Baze de date native XML Premise Conform Bourret (200D
  • 464.  H[LVW GRX SXQFWH GH YHGHUH SULYLWRDUH OD VWRFDUHD LQIRUPDLLORU ;0/ 3ULPXO VH UHIHU OD GRFXPHQWHOH FHQWUDWH SH GDWH data-centric document) în care XML este folosit pentru transportul datelor. Documentele sunt proiec- tate spre a fi eficient proceVDWH GH FWUH PDüLQ ILLQG FDUDFWHUL]DWH GH R VWUXFWXU UHJXODW VWRFkQG UHSUH]HQWUL ILQH DOH GDWHORU XQLWDWHD DWRPLF LQGHSHQGHQW GH LQIRUPDLH VH VLWXHD] OD QLYHOXO YDORULL XQXL DWULEXW VDX DO FRQLQXWXOXL VLPSOX DO XQXL HOHPHQW ;0/
  • 465.  $VWIHO GH GRFumente se pre- WHD] SHQWUX PHPRUDUHD RUDUHORU FXUVHORU DHULHQH D GDWHORU üWLLQLILFH D ordiQHORU GH SODW HWF &DUDFWHUXO VWUXFWXUDW DO GDWHORU FRQGXFH OD SRVLEL- OLWDWHD VWRFULL vQWU-R ED] GH GDW UHODLRQDO VDX D LQWHUVFKLPEXOXL GH
  • 466. Tehnologii XML154 LQIRUPDLL GLQWUH XQ VLVWHP GH ED]H GH GDWH UHODLRQDOH FRQYHQLRQDO üL R DSOLFDLH RUiHQWDW VSUH ;0/ $O GRLOHD SXQFW GH YHGHUH VH UHIHU OD DüD-numitele document-centric docu- ments, adoptându-VH R YL]LXQH FHQWUDW SH GRFXPHQW $FHVWH GRFXmente sunt destinate consumului XPDQ SXWkQG FRQVWD vQ FUL HOHFWURQLFH Pesaje GH SRüW HOHFWURQLF GRFXPHQWH ;+70/ ELQH IRUPDWDWH VFULVH PDQXDO Structura inWHUQ QX PDL HVWH DWkW GH UHJXODW PRGHODUHD ILLQG XQD VHPLVWUXFWXUDW &HD PDL PLF XQLWDWH GH GDW LQGHSHQGHQW SRDWH IL VLWXDW OD QLYHOXO XQXL HOHPHQW DYkQG XQ FRQLQXW PL[W FRmpus din sub-elemente üL WH[W
  • 467. VDX FKLDU OD QLYHOXO GRFXPHQWXOXL vQ DQVDPEOX 2UGLQHD vQ FDUH DSDU HOHPHQWHOH VLWXDWH SH DFHODüL QLYHO siblings) este, de cele mai multe ori, LPSRUWDQW $FHVWH GRFXPHQWH VXQW FRQFHSXWH GH PkQ VDX FRQYHUWLWH GLQ DOWH IRUPDWH 3') RUL 57)
  • 468.  IU D SURYHQL GLQWU-R ED] GH GDWH FOaVLF ÍQ SUDFWLF GLVWLQFLD GLQWUH FHOH GRX FDWHJRULL DPLQWLWH QX HVWH vQWRW- GHDXQ FODU GDU HOH FRQWULEXLH OD GHFL]LD FH WUHEXLH OXDW vQ SULYLQD manierei de stocare a datelor. În general, datele sunt stocate în baze de date UHODLRQDOH RULHQWDWH SH RELHFW VDX LHUDUKLFH 3H ED]D XQRU IDFLOLWL LQWHUQH sau a unor programe middleware, aceste date pot fi accesate în format XML. Astfel de siVWHPH VH FRQVLGHU D IL XML-enabled. Strategiile de stocare se bazea] SH DVRFLHUHD VFKHPHL GH YDOLGDUH ;0/ '7' ;0/ 6FKHPD 5(/$; 1*
  • 469. XQHL VFKHPH GH ED] GH GDWH üL YLFH-YHUVD $FHDVW DFLXQH SRDWH IL UHDOL]DW vQ PRG DXWRPDW FKLDU IRORVLQG R WUDQVIRUPare XSLT. Schema documentului se asocia] VFKHPHL ED]HL GH GDWH ILH OD QLYHO GH tabel (table-based mapping), fie conform unui model obiect-UHODLRQDO (object-relational mapping
  • 470.  ÍQ DFHVW XOWLP FD] GRFXPHQWHOH ;0/ VXQW DWDüDWH unor obiecte – via unor tehnici XML data binding –, care la rândul lor vor SRSXOD XOWHULRU ED]D GH GDWH 2 GLVFXLH SULYLQG VWRFDUHD GRFXPHQWHORU XML în cadrul bazelor de date reODLRQDOH HVWH GLVSRQLELO vQ %RXUUHW (2005a). De asemenea, alte detalii de interes sunt prezentate în Katz (2003). 7DEHOXO  2 FRPSDUDLH VXFFLQW vQWUH ED]HOH GH GDWH UHODLRQDOH üL FHOH QDWLYH ;0/ (conform Harold, 2005) %D]H GH GDWH UHODLRQDOH Baze de date native XML 2 ED] GH GDWH UHODLRQDO FRQLQH tabele 2 ED] GH GDWH ;0/ FRQLQH FROHFLL 2 ED] GH GDWH UHODLRQDO H FRP- SXV GLQ vQUHJLVWUUL DYkQG DFHHDüL VFKHP 2 FROHFLH FRQLQH GRFXPHQWH ;0/ având scheme identice ori diferite
  • 471. Modele de date semistructurate. Familia XML 155 2 vQUHJLVWUDUH UHSUH]LQW R OLVW QHRUGRQDW GH YDORUL LGHQWLILFDWH SULQ QXPH üL DYkQG WLSXUL a priori stabilite Un doFXPHQW ;0/ UHSUH]LQW XQ arbore de noduri, putând include date semistructurate O interogare întoarce un set neordonat GH vQUHJLVWUUL O interogare întoarce o VHFYHQ RUGRQDW de noduri 3ULQ FRQWUDVW GRFXPHQWHOH üL QX GDWHOH
  • 472. VXQW VWRFDWH ILH vQ baze de date native XML (native XML database
  • 473.  DGLF ED]H GH GDWH FRQFHSXWH VSHFLDO SHQWUX VWRFDUHD LQIRUPDLLORU ;0/ ILH vQ sisteme de management al FRQLQXWXOXL DSOLFDLL SURLHFWDWH V JHVWLRQH]H GRFXPHQWH HWHURJHQH üL FDUH VH ED]HD] SH R ED] GH GDWH QDWLY ;0/ Încercare de definire 2 SRVLELO GHILQLLH D FRQFHSWXOXL GH ED] GH GDW QDWLY ;0/ HVWH DFHHD F VSHFLILF XQ PRGHO ORJLF
  • 474. SHQWUX XQ GRFXPHQW ;0/ VXSOLPHQWDU IDFLOLWkQG VWRFDUHD üL DFFHVDUHD GRFXPHQWelor conform acestui model. Drept exemplu de moGHO VH SRDWH GD ;0/ ,QIRVHW 8QLWDWHD IXQGDPHQWDO GH VWRFDUH ORJLF
  • 475. HVWH GRFXPHQWXO ;0/ – SULQ FRQWUDVW FX VLVWHPXO UHODLRQDO foFDOL]DW DVXSUD vQUHJLVWUULL record, row
  • 476. XQHL WDEHOH 2 ED] GH GDWH QDWLY ;0/ QX QHFHVLW vQ PRG SDUWLFXODU IRORVLUHD XQXL VLVWHP GH VWRFDUH IL]LF GHRDUHFH GRFXPHQWHOH ;0/ SRW SURYHQL SULQ VHULDOL]DUH VDX DOWH PRGDOLWL din alte surse de date, inclusiv tabele comune). $UKLWHFWXUD LQWHUQ D XQXL VLVWHP GH ED]H GH GDWH QDWLYH ;0/ SRDWH IL ED]DW SH • text – LQIRUPDLLOH ;0/ sunt stocate ca text – e.g. ILüLHU GLQ FDGUXO XQXL VLVWHP GH ILüLHUH ORFDO XQ FkPS GH WLS %/2% Binary Large Object) ori CLOB (Character Large Object) sau un format text proprietar); • model – LQIRUPDLLOH ;0/ QX VXQW PHPRUDWH FD Gocumente text, ci conform unui model obiectual intern (de exemplu, un arbore DOM). &HULQH 6LVWHPHOH GH ED]H GH GDWH QDWLYH ;0/ WUHEXLH V DVLJXUH FHULnHOH HQXQDWH vQ VHFLXQHD DQWHULRU üL FX SUHFGHUH DX GUHSW VFRS VWRFDUHD LQIRUPaLLORU FHQWUDWH SH GRFXPHQWH üL IDFLOLWDUHD managementului datelor semistruc- turate.
  • 477. Tehnologii XML156 3ULQWUH DVSHFWHOH LPSRUWDQWH DYXWH vQ YHGHUH HQXPHUP • normalizarea FD üL vQ FD]XO PRGHOXOXL UHODLRQDO VH VWXGLD] GHSHQGHQHOH IXQFLRQDOH üL SUREOHPHOH SUiYLQG UHGXQGDQD üL anomaliile cauzate de actualizrile concurente ale datelor); • LQWHJULWDWHD UHIHUHQLDO DLFL UHIHULQHOH SRW IL H[SULPDWH YLD DWULEXWH GH WLS ,' üL ,'5() SULQ FKHL vQ FDGUXO VFKHPHORU ;0/ Iolosind XLink etc.); • scalabilitatea RSHUDLLOH WUHEXLH V DLE ORF – în timp rezonabil – üL pentru documente XML de mari dimensiuni). )DFLOLWLüLEHQHILFLL 6LVWHPHOH GH ED]H GH GDWH QDWLYH ;0/ RIHU VDX WUHEXLH V SXQ OD GLVSR]LLH IDFLOLWL SUHFXP %RXUUHW D
  • 478.  • XWLOL]DUHD FROHFLLORU GH GRFXPHQWH – R FROHFLH MRDF XQ URO VLPLODU celui de taEHO vQ FDGUXO PRGHOXOXL UeODLRQDO VDX GH GLUHFWRU vQ FHHD FH SULYHüWH VLVWHPXO GH ILüLHUH DFHVW DVSHFW SRDWH IDFLOLWD RUJDQL]DUHD documentelor conform unor criterii (unele sisteme ofeU SRVLEL- OLWDWHD LPEULFULL FROHFLLORU FUHkQGX-se astfel ierarhii – taxonomii); • recurgerea la limbaje de interogare – a se vedea secLXQHD  • RIHULUHD GH VXSRUW SHQWUX WUDQ]DFLL ODFWH locking
  • 479. üL FRQFXUHQ – DFHVWH DVSHFWH SUH]LQW QXPHURDVH SUREOHPH GH LQWHUHV SHQWUX FHUFHWWRULL vQ GRPHQLX • SXQHUHD OD GLVSR]LLH GH LQWHUIHH GH SURJUDPDUH • optimizarea accesului (round-tripping); • DFFHVXO OD GDWH DIODWH OD GLVWDQ UHPRWH GDWD
  • 480. – via servicii Web sau alte tehnici, pot fi incluse/interogate documente provenind din exterior; • suportul pentru indexare – sunt disponibile trei tipuri de indexuri: indexuri pentru valori (value indexes
  • 481.  SULYLQG YDORULOH DWULEXWHORU üL FRQLQXWXO WH[W DO HOHPHQWHORU SRW IL DFFHUDWH LQWHURJUL SUHFXP ÅJVHüWH WRDWH HOHPHQWHOH VDX DWULEXWHOH D FURU YDORDUH HVWH ©,DüLªµ
  • 482.  indexuri structurale (structural indexes), referitoare la localizarea elementelor/atributelor în cadrul documentului (se pot folosi în FDGUXO XQHL LQWHURJUL GH JeQXO ÅJVHüWH WRDWH HOHPHQWHOH <adresa>”), üL LQGH[XUL WH[W full-text indexes
  • 483.  FDUH YL]HD] WRDWH XQLWLOH WH[tuale (pot avea rol în inteURJUL FD ÅIXUQL]HD] WRDWH GRFXPHQWHOH FH includ cuvintele «Tehnologii Web»”).
  • 484. Modele de date semistructurate. Familia XML 157 Printre principalele beneficii aduse de un sistem de baze de date native ;0/ ID GH R DSOLFDLH FDUH PDQLSXOHD] XQ QuPU GH ILüLHUH ;0/ VH HQXPHU XUPWRDUHOH • PDQLHUD IDFLO GH VWRFDUH D GDWHORU – FHOH PDL PXOWH VHUYHUH RIHU R PDQLHU XüRU GH DGPLQLVWUDW D ED]HORU GH GDWH X]XDO VLPSOH GRFXPHQWH ;0/
  • 485.  FKLDU üL SULQ LQWHUPHGLXO XQHL LQWHUIHH :HE • oferirea unor vederi (views
  • 486. PXOWLSOH DOH DFHORUDüL date – folosind ;6/7 üL ;6/-)2 UH]XOWDWHOH LQWHURJUilor pot fi redate în moduri GLIHULWH vQ IXQFLH GH QHFHVLWL DVWIHO UH]XOWDWXO XQHL LQWHURJUL SRDWH IL IRORVLW SHQWUX DOWH LQWHURJUL ;0/ • SHUIRUPDQD – vQ FLXGD VFHSWLFLVPXOXL LQWHURJULOH RSWLPizate DVXSUD XQRU ED]H GH GDWH QDWLYH ;0/ MXGLFLRV SURLHFWDWH üL implementate pot fi realizate mai rapid decât asupra unor GRFXPHQWH HWHURJHQH VWRFDWH vQ FDGUXO XQXL VLVWHP GH ILüLHUH DFHVW aspect e deosebit de important pentru integrarea de resurse multiple în cadrul unui document); de asemenea, se poate recurge la caching, refolosirea/rescrierea „inteOLJHQWµ D XQRU IUDJPHQWH GH
  • 487. LQWH- URJUL HWF • utilizarea unor date de largi dimensiuni – tehnicile de procesare LQFUHPHQWDO SUHFXP 6$; RUL ;0/ 5HDGHU pot fi folosite la SUHOXFUDUHD XQXL YROXP IRDUWH PDUH GH LQIRUPDLL VXSOLPHQWDU SXWkQG IL RSHUDWH WUDQVIRUPUL VDX LQWHURJUL VRILVWLFDWH • DVLJXUDUHD LQWHURSHUDELOLWLL FX VHUYHUHOH WUDGLLRQDOH GH ED]H GH GDWH üL VXSOLPHQWDU RIHULUHD VXSRUWXOXL SHQWUu implementarea de VHUYLFLL :HE SHQWUX GHWDOLL YH]L 2QRVH üL 6imeon, 2004). 0RGDOLWLGHUHDOL]DUHDLQWHURJULORU 3ULPXO VFRS vQ GHPDUDUHD LPSOHPHQWULL XQXL VLVWHP GH PDQDJHPHQW DO GDWHORU ;0/ HVWH FUHDUHD XQRU OLPEDMH GH LQWHURJDUH D FRQLQXWXOXi XML. &DUDFWHULVWLFLOH GH]LUDELOH VH UHIHU OD • RELQHUHD UH]XOWDWHORU LQWHURJULORU vQ IRUPDW ;0/ • oferirea de suport pentru procesarea pe partea de server; • UHDOL]DUHD GH RSHUDLL FRPSOH[H VHOHFLL H[WUDFLL UHGXFLL UHVWUXFWXUUL üL DOWHOH
  • 488.  • alinieUHD OD üL LQWHJUDUHD GH VWDQGDUGH ;0/ DGLLRQDOH ;3DWK VSDLL de nume, XML Schema etc.); • suportul pentru noi tipuri de date.
  • 489. Tehnologii XML158 Limbajul XQuery Precursori &RQVRULXO :HE D SURLHFWDW üL SURLHFWHD] GLYHUVH VWDQGDUGH SULYLWRDUH OD PRGDOLWLOH GH LQWHURJDUH D datelor XML. Ideea de a realiza un limbaj VSHFLDOL]DW GH LQWHURJDUH D FRQGXV OD DSDULLD XQRU SURSXQHUL SUHFXUVRDUH vQ XUPD GLUHFLLORU VHPLQDOH Uezultate în cadrul workshop-ului Query Language (QL ’98). Astfel, pe parcursul anilor au fost sugerate limbaje precum WebSQL, XML-QL, XML-GL, XQL, UnQL sau XMAS. $IODWH vQ FXUV GH VWDQGDUGL]DUH SRW IL DPLQWLWH XUPWRDUHOH VSeFLILFDLL • XPath 2.0 (Berlung et al., 2005): www.w3.org/TR/xpath-datamodel/ • XSLT 2.0 (Kay, 2005): www.w3.org/TR/xslt20/ • XQuery 1.0 (Boag et al., 2005): www.w3.org/TR/xquery • ;4XHU;  0HOWRQ üL 0XUDOLGKDU 
  • 490.  www.w3.org/TR/xqueryx O privire de ansamblu asupra tehnologiei XQuery este disSRQLELO vQ (LVHQEHUJ üL 0HOWRQ 
  • 491.  &DUDFWHULVWLFLGHED]DOHOLPEDMXOXL;4XHU În cele ce urmeD] QH YRP FRQFHQWUD DWHQLD DVXSUD GHVFULHULL SULQFLSalelor caracteristici ale limbajului XQuery. 0RGHOXO GH GDWH FRPXQ FHOXL IRORVLW üL GH ;3DWK  üL ;6/7  FRQVLGHU GRFXPHQWXO ;0/ FD ILLQG XQ DUERUH FRPSXV GLQ QRGXUL GHWDOLL în Fernández et al., 2005). O valoare (value
  • 492. UHSUH]LQW R OLVW GH QRGXUL VDX YDORUL DWRPLFH 2 VHFYHQ GH QRGXUL HVWH RUGRQDW GH RELFHL vQ RUGLQHD DSDULLHL DFHVWRUD vQ FDGUXO GRFXPHQWXOXL FRQIRUP DOJRULWPXOXL SUHFL]DW GH VSHFLILFDLD ;0/ ,QIRVHW
  • 493.  9DORULOH DWRPLFH DSDULQ WLSXULORU GH GDWH LQWURGXVH GH VSHFLILFDLD ;0/ 6FKHPD 'H DVHPHQHD GRFXPHQWXO LQWHURJDW SRDWH DYHD DVRFLDW R VFKHP GH YDOLGDUH RpLRQDO 6SDLLOH GH QXPH FH SRW IL IRORVLWH vQ FRQWH[WXO ;4XHU VXQW GHVFULVH vQ tabelul 7. 7DEHOXO  6SDLLOH GH nume utilizate în cadrul XQuery Prefix Descriere URI xs VFKHP ;0/ http://www.w3.org/2001/XMLSchema xsi LQVWDQ GH VFKHP ;0/ http://www.w3.org/2001/XMLSchema-instance
  • 494. Modele de date semistructurate. Familia XML 159 xdt tipuri de date XPath 2.0 http://www.w3.org/2003/xpath-datatypes local IXQFLL ;Query locale http://www.w3.org/2003/11/xquery-local-functions xml XML http://www.w3.org/XML/1998/namespace 3URJUDPHüLH[SUHVLL;4XHU 0RGHOXO UHDOL]ULL LQWHURJULORU HVWH XUPWRUXO SHQWUX VHOHFWarea nodurilor, se recurge la XPath, orice expresie XPath reprezentând un program XQuery, iar rezultatul acestui program fiind o SGXUH VHFYHQ GH DUERUL ;0/
  • 495.  &D üL la XSLT, interoJULOH SRW IL LQFOXVH vQ üDEORDQH menite a genera rezultatul dorit. Astfel, în cele de mai jos, avem un program XQuery care include o expresie XPath: <proiecte> { /projects/project/* } </proiecte> O expresie de forma $nume HVWH R UHIHULQ OD YDULDELOD nume. Variabilele SRW IL IRORVLWH üL vQ FDGUXO H[SUHVLLORU ;3DWK 'H DVHPHQHD YDULDELOHOH SRW FRQLQH YDORUL VDX UH]XOWDWH DOH H[SUesiilor FLOWR. La rândul lor, expresiile FLOWR pot fi imbricate. 'HVFULHP vQ FHOH FH XUPHD] H[SUHVLLOH )/2:5 DOH FURU GHQXPLUH provine de la For, Let, Order-By, Where, Result: • for VHUYHüWH OD DWDüDUHD GH YDORUL XQRU YDULDELOH vQ PDQLHU LQWHUDWLY VH SHUPLW üL RSHUDLL GH WLS join); • let DVLJQHD] XQHL YDULDELOH YDORDUHD XQHL H[SUHVLL • where SHUPLWH IRUPXODUHD GH FRQGLLL ILOWUUL GH GDWH
  • 496. DVRFLDWH XQHL FRQVWUXFLL for; • order by VSHFLILF RUGLQHD GH VHOHFWDUH D YDORUilor/nodurilor; • return întoarce rezultatul unei expresii XQuery, putând include üDEORDQH H[SUHVLL ;3DWK VXE-expresii FLOWR imbricate. 'UHSW H[HPSOLILFDUH V FRQVLGHUP IUD]D select stud.name from students stud where stud.year = 4, exSULPDW vQWU-un dialect SQL. În termenii XQuery, interogarea se transcrie prin: for $stud in doc("students.xml")//student where $stud/year = 4 return $stud/name
  • 497. Tehnologii XML160 6H SRDWH GHGXFH XüRU F IXQFLD doc() IXUQL]HD] DUERUHOH FRUHVSXQ]WRU ILüLHUXOXL students.xml, realizându-se evaluarea expresiei XPath //student VH FRQVLGHU WRDWH HOHPHQWHOH <student>, parcurgându-se recursiv DUERUHOH
  • 498.  UH]XOWXO ILLQG R VHFYHQ GH QRGXUL-HOHPHQW $FHDVW VHFYHQ H LWHUDW SULQ for, variabila stud OXkQG SH UkQG ILHFDUH YDORDUH D VHFYHQHL 6H veriILF SULQWU-R DOW H[SUHVLH ;3DWK GDF YDORDUHD VXE-elementului year este 4. La final, se întoarce valoarea sub-HOHPHQWXOXL QDPH FRUHVSXQ]WRU elementelor <student> SHQWUX FDUH FRQGLLD VSHFLIiFDW GH where este DGHYUDW $üDGDU YRP RELQH R SGXUH GH QRGXUL FRQinând numele VWXGHQLORU GLQ DQXO ,9 DOH FURU LQIRUPDLL VXQW VWRFDWH GH GRFXPHntul students.xml. 'H DVHPHQHD SRW IL XWLOL]DL FXDntificatorii all üL some, se pot exprima FRQVWUXFLL FRQGLLRQDOH if...then...else
  • 499. üL VH SRDWH UHFXUJH OD RSHUDWRULL ;3DWK  SOXV DOLL VXSOimentari. În plus, se permite folosirea de IXQFLL SUHGHILQLWH VDX VSecificate de utilizator). În cadrul unei expresii XQuery, pot fi declarate tipuri de date pentru a VSHFLILFD H[SOLFLW FH YDORUL YRU IL vQWRDUVH üLVDX SHnWUX D vPEXQWL JUDGXO de lizibLOLWDWH DO FRGXOXL ÍQ XUPWRUXO H[HPSOX VH YD JHQHUD R OLVW GH numere calculate prin program: for $i as xs:integer in 1 to 5 return $i * 3 Desigur, înlocuind xs:integer cu tip XML Schema incompatibil cu RSHUDWRUXO GH vQPXOLUH GH H[HPSOX xs:string sau xs:dateTime), vom RELQH XQ PHVDM GH HURDUH 2 SDUWH GLQWUH IXQFLLOH ;4XHU VXQW VLPLODUH FHORU SXVH OD GLVSR]LLH GH PRGXOHOH (;6/7 GHVFULVH vQ VHFLXQHD  D FDSLWoOXOXL GH ID $VWIHO VXQW GLVSRQLELOH IXQFLL SUHGHILQLWH SHQWUX • tratarea erorilor üL GHSDQDUHD SURJUDPHORU error() üL trace(); • accesarea unor date: node-name(), string(), data(); • manipularea valorilor numerice: abs(), ceiling(), round(), count(), avg(), max(), min(), sum() etc.; • UHDOL]DUHD GH RSHUDLL DVXSUD üLUXULORU GH FDUDFWHUH compare(), concat(), string-join(), substring(), string-length(), upper- -case(), translate(), escape-uri(), contains(), starts-with(), ends-with(), substring-before(), substring-after() üL DOWHOH • lucrul cu expresii regulate: matches(), replace(), tokenize(); • PDQLSXODUHD GDWHL üL WLPSXOXL – e.g., get-year-from-date(); • accesarea nodurilor: name(), local-name(), namespace-uri(), root();
  • 500. Modele de date semistructurate. Familia XML 161 • OXFUXO FX VHFYHQH zero-or-one(), one-or-more(), exactly-one(), index-of(), empty(), exists(), distinct-values(), remove(), insert-before(), reverse(), unordered(), deep-equal() etc.; • precizarea contextului: position(), last(), current-dateTime() üL Dltele; • JHQHUDUHD GH VHFYHQH doc(), collection(). 3HQWUX GHWDOLL D VH FRQVXOWD 0DOKRWUD 0HOWRQ üL :DOVK 
  • 501.  De asemenea, SRW IL IRORVLWH üL IXQFLL H[WHUQH VSHFLILFDWH GH XWLOL]DWRU VDX SXVH OD GLVSR]LLH GH VLVWHPXO GH SURFesare XML. 0RGXODUL]DUHDLQWHURJULORU 9DULDQWHOH PDL QRL DOH VSHFLILFDLHL ;4XHU DX LQWURGXV IDFLOLWDWHD GHILQLULL GH PRGXOH GH IXQFLL SHUPLkQGX-se astfel reutilizarea codului-VXUV 6SHFLILFP vQWU-un modul utils.xqm R IXQFLH GH FRQYHUVLH D GDWHL calendaristice: module namespace utils="urn:infoiasi.ro:xdb-utils";  'HFODU R VHFYHQ GH QXPH GH OXQL 
  • 502. declare variable $utils:months { ("Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Nov", "Dec") };  7UDQVIRUP GDWD vQ IRUPD GG 0PP 
  • 503. declare function utils:format-date-RO ($date as xs:dateTime) as xs:string { string-join (( day-from-date ($date), item-at ($utils:months, month-from-date ($date)), year-from-date ($date)), " ") }; 6H REVHUY GHFODUDUHD XQXL VSDLX GH QXPH SHQWUX D UHIHUL YDULDELOHOH üL IXQFLLOH XWLOL]DWRUXOXL )XQFLD DUH OD LQWUDUH R YDORDUH FDOHQGDULVWLF DSDULQkQG WLSXOXL dateTime GHILQLW GH ;0/ 6FKHPD
  • 504. üL vQWRDUFH XQ üLU GH caracWHUH ÍQ FRUSXO IXQFLHL VH UHDOL]HD] FRQFDWHQDUHD XQRU üLUXUL GH caractere rezultate în urPD DSOLFULL XQRU IXQFLL ;4XHU SUHGHILQLWH ,QYRFDUHD IXQFLHL VH SRDWH IDFH FRQIRUP PRGHOXOXL XUPWRU
  • 505. Tehnologii XML162 import module namespace utils="urn:infoiasi.ro:xdb-utils"; declare variable $data external; <data> { utils:format-date-RO ($data) } </data> Variabila data HVWH GHFODUDW FD ILLQG H[WHUQ SXWkQG IL SUeOXDW GH OD utilizator sau din sistem. 8UPWRUXO H[HPSOX LOXVWUHD] PDQLHUD GH UHDOL]DUH D DXWHnWLILFULL XQXL XWLOL]DWRU SH ED]D XQRU IXQFLL SURSULL DOH VHUYHUului eXist: (: Autentificare prin nume de cont & parola preluate din seVLXQHD +773 FXUHQW vQWRDUFH R SHUHFKH (user, password) sau o secvHQ YLG vQ FD] GH HúHF 
  • 506. declare function main:checkUser() as xs:string* { let $user := request:get-session-attribute ("user"), $pass := request:get-session-attribute ("password"), $login := xdb:authenticate ("xmldb:exist:///db", $user, $pass) return if ($login) then ($user, $pass) else () }; )XQFLD get-session-attribute() GLQ VSDLXO GH QXPH request RIHU DFFHVXO OD YDULDELOH GH WLS VHVLXQH LDU IXQFLD authenticate() DSDULQkQG VSDLXOXL GH QXPH xdb, vHULILF H[LVWHQ XQXL XWLOL]DWRU vQ ED]D GH GDWH VLVWHP GHVHPQDW GH 85,-ul special xmldb:exist:///db
  • 507.  )XQFLD UHWXUQHD] XQ QXPU YDULDELO SRVLELO QXO
  • 508. GH üLUXUL GH Faractere. Alte limbaje /LPEDMXO ;4XHU D IRVW SURLHFWDW SHQWUX UHDOL]DUHD GH LQWHURJri, fiind similar comenzii select SXVH OD GLVSR]LLH GH 64/ ([LJHQHOH SUH]HQWXOXL LPSXQ RIHULUHD GH VXSRUW SHQWUX DFWXDOL]DUHD GDWHORU ;0/ LQVHUUL DFWXDOL]UL üWHUJHUL HWF
  • 509.  VLPLODU VXSRUWXOXL SHQWUX RSHUDLLOH &58' (Create-Read-Update-Delete) în contextul sistemelor de baze de date WUDGLLRQale. 2 VHULH GH DSOLFDLL GHMD DFRUG VXSRUW SHQWUX OLPEDMXO ;8SGDWH vQ FXUV GH VWDQGDUGL]DUH OD &RQVRULXO :HE IDFLOLWkQG DFWXDOL]DUHD GDWHORU ;0/ Viitoarele versiuni ale limbajului XQuery vor include, se parH üL SRVLELOLWL GH DFWXDOL]DUH YH]L üL &KDPEHUOLQ )ORUHVFX üL 5RELH 
  • 510. 
  • 511. Modele de date semistructurate. Familia XML 163 Pentru tipuri particulare de documente pot fi folosite limbaje de interogare specializate. Un exemplu notabil în acest sens este SPARQL, un limbaj pentru realizarea de interogUL DVXSUD Gocumentelor RDF. ,PSOHPHQWULüLDSOLFDLL ([HPSOHGHLPSOHPHQWUL )XUQL]P vQ FRQWLQXDUH R VHULH GH H[HPSOH GH LQVWUXPHQWH DSOLFDLL üL LPSOHPHQWUL SULYLWRDUH OD ;4XHU ÍQ SULPXO UkQG QH UHIHULP OD R VXLW GH VHUYHUH GH ED]H GH GDWH native XML, precum eXist, Mark Logic’s CIS sau X-+LYH'% RIHULQG üL GLYHUVH LQWHUIHH GH SURJUDPDUH vQ OLPEDMH SUHFXP & -DYD VDX 3+3 'H DVHPHQHD LQWHURJULOH ;4XHU VXQW VXSRUWDWH üL GH R VHULH GH VLVWHPH UHODLRQDOH (XML-enabled
  • 512. FD 2UDFOH üL 0LFURVRIW 64/ 6HUYHU ÍQ FHHD FH SULYHüWH serverul Oracle, o serie de exemple sunt oferite de Gennick (2005). (GLWDUHD üL GHSDQDUHD LQWHURJULORU ;4XHU FRPSOH[H VH SRW UHDOL]D FX <oXygen/> XML Editor sau Stylus Studio. De asemenea, experimentarea XQRU LQWHURJUL OD QLYHO GH OLQLH GH FRPDQG VDX YLD R LQWHUID GH SURJUDPDUH -DYD VH SRDWH IDFH IRORVLQG 6D[RQ YDULDQWD FRPHUFLDO RIHU üL SRVLELOLWDWHD YDOLGULL Gocumentelor XML transformate ori interogate). Sisteme XML $O GRLOHD VFRS XUPULW vQ FHHD FH SULYHüWH VROXLLOH GH PRGHODUH VWRFDUH üL JHVWLRQDUH D FRQLQXWXOXL ;0/ HVWH LPSOHPHQWDUHD XQRU FDWHJRULL GH VLVWHPH ED]DWH SH WHKQRORJLLOH ;0/ SUH]HQWH üL YLLWRDUH $VWIHO FRQIRUP %RXUUHW D
  • 513.  H[LVW R VXLW GH DSOLFDLL DOH FURU „specii” principale sunt enumerate în continuare: • DSOLFDLL OD QLYHO middleware: DB2XML, DBIx::XML, XDBC (XML Database Connectivity); • sisteme de baze de date native XML: Berkeley DB XML, DBDOM, dbXML, eXist, ozone, Tamino, XDB, Xindice etc.; • servere (cu suport pentru) XML: AxKit, Enhydra, WebObjects; • servere XML-enabled QXPLWH üL DSOLFDLL GH WLS wrapper): DB2 ,QIRUPDWLRQ ,QWHJUDWRU 0LFURVRIW 64/ 6HUYHU 2UDFOH üL DOWHOH DLFL VH FXYLQH PHQLRQDW LQLLDWLYD 64/;0/ SULYLWRDUH OD LQFOXGHUHD în standardul SQL a suportului pentru XML (o serie de detalii în Gennick, 2003); • motoare de interogare XML; • conectoare (XML data binding);
  • 514. Tehnologii XML164 • VLVWHPH GH PDQDJHPHQW DO FRQLQXWXOXL &06 'RFDWR 'QDEDVH Frontier, iENGINE, Mark Logic’s CIS (Content Information Server), Prowler, Syncato, UltraXML etc.; • LQWHUIHH GH SURJUDPDUH 3HUVLVWHQW '20 3'20
  • 515.  ;0/'% XQuery API for Java (XQJ), XML Database API (XAPI). 8WLOL]UL Unul dintre cele mai importante domenii în care se poate recurge la bazele de date native XML este cel privind integrarea datelor semistructurate. 'RFXPHQWHOH FX VWUXFWXUL HWHURJHQH üL SURYHQLQG GLQ VXUVH PXOWLSOH SRW FRQLQH GDWH SULYLWRDUH OD DIDFHUL OD DQDOL]D FHUeULORU GH SODW OD SURGXFLD GH üWLUL FRQYHQLRQDOH VDX PXOWLPedia), la aspecte din sectorul financiar (e.g. FRWDLL OD EXUV
  • 516. VDX FHO GH WUDQVSRUWXUL FXUVH FDOHQGDUH HWF
  • 517.  OD GLYHUVH LQGXVWULL PHGLFDO GH GLYHUWLVPHQW üL DOWHOH
  • 518.  OD VXSRUWXO DFRUGDW FOLHQLORU PDL DOHV vQ FRQWH[WXO &50 – Client Relationship Management), la DQXPLWH GHWDOLL GLQ GRPHQLXO OHJDO üL PXOte altele. 7RDWH DFHVWHD FRQGXF OD HIHFWXDUHD GH WUDQ]DFLL LPSOLFkQG PRGDOLWL GH VWRFDUH PDQDJHPHQWXO FR]LORU GH PHVDMH DUKLYDUHD GDWHORU DWDüDUHD üL folosirea de meta-date, depozitarea pe termen lung a documentelor (eventual, în cadrul depozitelor de date XML). 0DL PXOW GHFkW DWkW PXOWH VLVWHPH GH ED]H GH GDWH QDWLYH ;0/ vüL RIHU IXQFLRQDOLWLOH vQWU-R PDQLHU VLPLODU VHUYHUHORU :HE VLWXULOH SXWkQG IL integral dezvoltate folosind o asemenea abordare. 'HWDOLL SULYLQG H[SORDWUL HIHFWLYH vQ SUDFWLF VXQW IXUQL]DWH GH %RXUUHW (2005b). 5.5. Studii de caz 5HDOL]DUHDGHLQWHURJULSULQ0DUN/RJLF·V&,6 3HQWUX vQFHSXW QH SURSXQHP V UHDOL]P R ED] GH GDWH QDWLY ;0/ FXSULQ]kQG GRX GRFXPHQWH ;0/ VWRFkQG LQIRUPDLL SULYLWRDUH OD proiectele propuse OD R GLVFLSOLQ üL UHVSHFWLY VWXGHQLL FDUH üL-au ales un anumit proiect disponibil. 9RP IRORVL VHUYHUXO GH PDQDJHPHQW DO FRQLQXWXOXL 0DUN /RJLF·V &,6 UXOkQG VXE :LQGRZV üL LQFOX]kQG üL XQ VHUYHU :HE DVWIHO vQFkW LQWHURJULOH pot fi realizate direct via un formular HTML, iar rezultatele pot fi redate ca pagini Web. 6HUYHUXO VH DGPLQLVWUHD] ORFDO SULQ http://127.0.0.1:8001/, iar accesul propriu-]LV VH UHDOL]HD] YLD DGUHVD http://127.0.0.1:8000/. Documentele se
  • 519. Modele de date semistructurate. Familia XML 165 vor plasa în directorul use-cases al directorului Docs UHSUH]HQWkQG UGFLQD serverului). Interogarile vor putea fi experimentate accesând adresa http:// 127.0.0.1:8000/use-cases/ GXS LQLLDOL]DUHD VHUYHUXOXL 0DUN /RJLF·V &,6
  • 520.  3HQWUX vQFHSXW YRP vQFUFD GDWHOH ;0/ SULQ LQWHUPHGLXO XQHL IXQFLL proprii serverului: xdmp:document-insert("http://www.infoiasi.ro/projects.xml", <projects update="16 octombrie 2004"> <project class="A" id="p6"> <title>Super Proiect</title> <desc>Un proiect super</desc> <stud>3</stud> <url>http://www.super.org/</url> </project> <!-- úL DOWHOH --> </projects> ); xdmp:document-insert("students.xml", <students year="2004"> <student> <name>Mandra Pingo Zuin</name> <project start="2004-10-07">p6</project> </student> <!-- úL DOLL --> </students> ); Fiecare proiect va fi identificat unic prin intermediul atributului id care va servi pentru referirea proiectului ales de un student în cadrul celuilalt document. $ILüDUHD SURSULX-]LV D FRQLQXWXOXL ED]HL GH GDWH Fonstituite se poate UHDOL]D VFULLQG LQWHURJDUHD ;4XHU XUPWRDUH { doc("http://www.infoiasi.ro/projects.xml")/*, doc("students.xml")/* } ([HPSOHOH GHPRQVWUDWLYH SXVH OD GLVSR]LLH GXS LQVWDODUH IDFLOLWHD] VFULHUHD üL H[HFXLD LQWHURJULORU ;4XHU SULQ LQWHUPHGLXO XQHL LQWHUIHH :HE ILJXUD 
  • 521.  'H IDSW VH IRORVHüWH FRnVWUXFLD GH PDL MRV FDUH DSHOHD] OD R IXQFLH GH HYDOXDUH D FRQLQXWXOXL XQXL FkPS <textarea> al formularului de inWHUDFLXQH FX XWLOL]DWRUXO { xdmp:eval(xdmp:get-request-field("queryInput")) }
  • 522. Tehnologii XML166 3HQWUX vQFHSXW YRP OLVWD SURLHFWHOH GH FODV $ RSHUkQG üL PRGLILFUL GH VWUXFWXU D GRFXPHQWXOXL RULJLQDO <proiecte> { for $proj in doc("http://www.infoiasi.ro/projects.xml")/projects/* where $proj/@class = "A" return <proiect> <titlu> { $proj/title/text() } </titlu> </proiect> } </proiecte> 8UPWRDUHD LQWHURJDUH ;4XHU YD IXUQL]D QXPUXO GH SUoiecte propuse GLQ ILHFDUH FODV UHWXUQkQGX-VH XQ FRQLQXW ;+70/ for $clasa in ('A', 'B', 'C')  SHQWUX ILHFDUH FODV. :) let $proiecte := doc("http://www.infoiasi.ro/projects.xml" )//project[@class = $clasa]  SUHOXP OLVWD GH SURLHFWH 
  • 523. return <h:p xmlns:h="http://www.w3.org/1999/xhtml"> {  úL YHULILFP GDF H YLG 
  • 524. if (empty ($proiecte)) then FRQFDW 1X H[LVW SURLHFWH GH FODV  FODVD
  • 525. else concat ("Sunt ", string(count($proiecte)),  SURLHFWH GH FODV  FODVD
  • 526. } </h:p> ÍQ FRQWLQXDUH YRP OLVWD WRL VWXGHQLL DOH FURU QXPH FRQLQ ·3LQJ· üL VH termLQ FX ·XLQ· D VH YHGHD ILJXUD 
  • 527.  <div style="font-size: 14pt"> { for $stud in doc("students.xml")//student let $e := $stud/name[contains (string(.), "Ping") and ends-with (string(.), "uin")]
  • 528. Modele de date semistructurate. Familia XML 167 where exists($e) return <p><i>{ $stud/name/text() } </i> cu proiectul <span style="color: blue"> { $stud/project/text() } </span> </p> } </div> )LJXUD  6HUYHUXO 0DUN /RJLF·V &,6 RIHU SRVLELOLWDWHD GH D UHDOL]D LQWHURJUL LQWHUDFWLYH YLD R LQWHUID :HE O inWHURJDUH UHODWLY PDL FRPSOH[ HVWH FHD GH PDL MRV IXUQL]kQG XQ GRFXPHQW ;0/ FRQLQkQG VWXGHQLL VRUWDL GHVFUHVFWRU GXS QXPH
  • 529. üL titlurile proiectelor alese de fiecare:
  • 530. Tehnologii XML168 <students> { for $stud in doc("students.xml")//student order by $stud/name descending return <student> { $stud/name } { for $proj in doc("http://www.infoiasi.ro/projects.xml")/projects/* where some $projid in $proj/@id satisfies ($projid = $stud/project) return <project class="{ $proj/@class }"> { $proj/title } { $proj/desc } </project> } </student> } </students> 3XWHP GH DVHPHQHD RELQH DFHODüL UH]XOWDW UHFXUJkQG OD R RSHUDLH GH tip join WUDGXV vQ ;4XHU SULQ <students> { for $stud in doc("students.xml")//student, $proj in doc("http://www.infoiasi.ro/projects.xml" )/projects/project[@id = $stud/project] order by $stud/name descending return <student> { $stud/name } <project class="{ $proj/@class }"> { $proj/title } { $proj/desc } </project> </student> } </students>
  • 531. Modele de date semistructurate. Familia XML 169 2 XOWLP LQWHURJDUH – eroQDW – HVWH XUPWRDUHD XQGH IRORVLP IDFLOLWLOH SULYLWRDUH OD FUHDUHD GH QRGXUL ;0/ OXFUXO FX H[SUHVLL UHJXODWH üL OLVWH SOXV DQXPiWH IXQFLL SUHGHILQLWH element studenti { (: lista denumirilor lunilor anului :) let $luni := ('Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun', 'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec') for $stud in doc("students.xml")//student  SUHOXP GRDU SULPXO SURLHFW GDF H[LVW PDL PXOWH 
  • 532. where $stud/project[position() = 1 and xs:date(@start) <= current-date()] return  FUHP HOHPHQWXO VWXGHQW! 
  • 533. element student { (: un comentariu generat dinamic :) comment { concat(' A ales proiectul "', $stud/project, '" ') },  LQYHUVP RUGLQHD QXPHORU VWXGHQWXOXL úL le transforPP vQ PDMXVFXOH 
  • 534. for $nume in tokenize($stud/name/text(), "W+") order by $nume descending return  FUHP HOHPHQWXO LGHQWLWDWH! 
  • 535. element identitate { (: ...având atributul 'nume' :) attribute nume { upper-case($nume) } }, attribute luna {  UHWXUQP GHQXPLUHD OXQLL 
  • 536. $luni[get-month-from-date( xs:date($stud/project/@start))] } } } Predicatul [position()=1 and xs:date(@start) <= current-date()] QX VHOHFWHD] GRDU SULPXO SURLHFW FL DFHL VWXGHQL DOH FURU SULP SURLHFW GLQ document are data din atributul start PDL PLF GHFkW GDWD FXUHQW $FHDVWD vQVHDPQ F SHQWUX VWXGHQLL FDUH DX DVRFLDWH PDL PXOWH SURLHFte, dar
  • 537. Tehnologii XML170 SHQWUX FDUH SULPXO SURLHFW UHVSHFW SUHGLFDWXO H[SUHVLD $stud/project va vQWRDUFH R OLVW GH SURLHFWH FHHD FH JHQHUHD] R HURaUH OD FRQYHUVLD vQ üLU GH FDUDFWHUH 3URJUDPXO IXQFLRQHD] – de exemplu – FkQG GDWD HVWH SODVDW vQ 2004, deoarece pentru studentul cu mai multe proiecte, primul proiect din lista este din 2005, deci nodul student respectiv nu va face parte din rezultatul final. )LJXUD  9L]XDOL]DUHD UH]XOWDWXOXL XQHL LQWHURJUL ;4XHU
  • 538. Modele de date semistructurate. Familia XML 171 2 SRVLELO UHPHGLHUH HVWH DFHHD GH D VSHFLILFD H[Dct primul proiect: în loc de $stud/project scriem $stud/project[1], respectiv $stud/ project[1]/ @start 5H]XOWDWXO LQWHURJULL DSDUH vQ Iigura 30. 6LVWHPXO 0DUN /RJLF·V &,6 SXQH OD GLVSR]LLH R VXLW GH LQWHUIHH GH programare pentru realizarea, via XDBC (XML DataBase Connectivity), de LQWHURJUL ;4XHU GLUHFW GLQ DSOLFDiile concepute în limbaje precum C#, PHP sau Java. De exemplu, pentru PHP, situl Mark Logic’s CIS dedicat dezvoltatorilor SXQH OD GLVSR]LLH XQ $3, UHSUH]HQWDW SULQ GULYHUXO xdbc de conectare la ED]D GH GDWH QDWLY ;0/ IXQFLLOH SULncipale fiind: • xdbc_query() – UHDOL]HD] R LQWHURJDUH ;4XHU • build_result() – IXUQL]HD] UH]XOWDWHOH XQHL LQWHURJUL • build_error() – VHPQDOHD] SRVLELOHOH HURUL VXUYHQLWH 8Q üDEORQ GH SURJUDP 3+3 UHFXUJkQG OD LQWHURJUL ;4XHU SRDWH IL <?php require_once ('xdbc.php'); // biblioteca XDBC IOJ ;'%&B$55$<  RSLXQL GH FRQWURO $flg |= XDBC_XML; $params = array(); XVU FRQWSDURO  GDWH GH DXWHQWLILFDUH $host = "localhost:8010"; $query = "..."; // interogarea XQuery $query = str_replace('"', '"', $query); $query = str_replace("'", "'", $query); if ($flags & XDBC_XML) { // returnarea rezultatului return xdbc_query ($host, $query , $params, $usr, $flg); } else { print_r (xdbc_query ($host, $query , $params, $usr, $flg)); } ?> Utilizarea procesorului Saxon Saxon QX RIHU GRDU VXSRUW SHQWUX UHDOL]DUHD GH WUDQVIRUPUL ;6/ FL üL SRVLELOLWL GH LQWHURJDUH YLD ;4XHU D GRFXPHQWHORU ;0/ ÍO SXWHP IRORVL
  • 539. Tehnologii XML172 ILH GLQ OLQLD GH FRPDQG ILH vQ FDGUXO XQRU DSOLFDLL -DYD SULQ LQWHUPHGLXO inWHUIHHL GH SURJUDPDUH GLVSRQLELOH ÍQ SULPXO FD] QH SURSXQHP V UHDOL]P R LQWHURJDUH DVXSUD GRFXPHQWXOXL ;0/ SULYLWRU OD SXQFWDMHOH RELQXWH GH DQXPLL VWXGHQL OD R GLVFLSOLQ 9RP JHQHUD XQ IUDJPHQW GH GRFXPHQW ;+70/ FRQLQkQG R OLVW QHQXPeURWDW FX QXPHOH VWXGHQLORU FDUH DX DYXW OD proiect punctaj PDL PDUH GHFkW  vQ RUGLQHD GHVFUHVFWRDUH D SXQFWDMHORU üL FUHVFWRU GXS nume. ProJUDPXO ;4XHU YD IL VFULV vQ ILüLHUXO punctaje.xq: xquery version "1.0"; declare namespace h = "http://www.w3.org/1999/xhtml"; <h:ul> { for $punctaj as element(punctaj) in //punctaj let $nota := $punctaj/nota[@tip = "proiect"] let $nume as xs:string := string ($punctaj/@stud) where $nota >= 10 order by $nota descending, $nume ascending return <h:li> { $nume } </h:li> } </h:ul> Am specificat explicit VSDLXO GH QXPH DO HOHPHQWHORU ;+70/ IRORVLWH üL tipurile unor variabile. 3HQWUX D UXOD LQWHURJDUHD DVXSUD ILüLHUXOXL punctaje.xml vom introduce de OD OLQLD GH FRPDQG XUPWRDUHOH D:saxon>java -cp saxon8.jar net.sf.saxon.Query -s punctaje.xml punctaje.xq <?xml version="1.0" encoding="UTF-8"?> <h:ul xmlns:h="http://www.w3.org/1999/xhtml"> <h:li>Moruz Mihai Alex</h:li> <h:li>Abageru Stefan</h:li> <h:li>Dumbrava Andrei-Liviu</h:li> <h:li>Augustin Roxana Maria</h:li> </h:ul> )XUQL]P vQ FRQWLQXDUe scheletul unei metode de invocare a procesorului Saxon dintr-un program Java : import net.sf.saxon.*;  UHDOL]HD] R LQWHURJDUH ;4XHU GDW FD úLU GH Faractere public void XQuery (String xq) {
  • 540. Modele de date semistructurate. Familia XML 173  FRQILJXUULOH SURFHVRUXOXL 6D[RQ Configuration config = new Configuration();  FRQLQH FRQWH[WXO LQWHURJULL StaticQueryContext xquery = new StaticQueryContext (config); try {  FRPSLOP LQWHURJDUHD ;4XHU XQueryExpression exp = xquery.compileQuery (xq); DynamicQueryContext dynamicContext = new DynamicQueryContext (config); // construim contextul (arborele XML ce va fi interogat) dynamicContext.setContextNode( xquery.buildDocument(new StreamSource( new File("punctaje.xml"))));  SUHOXP QRGXULOH FH YRU IL LQWHURJDWH SequenceIterator punctaje = exp.iterator(dynamicContext); // stabilim documentul rezultat DocumentInfo rez = QueryResult.wrap (punctaje, config);  VWDELOLP GLYHUVH SURSULHWL SULYLWRDUH OD Uezultat Properties props = new Properties(); // iHúLUHD YD IL XQ GRFXPHQW ;0/ props.setProperty(OutputKeys.METHOD, "xml");  DO FUXL HOHPHQWH YRU IL LQGHQWDWH props.setProperty(OutputKeys.INDENT, "yes");  UXOP LQWHURJDUHD exp.run(dynamicContext, new StreamResult(sw), props);  VHULDOL]P UH]XOWDWXO DILúkQGX-O OD LHúLUHD VWDndard QueryResult.serialize(rez, new StreamResult(System.out), props); } catch (Exception e) {  WUDWP H[FHSLLOH VXUYHQLWH } } )RORVLQG ÅUHHWDµ GH PDL VXV SXWHP UHDOL]D R DSOLFDLH FDUH V UHDOL]H]H UHSUH]HQWUL JUDILFH DOH XQRU WLSXUL GH IUDFWDOL QuPLL VLVWHPH /LQGHQPDHU (L-Systems) (detalii în Buraga, 2000). Un sistem Lindenmayer este un tip particular de sistem dinamic simbolic (generat printr-R JUDPDWLF
  • 541. vQ FDUH HYROXLD VLVWHPXOXL DUH DWDüDW R LQWHUSUHWDUH JHRPHWULF ED]DW SH JUDILFD turtle 3RUQLQG GH OD XQ üLU LQLLDO QXPLW D[LRP YRU IL DSOLFDWH GH XQ
  • 542. Tehnologii XML174 QXPU N GH RUL DQXPLWH UHJXOL GH WUDQVIRUPDUH SHQWUX D SURGXFH XQ üLU ILQDO FRQLQkQG FRPHQ]L SHQWUX UHSUezentarea grDILF D IUDFWDOXOXL GRULW Reprezentarea fractalului se va face într-un document XML de forma: <gramatica> <initial formula="F" x="100" y="100" iter="4" unghi="60" unghi-inceput="0" dist="10" /> <regula stare="F" trece-in="F-F++F-F" /> <regula stare="-" trece-in="-" /> <regula stare="+" trece-in="+" /> </gramatica> $[LRPD HVWH VSHFLILFDW GH DWULEXWXO formula QXPUXO GH LWHUDLL – de atributul iter, iar regulile gramaticii sunt definite de elementele <regula>. Restul atributelor sunt folosite pentru a controla modul de reprezentare. Comanda „Fµ YD UHDOL]D WUDVDUHD XQXL VHJPHQW GH GUHDSW GH dist pixeli, iar comenzile „+µ üL Å-” vor roti cu unghi JUDGH vQ VHQV WULJRQRPHWULF üL respectiv, invers trigonometric dispozitivul virtual de trasare. Orientarea LQLLDO HVWH VWDELOLW GH YDORDUHD DWULEXWXOXL unghi-inceput. Vom prezenta în continuare un program XQuery care va genera un GRFXPHQW 69* ILJXUkQG IUDFWDOXO VROXLH FRQFHSXW GH DEVROYHQWXO 'UDJRü *DYULOX declare namespace math="java:java.lang.Math";  IXUQL]HD] SDUWHD GUHDSW D XQHL UHJXOL 
  • 543. declare function local:preiaRegula($r as xs:string) as xs:string { for $reg in doc("LSystems.xml")/gramatica/regula[@stare = $r] return $reg/@trece-in };  SURFHVHD] R UHJXO în mod recursiv :) declare function local:parcurgeRegula($r as xs:string, $poz as xs:integer) as xs:string { for $i in 1 to 1 return if ($poz=string-length($r)) then local:preiaRegula(substring($r,$poz,1)) else concat(local:preiaRegula(substring($r,$poz,1)), local:parcurgeRegula($r,$poz+1)) };
  • 544. Modele de date semistructurate. Familia XML 175  SURFHVHD] IRUPXOD 
  • 545. declare function local:procesFormula($r as xs:string, $poz as xs:double,$pasi as xs:double) as xs:string { for $i in 1 to 1 return if ($poz < $pasi) then local:parcurgeRegula(local:procesFormula($r, $poz + 1,$pasi),1) else local:parcurgeRegula($r,1) };  GHVHQHD] R OLQLH D IUDFWDOXOXL conform graficii turtle, folosind <line> din SVG :) declare function local:desenLinie ($expr as xs:string,$poz as xs:integer, $x as xs:double,$y as xs:double,$dist as xs:double , $u as xs:double,$alfa as xs:double) as element()* { for $a in 1 to 1 return for $i in 1 to 2 return if ($i = 1) then if (substring($expr,$poz,1) = "F") then (: se recurge la metodele Math din Java :) <line x1="{$x}" y1="{$y}" x2="{$x + round($dist * math:cos($u * 0.0174)) }" y2="{$y + round($dist * math:sin($u * 0.0174))}" /> else () else for $j in 1 to 1 return if ($poz < string-length($expr)) then if (substring($expr, $poz, 1) = "F") then  ) UHSUH]LQW IRUZDUG GHFL WUDVP R OLQLH 
  • 546. local:desenLinie($expr,$poz + 1,$x + round($dist * math:cos($u * 0.0174)),$y + round($dist * math:sin($u * 0.0174)),$dist,$u,$alfa) else if (substring($expr,$poz, 1) = "+") then (: rotim în sens trigonometric :) local:desenLinie($expr, $poz + 1, $x, $y, $dist, $u + $alfa, $alfa) else if (substring($expr,$poz,1) = "-") then
  • 547. Tehnologii XML176 (: sau în sens invers trigonometric :) local:desenLinie($expr, $poz + 1, $x, $y, $dist, $u - $alfa, $alfa) else () else () }; <svg> <g stroke="black"> {  SUHOXP GDWHOH GLQ GRFXPHQWXO ;0/  FRRUGRQDWHOH LQLLDOH let $x := round( doc("LSystems.xml")/gramatica/initial/@x ) let $y as xs:double := round( doc("LSystems.xml")/gramatica/initial/@y )  QXPUXO GH LQWHUDLL let $n as xs:double := round( doc("LSystems.xml")/gramatica/initial/@iter )  QXPUXO GH SL[HOL DL VHJPHQWXOXL GH GUHDSW let $dist as xs:double := round( doc("LSystems.xml")/gramatica/initial/@dist )  XQJKLXO IRORVLW SHQWUX URWDLL let $alfa as xs:double := round( doc("LSystems.xml")/gramatica/initial/@unghi )  XQJKLXO LQLLDO GH RULHQWDUH let $u as xs:double := round( doc("LSystems.xml")/gramatica/initial/@unghi-inceput ) // axioma (formula de start) let $start-formula := doc("LSystems.xml")/gramatica/initial/@formula  FDOFXOP H[SUHVLD GH GHVHQDUH DSOLFkQG UHJXOLOH let $expr as xs:string := local:procesFormula($start-formula, 1, $n)  GHVHQP IUDFWDOXO FRQIRUP IRUPXOHL JHQHUDWH for $i in 1 to 1 return local:desenLine($expr, 1, $x, $y, $dist, $u, $alfa) } </g> </svg>
  • 548. Modele de date semistructurate. Familia XML 177 3URJUDPXO ;4XHU SRDWH IL UXODW üL GLQ OLQLD GH FRPDQG UHFXUJkQG OD Saxon, rezultatul fiind scris într-XQ ILüLHU 69* D:saxon>java -cp saxon8.jar net.sf.saxon.Query LS.xq >LS.svg 'LQ FDX]D QXPUXOXL PDUH GH DSHOXUL UHFXUVLYH üL D IDSWXOXL F SURFHVDUHD VH HIHFWXHD] vQ PHPRULH QX YRU SXWHD IL VSHFLILFDWH GHFkW YDORUL PLFL pentru atributul iter. Documentul SVG poate fi vizualizat, de exemplu, cu Adobe SVG Viewer YH]L ILJXUD XUPWRDUH
  • 549.  Figura 31. RHSUH]HQWDUHD JUDILF vQ 69* D IUDFWDOXOXL SURFHVDW YLD ;4XHU ûDEORDQHGHSURLHFWDUH;0/ 6.1. Punerea problemei Cum s-DU SXWHD GHVIüXUD XQ SURFHV GH PRGHODUH ;0/ FDUH ar putea avea VXFFHV" ÍQ SULPXO UkQG DXWRULL GH GRFXPHQWH FUHHD] tag-uri din zbor, ILHFDUH SHUVRDQ FRQWULEXLQG FX SURSULLOH VDOH GHQXPLUL GH HOHPHQWH DWULEXWH 2ULFH LQIRUPDLH HVWH PDUFDW LDU GRFXPHQWHOH JHQHUDWH VXQW ELQH formatate, deoarece tag-urile se închid corect. La urma urmei, oricine poate FUHD OLPEDMH ;0/ 6H LJQRU GHOLEerat?) scopurile pentru care se PRGHOHD] LQIRUPDLLOH DFFHVDUHD UHXWLOL]DUHD üL LQWHUVFKLPEXO GH GDWH 7UHEXLH DüDGDU V IDFHP R VHULH GH FRQVLGHUDLL UHIHULWRDUH OD PDQLHUD GH SURLHFWDUH D GRFXPHQWHORU ;0/ &D üL vQ VLWXDLD GH]YROWULL GH VRIWZDUH apDU GLILFXOWL vQ FHHD FH SULYHüWH SURLHFWDUHD XQRU FODVH GH GRFXPHQWH corespun]WRDUH VFRSXULORU XUPULWH üL PDL PXOW GHFkW DWkW SURLHFWDUHD unoUD FDUH V ILH UHXWLOL]DWH XOWHULRU 'UHSW VROXLL YLDELOH RIHULWH GH LQJLQHULD VRIWZDUH VXQW FLWDWH üDEORDQele de proiectare (design patterns
  • 550. üL cadrele de lucru (frameworks). 3URFHVXO GH vQYDUH D SURLHFWULL GH GRFXPHQWH ;0/ ÅEXQHµ ÅFRUHFWHµ
  • 551. HVWH VLPLODU FHOXL GH vQYDUH D XQXL MRF GH üDK VDX JR ÍQ SULPD HWDS WUHEXLH V FXQRDüWHUP UHJXOLOH MRFXOXL SHQWUX D SXWHD DSRL V üWLP principiile – FHOH GHVFULVH PDL VXV VSHUP F L-DX GDW FLWLWRUXOXL LQIRUPDLLOH GH ED] QHFHVDUH DSURIXQGULL ÍQV SHQWUX D GHYHQL PDHVWUX vQ üDK PDL
  • 552. Tehnologii XML178 UPkQ GH VWXGLDW SDUWLGHOH üL VFKHPHOH GH MRF DOH DOWRU PDHüWUL $FHVWHD inclXG üDEORaQH GH UDLRQDPHQWVWUDWHJLH FDUH DU WUHEXL vQHOHVH PHPRUDWH üL DSOLFDWH UHSHWDW DFROR XQGH H FD]XO 6XQW VXWH VDX SRDWH FKLDU PLL GH DVWIHO GH üaEORDQH DSUXWH FX WUHFHUHD WLPSXOXL &XP R DQXPLW SUREOHP SRDWH DSUHD IUHFYHQW GH]YROWDWRULL FX H[SHULHQ ÅPDHüWULLµ
  • 553. DX JVLW GLYHUVH VROXLL SHQWUX SUREOHPD vQ FDX] UHXüLQG V UHFXQRDVF SUREOHPD üL V DOHDJ VROXLD RSWLP
  • 554. FDUH SRDWH IL DSOLFDW vQWU-XQ DQXPLW FRQWH[W 'XS FXP DP Y]XW DSDUH DVWIHO XQ üDEORQ (pattern
  • 555. GH SURLHFWDUH VROXionare) a problemelor. &DGUHOH GH OXFUX DU WUHEXL V RIHUH GH]YROWDWRULORU VXSRUWXO SHQWUX DSOLFDUHD GLYHUVHORU üDEORDQH GH SURLHFWDUH DFROR XQGH HVWH FD]XO &HHVWHXQüDEORQ" Un pattern HVWH R UHJXO FDUH H[SULP R UHODLH GLQWUH XQ FRQWH[W R SUREOHP üL R VROXLH ILJXUD 
  • 556.  $FHVW FRQFHSW D IRVW LQWURGXV OD vQFHSXW vQ Gomeniul DUKLWHFWXULL ILLQG IRORVLW XOWHULRU üL vQ LQIRUPDWLF vQ DULL SUHFXP ingineria VRIWZDUH SURLHFWDUHD LQWHUIHHORU FX XWLOL]DWRUXO GHVLJQXO VLWXULORU HWF Figura 32. RHODLD GLQWUH FRQWH[W SUREOHP üL VROXLH FRQGXFH OD XQ üDEORQ Un üDEORQ SRDWH GHVFULH FXQRüWLQHOH XQXL H[SHUW SH ED]D H[SHULHQHL VDOH SHUVRQDOH
  • 557. vQ GRPHQLXO SUREOHPHL vQ FHHD FH SULYHüWH UHFXQRDüWHUHD SUREOHPHL D FRQWH[WXOXL üL D VROXLHL OD DFHD SUREOHP 8Q pattern nu UHSUH]LQW vQV R UHJXO IHUP XQHRUL QX WUHEXLH DSOLFDW
  • 558.  6XSOLPHQWDU HVWH QHFHVDU DGRSWDUHD XQXL YRFDEXODU FRPXQ FRUHVSXQ]WRU GRPHQLXOXL problemei, re]XOWkQG DüD-QXPLWXO OLPEDM GH üDEORDQH pattern language). ([LVW PDL PXOWH WLSXUL GH üDEORDQH GLQWUH FDUH VH GLVWLQJ FHOH GH SURLHF- WDUH DUKLWHFWXUDOH GH DQDOL] GH FUHDLH VWUXFWXUDOH üL FRPSRUWDPHQWDOH Pentru un pattern YRU WUHEXL VSHFLILFDWH LQIRUPDLL SUHFXP QXPHOH R GHVFUL- HUH SUREOHPD FRQWH[WXO vQ FDUH DSDUH VROXLD FH WUHEXLH DGRSWDW H[HPSOHOH üL XWLOL]ULOH HIHFWLYH &DWHJRULLGHüDEORDQHGHSURLHFWDUH;0/ ÍQ FD]XO QRVWUX QH LQWHUHVHD] üDEORDQHOH GH SURLHFWDUH D GRFXPHQWHORU ;0/ )LUHVF DSDU vQWUHEUL GH JHQXO Å&H VWUXFWXU ;0/ WUHEXLH DGRSWDW
  • 559. Modele de date semistructurate. Familia XML 179 pentru a stoca anumite date sau meta-GDWH"µ üL Å&XP WUHEXLH SURLHFWDW R DSOLFDLH FDUH XWLOL]HD] ;0/ FD OLPEDM GH VSHFLILFDUH VWRFDUH üLVDX prezentare a daWHORU"µ 9RP vQFHUFD PDL MRV V UVSXQGHP OD SULPD întrebare. 'H PHQLRQDW IDSWXO F R VHULH GH üDEORDQH SRW DSUHD üLVDX SRW IL aplicate pentru clase de documente XML specifice (e.g. WUDQVIRUPUL ;6/ sau scheme de validare). Aspecte importante 3URLHFWDUHD VWUXFWXULL XQXL GRFXPHQW ;0/ WUHEXLH V DLE vQ YHGHUH VH UHFXUJH OD üDEORDQH VWUXFWXUDOH
  • 560.  • lungimea documentului; • XüXULQD IRORVLULL PDUFDMHORU ease of authoring); • XüXULQD SURFHVULL ease of processing); • XüXULQD YDOLGULL • flexibilitatea; • FRQVLVWHQD • gradul de abstractizare. Clasificare $VWIHO DYHP OD GLVSR]LLH GLYHUVH üDEORDQH JUXSDWH SH FDWHJRUii: • oportunitatea folosirii tehnologiilor XML: Use XML; • reutilizarea tipurilor de documente existente: Reuse Document Type; • alegerea elementului/elementelor-UGFLQ Multiple Document Types, Multi Root Document Types; • stabilirea gradului de abstractizare: Envelope, Short Understandable Names, Domain Element, Container Element, Collection Element etc.; • asocierea de meta-date (date descriind date): Separate Meta-data & Data, Meta-data in Separate Document, Head-Body, Meta-data First; • organizarea documentului: – UHIHUHQLHUHD XQRU FRQVWUXFLL FDUH vQWkL VH YRU GHFODUD üL DSRL se vor folosi: Declare Before First Use; – DFHHDüL LQIRUPDLH UHIHUHQLDW vQ ORFXUL PXOWLSOH Flyweight; – arbore (ierarhie) versus graf: Marketplace; • H[WLQGHUHD XOWHULRDU Catch-All Element, Role Attribute, Extensible Content Model; • DVLJXUDUHD FRQVLVWHQHL Common Attributes, Consistent Element Set.
  • 561. Tehnologii XML180 9RP GHVFULH vQ FRQWLQXDUH R SDUWH GLQWUH üDEORDQHOH HQXPHUDWH – detalii la www.XMLpatterns.org. Adoptarea modelului XML: Use XML $FHVW üDEORQ GHWHUPLQ VLWXDLD vQ FDUH ;0/ HVWH VROXLD YLDELO GH UHSUH- ]HQWDUH D LQIRUPDLHL VHPL
  • 562. VWUXFWXUDWH ÍQ FDGUXO DSOLFDLLORU GH]YROWDWH SRW H[LVWD UHSUH]HQWUL PXOWLSOH DOH GDWHORU vQ IRUPDW H
  • 563. ELQDU H
  • 564.  &69 +70/ IRORVLQG ED]H GH GDWH UHODLRQDOH RELHFWH VHULDOL]DWH üLVDX ;0/ 6H FRQVLGHU F ;0/ SRDWH IL R VROXLH DGHFYDW DWXQFL FkQG • GDWHOH FRQLQXWXO
  • 565. WUHEXLH VHSDUDWH GH IRUPDWDUH • GDWHOH WUHEXLH SDUWDMDWH vQWUH DSOLFDLL RUJDQL]DLL HWF • UHSUH]HQWDUHD WUHEXLH V SRDW IL vQHOHDV üL GH RDPHQL • rHSUH]HQWDUHD H QHFHVDU V ILH SURFHVDW XüRU GH FDOFXODWRU LQGHSHQ- GHQW GH SODWIRUP üL GH OLPEDM )DFWRULL FDUH WUHEXLH FRQVLGHUDL YL]HD] VLPSOLWDWHD XQ IRUPDW ;0/ excesiv de complicat, „stufos” poate fi inadecvat de cele mai multe ori), extensibilitaWHD YLD VSDLL GH QXPH PXOWLSOH UHGHILQLUHD VFKHPHORU HWF
  • 566.  LQWHURSHUDELOLWDWHD H[LVWHQD LQVWUXPHQWHORU GH SURFHVDUH WUDQVIRUPDUHD IDFLO vQ DOWH UHSUH]HQWUL XüXULQD YDOLGULL üL H[LVWHQD VWDQGDUGL]ULL VH SUHIHU XQ OLPEDM ;0/ GHMD FRQVDFUDW Gecât unul specificat de la zero). 'H DVHPHQHD ;0/ H Y]XW FD XQ OLPEDM SHQWUX UHSUH]HQWDUHD DWkW D GDWHORU FkW üL D PHWD-GDWHORU YH]L FDSLWROXO 
  • 567.  8UPWRUXO IUDJPHQW GH docuPHQW VWRFKHD] DWkW GDWH FkW üL PHWD-date: <rdf:Description rdf:about="studenti.cgi?matricol=33"> <prenume porecla="zmeuldummy">Marius</prenume> <orar> <zi tip="luni">... </zi> </orar> </rdf:Description> )RORVLUHDGHQXPHGHFRQVWUXFLLXüRUGHvQHOHV 1XPHOH HOHPHQWHORU üL DWULEXWHORU WUHEXLH V ILH VFXUWH üL XüRU GH vQHOHV atât GH DXWRUL FkW üL GH GH]YROWDWRULL VRIWZDUH-ului de procesat documentul. ûDEORQXO Short Understandable Names SRDWH IL XWLOL]DW SHQWUX ILHFDUH FODV GH GRFXPHQWH FH GRULP V R SURLHFWP 'H UHPDUFDW F QXPHOH SUHD VFXUWH VXQW GLILFLO GH vQHOHV GDU UHduc lungimea documentelor (mai ales în cazul vQ FDUH YROXPXO GH LQIRUPDLL HVWH PDUH
  • 568.  3RW IL DGRSWDWH üL DQXPLWH FRQYHQLL GH QXPLUH VLPLODUH FHORU IRORVLWH vQ programare. Formele cele mai frecvent folosite sunt <nume_tag>, <NumeTag> sau <numeTag>.
  • 569. Modele de date semistructurate. Familia XML 181 CompaUDL JUDGXO GH FRPSUHKHQVLELOLWDWH DO XUPWRDUHORU QXPH GH HOHPHQWH üL DWULEXWH <b> üL <ul> versus <table> üL <img> GLQ +70/
  • 570. üL <DescriereaEchipamentului CodulEchipamentului="" /> versus <desec c="" />. 3UHFL]DUHDXQXLHOHPHQWGHFRQLQXWContent Element ÍQ PXOWH VLWXDLL SRW H[LVWD HOHPHQWH-copil înrudite ce trebuie grupate într-XQ FRQWDLQHU JHQHULF 1XPHURDVH HOHPHQWH DSDU SH DFHODüL QLYHO vQ GRFXPHQW üL SRW IL GLYL]DWH vQ JUXSXUL GLVWLQFWH FRQIRUP UROXOXL VDX WLSXOXL GH FRQLQXW Pattern-ul facilitHD] VWUXFWXUDUHD GRFXPHQWXOXL GDU H IRDUWH JHQHUDO SRW H[LVWD üDEORDQH PDL VSHFLDOL]DWH GHULYDWH GLQ DFHVWD
  • 571.  6H DGDXJ XQ QLYHO GH DEVWUDFWL]DUH JUXSDUHD HOHPHQWHORU RIHULQG LQIRUPDLL VHPDQWLFH suplimentare (e.g., asocierea de meta-date unui grup de elemente). 8Q H[HPSOX vQ DFHVW VHQV HVWH FHO SULYLWRU OD JUXSDUHD LQIRUPDLLORU SULYLWRDUH OD SUHFL]DUHD FHULQHORU VRIWZDUH üL KDUGZDUH QHFHVDUH SHQWUX rulaUHD XQHL DSOLFDLL 2 SULP DERUGDUH HVWH <config> <ram>512</ram> <hdd tip="...">180</hdd> <parser limbaj="C++">Xerces</parser> <editor>vim</editor> <parser limbaj="Perl">Expat</parser> </config> 2 VROXLH PDL EXQ HVWH V JUXSP ORJLF FHOH GRX FDWHJRULL GH FeULQH <config> <hardware> <ram>512</ram> <hdd tip="...">180</hdd> </hardware> <software> <parser limbaj="C++">Xerces</parser> <parser limbaj="Perl">Expat</parser> <editor>vim</editor> </software> </config> 'UHSW üDEORDQH vQUXGLWH PHQLRQP Head-Body üL Collection Element.
  • 572. Tehnologii XML182 Organizarea datHORUvQFROHFLLCollection Element 6H FUHHD] XQ HOHPHQW DO FUXL PRGHO GH FRQLQXW SHUPLWH GRDU LQVWDQH GH VLQJXU WLS $FHVW DVSHFW H IRORVLWRU DWXQFL FkQG H[LVW XQ HOHPHQW FDUH WUHEXLH UHSHWDW OD DFHODüL QLYHO DO GRFXPHQWXOXL Contextul în care se uWLOL]HD] HVWH FHO SULYLWRU OD JUXSDUHD SH FDWHJRULL D HOHPHQWHORU OD H[LVWHQD PXOWRU ÅIUDLµ siblings), la asocierea de meta-date HWF 6ROXLD HVWH V VSHFLILFP XQ HOHPHQW FRQLQkQG PDL PXOWH HOHPHQWH GH DFHODüL WLS VWUXFWXUD UH]XOWDW ILLQG PXOW PDL XüRU GH SURFHVDW 'LQ SXQFW GH YHGHUH FRQFHSWXDO VH vQFDSVXOHD] R VHULH GH GDWH 'DF YROXPXO GH PHWD-date este mare, se va putea utiliza pattern-ul Head-Body, FDUH RIHU R SDUWLLRQDUH D GRFXPHQWXOXL vQ GRX FRPSDrtimente GLVWLQFWH DüD FXP VH vQWkPSO OD +70/ üL OD 60,/
  • 573.  $FHVW üDEORQ DSDUH IUHFYHQW GUHSW H[HPSOH WLSLFH SXWkQG IL GDWH GLYHUVHOH FRQVWUXFLL SUH]HQWH vQ ;+70/ 5') VDX 'RF%RRN &RQVLVWHQDüLDEVWUDFWL]DUHDFRQLQXWXOXLYLDEnvelope 6H RIHU XQ WLS GH GRFXPHQW FDUH YD GHVHPQD XQ ÅSOLFµ unde se vor putea VWRFD GDWH ;0/ DUELWUDUH 3UREOHPD HVWH FD GLIHULWH VHWXUL GH GDWH V ILH livrate unui sistem, într-R PDQLHU FRQVLVWHQW vQ FRQWH[WXO vQ FDUH VWUXFWXUD GDWHORU GLQ ÅSOLFµ SRDWH YDULD üL QX H FXQRVFXW OD PRPHQWXO FUHULL VLVWH- mului. Pattern-XO SHUPLWH VHSDUDUHD GLIHULWHORU WLSXUL GH FRQLQXWXUL RIHULQG XQ PHFDQLVP GH OLYUDUH D GDWHORU ;0/ SOLFXO QX LQWHUIHUHD] FX FRQLQXWXO propriu-zis al mesajului transmis. 8Q H[HPSOX HGLILFDWRU HVWH RIHULW GH VSHFLILFDLD 62$3 – DPQXQWH vQ capitolul 4. 5HIHUHQLHUHDGDWHORU Flyweight $WXQFL FkQG DFHHDüL LQIRUPDLH HVWH LQFOXV vQ GLIHULWH ORFXUL vQ GRFXPHQW DWXQFL HD SRDWH IL SODVDW R VLQJXU GDW üL UHIHULW vQ ORFXUL PXOWLSOH 3ODVDUHD UHSHWDW D DFHORUDüL GDWH vQ ORFXUL GLIHULWH SRDWH FDX]D HURUL üL GLILFXOWL vQ vQWUHLQHUHD GRFXPHQWXOXL 'H DVHPHQHD FUHüWH QHMXVWLILFDW lungimea documentului. 'UHSW VROXLL WHKQLFH VH HQXPHU XWLOL]DUHD HQWLWLORU ;0/ H[WHUQH
  • 574.  IRORVLUHD GDWHORU ÅVFXIXQGDWHµ YLD ;/LQN UHFXUJHUHD OD DWULEXWHOH ,' üL IDREF etc. $FHVW üDEORQ mreüWH JUDGXO GH PHQWHQDQ üL PRGXODUL]DUH GDU SRDWH DIHFWD DELOLWDWHD GH vQHOHJHUH D GRFXPHQWXOXL
  • 575. Modele de date semistructurate. Familia XML 183 9RP GD XQ H[HPSOX vQ FDUH YLD UHIHULQH OD HQWLWL SODVP vQ FDGUXO XQXL GRFXPHQW ;+70/ DFHHDüL LQIRUPDLH vQ ORFXUL PXOWLSOH vQ titlu, în <meta> üL vQ FRUSXO SDJLQLL
  • 576.  <?xml version="1.0" ?> <!DOCTYPE Titlu [ <!ENTITY titlu "Situl WebGroup"> ]> <html> <head> <title>&titlu;</title> <meta name="description" content="&titlu;" /> </head> <body><h1>&titlu; :: Salut!</h1></body> </html> 0RGHODUHDLQIRUPDLLORU Modelul de date oferit de XML este unul deosebit de flexibil, ceea ce FRQGXFH OD R SURLHFWDUH LQDGHFYDW D GRFXPHQWHORU ;0/ $QXPLWH JUHüHOL deWDOLDWH vQ FDGUXO DFHVWHL VHFLXQL HURGHD] SXWHUHD üL H[SUHVLYLWDWHD limbajului. Metodologii 0RGHODUHD YL]HD] vQ SULPXO UkQG DQDOL]D LQIRUPDLHL information analysis
  • 577.  SURFHV GH LGHQWLILFDUH üL GHILQLUH D PDQLHUHL GH PDUFDUH D XQXL VHW de date în vederea realizarea unor scopuri specifice. Modul de prezentare a GDWHORU üL GH XWLOL]Dre – e.g. LQWHUDFLXQH – D DFHVWRUD IRUPHD] SDUWHD GH DUKLWHFWXU D LQIRUPDLHL information architecture). 3ULPXO SDV HVWH V VWDELOLP DQXPLWH UHJXOL GH SURLHFWDUH FDUH SRW IL SUHVFULSWLYH UHVWULFWLYH
  • 578. VDX GHVFULSWLYH SHUPLVLYH
  • 579.  vQ IXQFLH GH VFRSXUile urPULWH 0RGHOHOH SUHVFULSWLYH VXQW XWLOL]DWH OD FUHDUHD GH QRL LQIRUPDLL XWLOL]kQG UHJXOL VSHFLILFH SHQWUX VWRFDUHD FRQLQXWXOXL üL SRW PRGLILFD GRFXPHQWH YHFKL vQ FRQGLLLOH UHIRORVLULL vQWU-un alt context. Cele descriptive GHVFULX LQIRUPDLL GHMa existente, utilizând reguli flexibile (e.g., anumite ele- PHQWH SRW IL VSHFLILFDWH RSLRQDO vQWU-o ordine aleatorie). Astfel, se permite SURLHFWDUHD GH GRFXPHQWH FDUH VXQW YDULDLL SH R WHP VWUXFWXU
  • 580. GDW ÍQ FHHD FH SULYHüWH VFRSXULOH HOH SRW VWDELOL UHVWULFLRQDUHD XQXL PRGHO pentru a putea fi folosit la crearea unei scheme de baze de date sau la UHGDFWDUHD XQXL WLS VWULFW GH GRFXPHQW XQ DUWLFRO FX R VWUXFWXU IL[DW GH
  • 581. Tehnologii XML184 H[HPSOX
  • 582.  3HQWUX VFKLPEXO GH GDWH VDX FRQYHUVLD DFHVWRUD VH SUHWHD] uneori, modelele mai laxe. 2 VWUXFWXU FRUHVSXQ]WRU SURLHFWDW YD IDFLOLWD FXWDUHD DWkW D LQIRUPDLLORU SURSULX-]LVH FkW üL D XQRU VWUXFWXUL GH GDWH 0DUFDMHOH SRW vPEXQWL UHOHYDQD YLD JUDPDWLFD GHVHPQkQG VWUXFWXUD tag-XULORU
  • 583. üL recall-ul (via vocabularul adoptat). 0DUFDMHOH SRW IL IRORVLWRDUH SHQWUX D SUHFL]D FRQWH[WXO FXWULL LGHQWLILFkQG LQIRUPDLLOH HVHQLDOH VXEGLYL]LXQLOH LPSRUWDQWH üL SRULXQLOH cuprinzând date efective. De exemplu, utilizatori din domenii variate ar GRUL V JVHDVF R H[SUHVLH GDF DFHDVWD DSDUH vQWU-unul dintre contextele: VHFLXQHD GH FRQFOX]LL RELHFWLYHOH GRFXPHQWXOXL DXWRUXO OLVWD GH GRFXPHQWH înrudiWH DSOLFDLLOH ORFDLD IL]LF LPSOLFDLLOH SH WHUPHQ OXQJ De asemenea, marcajele pot fi utilizate la identificarea infoUPDLLORU neimportante sau nerelevante într-XQ DQXPLW FRQWH[W 'H SLOG vQWU-o FXWDUH SRW IL H[FOXVH VHFLXQLOH GH GRFXPHQW SULYLWRDUH OD UHIHULQH H[SHULPHQWH PHWRGRORJLH LQWURGXFHUH LVWRULF GLUHFLL YLLWRDUH WHUH SHUVRDQH FDUH DX DYXW FRQWULEXLL OD FRQLQXW üDPG 0DL PXOW PRGHOXO VWUXFWXUDO DGRSWDW WUHEXLH V RIHUH VXSRUW SHQWUX navigabilitate, exprimând meta-GDWHOH OHJWXULOH KLSHUWH[W LQIRUPDLLOH bibliografice, maniera de identificare a altor obiecte, indicii, asocierile de subiecte, URI-urile etc. 9RFDEXODUXO WUHEXLH V ILH XQXO FRQWURODW VSHFLILF GRPHQLXOXL GH FXQRDü- WHUH PRGHODW üL IDFLOLWkQG FXWDUHD 'H H[HPSOX WLSXO XQXL HFKLSDPHQW SULYLWRU OD WHOHFRPXQLFDLL SRDWH SUHFL]D FDWHJRULLOH GH WHOHIRDQH PRELOH üLVDX GH FHQWUDOH IRORVLte. Specificarea subiectului unui document poate OXD vQ FRQVLGHUDLH GLYHUVH VLVWHPH GH FODVLILFDUH /HJWXULOH FRQFHStuale vQWUH IUDJPHQWH GH LQIRUPDLL YRU vPEXQWL UHOHYDQD FXWULORU În primul rând, analiza datelor ce dorim a fi modelate trebuie s RIHUH LQIRUPDLL UHIHULWRDUH OD FH DQXPH HVWH UHOHYDQW e.g. LQIRUPDLL-cheie, SRULXQL GH LQIRUPDLL ERJDWH vQ FRQLQXW VFRSXULOH FRQLQXWXOXL HWF
  • 584. üL folosiWRU QH LQWHUHVHD] XWLOL]DUHD UHXWLOL]DUHD PRGXO GH DFFHVDUH
  • 585.  'H DVHPHQHD WUHEXLH V UVpundem la întrebarea „Ce trebuie identificat în FDGUXO GDWHORU FH YRU IL PRGHODWH"µ 5HFRPDQGDELO DU IL V SURLHFWP PDL întâi un cadru de lucru (framework) conceptual, oferind infrastructura de ED] DGXJkQG DSRL ÅPRGXOHµ VXSOLPHQWDUH IRORVLWH SHQWUX SUHzentarea GDWHORU FRQWUROXO YHUVLXQLORU VWULL üL DFFHVXOXL üL PDQLHUD GH DVociere a meta-datelor. Mai trebuie stabilite anumite constrângeri – VLQWDFWLFH üL VHPDQWLFH – SHQWUX D QH DVLJXUD F GRFXPHQWHOH YRU IL IRORVLWRDUH useful
  • 586. üL corecte/consistente (clean
  • 587.  0DL PXOW YRU IL GHVFULVH UHODLLOH VWDELOLWH vQWUH
  • 588. Modele de date semistructurate. Familia XML 185 comSRQHQWHOH LQIRUPDLRQDOH üL SURSULHWLOH DFHVWRU FRPSRQHQWH 6XSOLPHQWDU VH SRW LPSXQH UHVWULFLL DGLLRQDOH e.g. RUJDQL]DLRQDOH comerciale etc.) 0HWRGRORJLD GH DQDOL] LQIRUPDLRQDO VH ED]HD] DFWXDOPHQWH SH DSRU- WXO XWLOL]DWRULORU ILQDOL FDUH SRW DYHD XQ URO LPSRUWDQW vQ FHHD FH SULYHüWH H[WUDJHUHD LQIRUPDLLORU FUHDUHD FRQVHQVXOXL üL UH]ROYDUHD FRQIOLFWHORU GH modelare (proiectare). Alegerea elementelor 2 SULP DFWLYLWDWH FDUH WUHEXLH GHVIüXUDW vQ SURLHFWDUHD XQXL OLPEDM ;0/ HVWH V JVLP üL V QXPLP HOHPHQWHOH 7UHEXLH JVLWH UVSXQVXUL OD vnWUHEUL precum „Ce sunt «documentele»?”, „Care sunt cele mai largi componente VWUXFWXUDOH VDX GH FRQLQXW"µ Å&DUH VXQW SULOH DWRPLFH GLQ cadrul unora PDL FXSULQ]WRDUH"µ Din cele de mai sus, vom alege/reutiliza elemente pentru a colecta sau LGHQWLILFD IUDJPHQWH UHOHYDQWH GH LQIRUPDLH 7UHEXLH V GHFLGHP FHHD FH HVWH LPSRUWDQW üL YD IL XWLOL]DW vQ PRPHQWXO SURFHVULL 'H DVHPHQHD informaLLOH FX VWUXFWXULFRQLQXWXUL GLIHULWH WUHEXLH V ILH vQFDSVXODWH vQ elemente (generice). 'H QRWDW IDSWXO F QX H[LVW XQ PDUFDM ÅLGHDOµ 'DF RSWLPL]P R VWUXFWXU ;0/ SHQWUX D VDWLVIDFH XQ DQXPH VFRS V-DU SXWHD FD DFHDVWD V ILH toWDO LQDGHFYDW vQ DOW VLWXDLH 3HQWUX D GHSüL DFHVW LQFRQYHQLHQW SXWHP XOWHULRU UHFXUJH OD WUDQVIRUPUL ;6/ 6WUDWHJLD GH DOHJHUH D HOHPHQWHORU ÅFRUHFWHµ HVWH vQ SULPD ID] XQD GH sus în jos (top-down, outside-in); apoi, putem rafina de jos în sus (bottom-up), via grupare. Elementele pot stoca: • date propriu-]LVH FRQLQXW
  • 589. – FH WLS GH LQIRUPDLH YD IL VWRFDW • blocuri structurale – FH DQXPH UHSUH]LQW GRFXPHQWXO • descrieri/moduri de acces – FH FXQRDüWHP despre LQIRUPDLL • LQGLFDLL SULYLWRDUH OD FRPSRUWDPHQW Maniera de strXFWXUDUH SRDWH IL GHVIüXUDW GLQ SXQFW GH YHGHUH IL]LF VDX ORJLF LDU FRQLQXWXO SRDWH GHVHPQD XQ vQHOHV meaning
  • 590. RUL R FODV GH LQIRUPDLL FRQLQXW SURSULX-]LV
  • 591.  8QHRUL WUHEXLH IFXWH UHFRQFLOLHUL vQWUH FHOH GRX DERUGUL (OHPHQWHOH GHVFULSWLYH UHSUH]LQW vQ IDSW FRQWDLQHUH GH meta-date (e.g. VFRS PRG GH XWLOL]DUH GHVFULHUH GDWD FUHULL HWF
  • 592. VDX SRW LQFOXGH LQIRUPDLL SULYLQG PRGXO GH DFFHVFXWDUH GH H[HPSOX FXYLQWH- -FKHLH WHUPHQL RQWRORJLL HWF
  • 593.  (OHPHQWHOH FRPSRUWDPHQWDOH IDFLOLWHD] expriPDUHD OHJWXULORU KLSHUWH[W DSHOXO GH SURJUDPH H[WHUQH HWF
  • 594. Tehnologii XML186 2 SULP JUHüHDO HVWH FHD SULYLWRDUH OD QXPUXO PDUH GH HOHPHQWH definite (tag abuse), ceea ce conduce la probleme de procesare, portabilitate sc]XW GLILFXOWL vQ vQHOHJHUH üL UHGXFHUHD UHXWLOL]ULL FODVHL GH GRFXPHQW $üD FXP DP SUHFL]DW PDL VXV QXPHOH GH HOHPHQWH WUHEXLH V ILH IDPL- OLDUH VFXUWH üL XüRU GH UHDPLQWLW ÍQ DOHJHUHD QXPHORU WUHEXLH V LQHP FRQW GH FRQWH[WXO XWLOL]ULL XQHOH HOHPHQWH DU SXWHD DSUHD vQ VLWXDLL PXOWLSOH
  • 595.  'H UHPDUFDW üL IDSWXO F QXPHOH XQXL HOHPHQW GHVHPQHD] WLSXO DFHVWXLD üL QX WLSXO FRQLQXWXOXL $VWIHO XQ HOHPHQW DU WUHEXL V QXPHDVF R FDUDFWHULVWLF SURSULHWDWH
  • 596.  üL QX YDORDUHD DFHVWHLD Documentul de mai jos e inadecvat din punct de vedere conceptual QXPHOH GH HOHPHQWH GHVHPQHD] YDORUL DOH XQRU QXPH GH IRUPDLL
  • 597.  <Pink><Floyd /></Pink> <Dead><Can /><Dance /></Dead> 2 DOW YDULDQW QLFL HD VDWLVIFWRDUH HVWH XUPWRDUHD <formatie1>Pink Floyd<formatie1> <formatie2>Dead Can Dance<formatie2> ... <formatie33>Planet Funk<formatie33> 3ULQ HOHPHQWH SRW IL VSHFLILFDWH üL UHODLLOH GLQWUH FRPSRQHQWHOH LQIRUma- LRQDOH PRGHODWH • ierarhii – HOHPHQWH IXQFLRQkQG GUHSW FRQWDLQHUH • VHFYHQH – VH SRW LPSXQH R RUGLQH ULJXURDV VDX XQ VHW GH DOWHU- native; • apaULLL – FX FDUDFWHU REOLJDWRULX VDX RSLRQDO RUL UHIHULWRDUH OD repetabilitate; • VLPLODULWL – WLSXUL JUXSXUL UDILQUL • referinH – GH JHQXO ÅYH]L üL«µ see also) ori „despre” (about). 'HILQLUHD FRQVWUkQJHULORU LD vQ FRQVLGHUDLH FRQWH[WXO XQGH üL FXP va fi XWLOL]DW XQ DQXPLW HOHPHQW
  • 598.  FRQLQXWXO FH YD FXSULQGH XQ HOHPHQW
  • 599. üL PRGXO GH DSDULLH GH FkWH RUL YD DSUHD HYHQWXDO vQ IXQFLH GH FRQWH[W
  • 600.  'H DVHPHQHD VH SRW VSHFLILFD üL DQXPLWH GHSHQGHQH SUHFXP ÅGDF H[LVW HOHPHQWXO <comanda>, atunci trHEXLH V H[LVWH vQ <produs>” sau „elementele <credit> üL <debit> VXQW PXWXDO H[FOXVLYHµ 6SHFLILFDLLOH ;0/ 6FKHPD üL 5(/$; 1* SRW H[SULPD DVHPHQHD GHSHQGHnH GXS FXP se poate remarca din exemplul de mai jos: <xsd:element name="info"> <xsd:complexType mixed="false"> <xsd:choice minOccurs="1" maxOccurs="1">
  • 601. Modele de date semistructurate. Familia XML 187 <xsd:element name="credit" type="xsd:string"/> <xsd:element name="debit" type="xsd:string"/> </xsd:choice> </xsd:complexType> </xsd:element> $OWH GHSHQGHQH QX SRW IL actualmente modelate în XML Schema. Un exemplu este cel în care elementul-UGFLQ DO XQXL GRFXPHQW GRULP V DSDULQ PDL PXOWRU VSDLL GH QXPH 6ROXLD H RIHULW GH 5(/$; 1* <element xmlns="http://relaxng.org/ns/structure/1.0"> <choice> <name ns="http://www.infoiasi.ro/info#">info</name> <name ns="http://alternativ.info/">info</name> <name ns="urn:info.ro">info</name> </choice> <text/> </element> 'DF GHSHQGHQHOH üL FRQVWUkQJHULOH QX SRW IL H[SULPDWH SULQ QLFL R PDQLHU IRUPDO, ele trebuie documentate pentru a putea fi rezolvate la nivel de program. /D ILQDOXO SDüLORU SUH]HQWDL PDL VXV WUHEXLH V WHVWP PRGHOXO SURLHFWDW 6H XWLOL]HD] LQVWDQH GH GRFXPHQWH FDUH V VXUSULQG DWkW FRUHFWLWXGLQHD FkW üL LQFRUHFWLWXGLQHDGHILFLHQHOH PRGHOXOXL 'H DVHPHQHD VH FRQGXF WHVWH GH DFFHSWDUH D PRGHOXOXL GH FWUH XWLOL]DWRUL üL VH SRDWH GHPDUD üL XQ proiect-SLORW GH LPSOHPHQWDUH SUDFWLF Alegerea atributelor 'HüL PXOWH GLQ FHOH SUHFL]DWH DQWHULRU VH DSOLF üL vQ FD]XO DWULEXWHORU YRP IDFH R VHULH GH FRQVLGHUDLL VXSOLPHQWDUH $WULEXWHOH DU WUHEXL V GHVFULH PRGXO GH LQWHUSUHWDUH D HOHPHQWHORU FRQLQkQG GDWH VDX DQXPLWH FDUDFWHULVWLFL i.e. meta-date). Se poate recurge OD üDEORQXO Role Attribute FDUH SUHFL]HD] F SHQWUX XQ DQXPLW HOHPent SRDWH IL DWDüDW XQ DWULEXW GHVFULLQGX-i rolul (caracteristica definitorie). 'H SLOG SXWHP SUHFL]D UROXO XQXL GHSDUWDPHQW vQWU-o companie VSHFLILFkQG YDORULOH WUHEXLH V ILH PXWXDO H[FOXVLYH GHRDUHFH QX Sutem DYHD DSDULLL PXOWLSOH GH DWULEXWH FX DFHODüL QXPH
  • 602.  <departament rol="cercetare">...</departament> 6H UHGXFH DVWIHO QXPUXO GH HOHPHQWH FH WUHEXLH GHILQLWH QX PDL DYHP nevoie de un element precum <departament_cercetare>).
  • 603. Tehnologii XML188 0DL PXOW SXWHP XWLOL]D üDEORQXO Common Attributes pentru a recurge la DFHODüL VHW GH DWULEXWH – familiar deja utilizatorului din alte contexte – într-o VLWXDLH GDW 'H H[HPSOX GDF GH OD ;+70/ VH üWLH F style este folosit SHQWUX D DWDüD SURSULHWL GH VWLO XQXL HOHPHQW WRW style H DGRSWDW üL GH DOWH VSHFLILFDLL e.g., SVG sau XFrames). ([LVW QXPHURDVH H[HPSOH vQ FDUH LQIRUPDLLOH VXQW SODVDWH H[FOXVLY vQ FDGUXO DWULEXWHORU LDU FRQLQXWXO HOHPHQWXOXL FDUH OH FRQLQH HVWH YLG 8Q H[HPSOX H XUPWRUXO <preferinte tema="delta" rezolutie="1024x768" browser="Mozilla 1.5" /> Mai mult decât atât, valorile atributelor rezolutie üL browser folosesc o FRQYHQLH GH UHSUH]HQWDUH FDUH QX VH SRDWH GHGXFH H[SOLFLW SURFHVkQG GRFXPHQWXO $SDU vQWUHEULQHGXPHULUL Å&XP GHSDUWDMP QXPHOH DSOLFDLHL GH YHUVLXQHD VD"µ VDX Å&H VH vQWkPSO GDF OD XQ PRPHQW GDW WUHEXLH PHPRUDW R OLVW D QDYLJDWRDUelor preferate?” 2 VROXLH PDL EXQ DU SXWHD IL H[SOLFLWP XQLWLOH GH PVXU IRORVLWH üL RIHULP VXSRUW SHQWUX H[WLQGHUHD XOWHULRDU D OLVWHL GH SUHIHULQH
  • 604.  <preferinte> <tema>delta</tema> <rezolutie> <latime unitate="px">1024</latime> <lungime unitate="px">768</lungime> </rezolutie> <browser versiune="1.5">Mozilla</browser> </preferinte> 'LQ DFHVW H[HPSOX VLPSOX VH SRDWH GHGXFH IDSWXO F XQ HOHPHQW VH SRDWH utilL]D DWXQFL FkQG LQIRUPDLLOH PDUFDWH GH DFHVWD VXQW SUL FRQVWLWXHQWH DOH unui element-SULQWH 'DF LQIRUPDLLOH DX OHJWXU FX SULQWHOH GDU QX UHSUH]LQW R SDUWH FRQVWLWXHQW D DFHVWXLD VH IRORVHVF DWULEXWH 'H H[HPSOX SXWHP WLD GLQWU-un copac o raPXU GDU QX-i putem elimina greutatea. )LHFDUH UDPXU YD SXWHD IL PRGHODW YLD XQ HOHPHQW LDU YDORDUHD JUHXWLL YD IL VWRFDW GH XQ DWULEXW 'H DLFL SXWHP REVHUYD F HOHPHQWHOH SRVHG QRGXUL LDU DWULEXWHOH SUR- prieWL 9DORULOH DWULEXWHORU QX VXQW GH IDSW GHFkW üLUXUL GH FDUDFWHUH GHFL QX SUH]LQW QLFL R VWUXFWXU vQ WHUPHQLL ;0/
  • 605.  ÍQ SUDFWLF DFHVW DVSHFW SRDWH FDX]D GLILFXOWL GHRDUHFH YDORULOH SURSULHWLORU QHFHVLW H[LVWHQD unei anumite structuri – a se revedea exemplul anterior. În acest caz, se SUHIHU IRORVLUHD HOHPHQWHORU vQ GHWULPHQWXO DWULEXWHORU 'H DOWIHO H[LVW R
  • 606. Modele de date semistructurate. Familia XML 189 propuneUH QXPLW Minimal XML, care permite specificarea doar a elementelor, atributele fiind interzise. Gradul de abstractizare *UDQXODULWDWHD GDWHORU üL WLSXO GH DEVWUactizare folosit într-un document YDULD] vQ IXQFLH GH FRQWH[W *UDGXO GH DEVWUDFWL]DUH SRDWH IDFLOLWD üL PDQLHUD GH SURFHVDUH D FRQLQXWXOXLVWUXFWXULL ;0/ 6SDLXO DORFDW üL VSHFLILFXO FULL QX QH SHUPLW V LQWUP vQ GHWDOLL 9RP prezenta doar un exemSOX &RPSDUDL PDQLHUD GH UHSUH]HQWDUH D XQHL GDWH FDOHQGDULVWLFH vQ XUPWRDUHOH GRX IRUPH &DUH GLQWUH DERUGUL VH SUHWHD] XQHL SUHOXFUUL IU DPELJXLWL OLSVLW GH VSHFLILFDLL VXSOLPHQWDUH SULYLWRDUH OD FRQYHQLLOH GH VLQWD[ DGRSWDWH" <data_curenta>10-11-2006</data_curenta> <data_curenta> <ziua>10</ziua> <luna>11</luna> <anul>2006</anul> </data_curenta> 5HIHULQH Abiteboul, S.; Buneman, P.; Suciu, D., Data on the Web. From Relations to Semistructured Data and XML, Morgan Kaufmann, 2000 Adler, S. et al., Extensible Stylesheet Language (XSL) Version 1.0, W3C Recommendation, Boston, 2001: http://www.w3.org/TR/xsl/ Axelsson, J. et al. (eds.), XHTML™ 2.0, W3C Working Draft, Boston, 2005: http://www.w3.org/TR/xhtml2 Berlung, A. (ed.), Extensible Stylesheet Language (XSL) Version 1.1, W3C Candidate Recommendation, Boston, 2006: http://www.w3.org/TR/xsl11/ Berlung, A. et al. (eds.), XML Path Language (XPath) 2.0, W3C Working Draft, Boston, 2005: http://www.w3.org/TR/xpath20/ Biron, P.; Malhotra, A. (eds.), XML Schema Part 2: Datatypes (Second Edition), W3C Recommendation, Boston, 2004: http://www.w3.org/TR/xmlschema-2/ Boag et al. (eds.), XQuery 1.0: An XML Query Language, W3C Working Draft, Boston, 2005: http://www.w3.org/TR/xquery/ Bos, B. et al. (eds.), Cascading Style Sheets – Level 2, W3C Recommendation, Boston, 1998: http://www.w3.org/TR/REC-CSS2 Bourret, R., XML and Databases, 2005: http://www.rpbourret.com/xml/ XMLandDatabases.html Bourret, R., Goind Native: Making the Case for XML Databases, XML.com, 2005: http://www.xml.com/pub/a/2005/03/30/native.html
  • 607. Tehnologii XML190 Boyer, J. et al. (eds.), XForms 1.0 (Second Edition), W3C Proposed Recommendation, Boston, 2005: http://www.w3.org/TR/xforms/ Bray, T. et al. (eds.), Extensible Markup Language 1.0 (Third Edition), W3C Recommendation, Boston, 2004: http://www.w3.org/TR/REC-xml Bray, T. et al. (eds.), Extensible Markup Language 1.1, W3C Recommendation, Boston, 2004: http://www.w3.org/TR/xml11 Bray, T.; Hollander, D.; Layman, A., Namespaces in XML, W3C Recommendation, Boston, 1999: http://www.w3.org/TR/REC-xml-names Buraga, S., „Reprezentarea sistemelor Lindenmayer ca documente XML”, /XFUULOH 3ULPHL &RQIHULQH GH ,QIRUPDWLF 7HRUHWLF üL 7HKQRORJLD ,QIRUPDLHL – CITTI &RQVWDQD 2000: http://www.infoiasi.ro/~busaco/publications/articles/lsml-pub.pdf Buraga, S., Tehnologii Web 0DWUL[ 5RP %XFXUHüWL  http://www.infoiasi.ro/ ~busaco/books/web.html Buraga, S. et al., 3URJUDPDUH :HE vQ EDVK üL 3HUO 3ROLURP ,DüL  http://www.infoiasi.ro/~cgi/ Buraga, S., 6HPDQWLF :HE )XQGDPHQWH üL DSOLFDLL 0DWUL[ 5RP %XFXUHüWL  http://www.infoiasi.ro/~sweb/ Buraga, S., Proiectarea siturilor Web HGLLD D GRXD
  • 608.  3ROLURP ,DüL  http://www.infoiasi.ro/~design/ Buraga, S. (coord.), $SOLFDLL :HE OD FKHLH 3ROLURP ,DüL  http://www.infoiasi.ro/ ~phpapps/ Buraga, S. (coord.), 6LWXUL :HE OD FKHLH 6ROXLL SURIHVLRQDOH GH LPSOHPHntare, Polirom, ,DüL  http://www.infoiasi.ro/~busaco/books/webapps/ Chamberlain, D.; Florescu, D.; Robie, J. (eds.), XQuery Update Facility, W3C Working Draft, Boston, 2006: http://www.w3.org/TR/xqupdate/ Clark, J. (ed.), XSL Transformations (XSLT) ± Version 1.0, W3C Recommendation, Boston, 1999: http://www.w3.org/TR/xslt Clark, J.; Kawaguchi, K., Guidelines for using W3C XML Schema Datatypes with RELAX NG, OASIS Committee Specification, 2001 Clark, J.; Murata, M., RELAX NG Specification, OASIS Committee Specification, 2001 Clark, J.; Murata, M., RELAX NG DTD Compatibility, OASIS Committee Specification, 2001 Clark, J.; DeRose, S. (eds.), XML Path Language (XPath) Version 1.0, W3C Recommendation, Boston, 1999: http://www.w3.org/TR/xpath Cowan, J.; Tobin, R. (eds.), XML Information Set (Second Edition), W3C Recommendation, Boston, 2004: http://www.w3.org/TR/xml-infoset Daconta, M.; Obrst, L.; Smith, K., The Semantic Web, Wiley Publishing, 2003 Daum, B.; Merten, U., System Architecture with XML, Elsevier Science, 2003 DeRose, S.; Maler, E.; Orchad, D. (eds.), XML Linking Language (XLink) Version 1.0, W3C Recommendation, Boston, 2001: http://www.w3.org/TR/xlink/
  • 609. Modele de date semistructurate. Familia XML 191 DeRose, S. et al. (eds.), XML Linking Language (XLink) Version 1.1, W3C Working Draft, Boston, 2005: http://www.w3.org/TR/xlink11/ Dick, K., XML: A Manager’s Guide HGLLD D GRXD
  • 610.  $GGLVRQ :HVOH  Dubinko, M. et al. (eds.), XForms 1.0, W3C Recommendation, Boston, 2003: http://www.w3.org/TR/xforms/ Fallside, D.; Walmsley, P., XML Schema Part 0: Primer Second Edition, W3C Recommendation, Boston, 2004: http://www.w3.org/TR/xmlschema-0/ Fernández, M. et al. (eds.), XQuery 1.0 and XPath 2.0 Data Model, W3C Working Draft, Boston, 2005: http://www.w3.org/TR/xpath-datamodel/ Florescu, D., „Managing Semi-Structured Data”, Semi-Structured Data, vol. 3, nr. 8, 2005 Fotache, M., Proiectarea bazelor de date 3ROLURP ,DüL  Eisenberg, A.; Melton, J., XQuery 1.0 is Nearing Completion, SIGMOD Record, vol. 34, nr. 4, decembrie 2005 Gennick, J., „SQL in, XML Out”, Oracle Magazine, mai/iunie 2003 Gennick, J., „XQuery Flowers”, Oracle Magazine, septembrie/octombrie 2005 Geroimenko, V., Dictionary of XML Technologies and the Semantic Web, Springer-Verlag, 2004 Goldfarb, C., The SGML Handbook, Oxford Press, 1990 Grosso, P. et al. (eds.), XPointer Framework, W3C Recommendation, Boston, 2003: http://www.w3.org/TR/xptr-framework/ Harold, E., „Managing XML Data: Native XML Databases”, developerWorks, IBM, 2005 Jacobs, I.; Walsh, N., Architecture of the World Wide Web, Volume One, W3C Recommendation, Boston, 2004: http://www.w3.org/TR/webarch/ Jucan, T., Limbaje formalH üL DXWRPDWH 0DWUL[ 5RP %XFXUHüWL  Katz, H. (ed.), XQuery from the Experts: A Guide to the W3C XML Query Language, Addison Wesley, 2003 Kay, M., XPath 2.0 Programmer’s Reference, Wiley Publishing, 2004 Kay, M. (ed.), XSL Transformations (XSLT) ± Version 2.0, W3C Working Draft, Boston, 2005: http://www.w3.org/TR/xslt20/ Le Hors, A. et al. (eds.), Document Object Model (DOM) Level 2 Core Specification ± Version 1.0, W3C Recommendation, Boston, 2000: http://www.w3.org/TR/ DOM-Level-2-Core Le Hors, A. et al. (eds.), Document Object Model (DOM) Level 3 Core Specification ± Version 1.0, W3C Recommendation, Boston, 2004: http://www.w3.org/TR/ DOM-Level-3-Core Malhotra, A.; Melton, J.; Walsh, N. (eds.), XQuery 1.0 and XPath 2.0 Functions and Operators, W3C Working Draft, Boston, 2005: http://www.w3.org/TR/ xpath-functions/ Marsh, J.; Veillard, D.; Walsh, N. (eds.), xml:id Version 1.0, W3C Recommendation, Boston, 2005: http://www.w3.org/TR/xml-id/
  • 611. Tehnologii XML192 McCarron, S.; Pemberton, S.; Raman, T. (eds.), XML Events, W3C Recommendation, Boston, 2003: http://www.w3.org/TR/xml-events Melton, J.; Muralidhar, S., XML Syntax for XQuery 1.0 (XQueryX), W3C Working Draft, 2005: http://www.w3.org/TR/xqueryx Obasanjo, D., XML Namespaces and How They Affect XPath and XSLT, MSDN, 2002 Ogbuji, U., Google Sitemaps, XML.com, 2005: http://www.xml.com/lpt/a/2005/ 10/26/google-site-maps.html Onose, N.; Simeon, J., „XQuery at Your Web Service”, Proceedings of WWW 2004 International Conference, ACM Press, 2004 Pawson, D., XSL-FO, O’Reilly, 2002 Raman, T.V., XForms: XML Powered Web Forms, Addison Wesley, 2003 Sandoz, P. et al., Fast Infoset, Sun Developer Network, iunie 2004: http://java.sun.com/ developer/technicalArticles/xml/fastinfoset/ Van der Vlist, E., XML Schema, O’Reilly, 2002 Van der Vlist, E., RELAX NG, O’Reilly, 2003 * * *, Apache XML: http://xml.apache.org/ * * *, Berkeley DB XML: http://www.sleepycat.com/products/bdbxml.html * * *, Café con Lèche: http://www.cafeconleche.org/ * * *, ECMA (European Computer Manufacturers Association): http://www.ecma- international.org/ * * *, eXists: http://exist.sourceforge.net/ * * *, Expat: http://expat.sourceforge.net/ * * *, FormsPlayer: http://www.formsPlayer.com/ * * *, Jabber: http://www.jabber.org/ * * *, libxml: http://xmlsoft.org/ * * *, Mark Logic’s CIS: http://xqzone.marklogic.com/ * * *, Oracle Technology Network: http://www.oracle.com/technology/ * * *, Oxygen XML Editor: http://www.oxygenxml.com/ * * *, Saxon: http://saxon.sourceforge.net/ * * *, ûDEORDQH GH SURLHFWDUH ;0/: http://www.xmlpatterns.org/ * * *, Trang: http://www.thaiopensource.com/relaxng/trang.html * * *, World-Wide Web Consortium, Boston, 2006: http://www.w3.org/ * * *, XFront: http://www.xfront.com/ * * *, XML Standards Library: http://xmlstds.xemantics.com/ * * *, XSmiles: http://www.xsmiles.org/ * * *, ZVON: http://www.zvon.org/
  • 612. Capitolul 3 3URFHVUL;0/ Å5HJXOD GH DXU HVWH F QX H[LVW UHJXOL GH DXUµ George Bernard Shaw 6H UHDOL]HD] R WUHFHUH vQ UHYLVW DVXSUD FHORU PDL FXQRVFXWH PDQLHUH de procesare a documentelor XML, insistând asupra modelului DOM (Document Object Model
  • 613. üL D LQWHUIHHL de programare SAX (Simple API for XML). Sunt furnizate exemple de cod-VXUV VFULV vQ OLPEDMH SUHFXP & & -DYD 3HUO üL 3+3 VXE SODWIRUPHOH /LQX[ üL :LQGRZV 'H DVHPHQHD VH SUH]LQW üL DOWH PHWRGH GH SURFHVDUH DFFHQWXO ILLQG SXV asupra celor oferite de .NET Framework. Cuvinte-cheie: procesare, DOM, SAX, programare, cod-VXUV H[HPSOL- ILFUL 1. Preliminarii 'RFXPHQWHOH ;0/ WUHEXLH V ILH SUHOXFUDWH vQ GLIHULWH PRGXUL 1H UHIHULP vQ SULPXO UkQG OD SURFHVDUHD FRQLQXWXOXL GDU üL OD QHFHVLWLOH SULYLnd UHDOL]DUHD GH WUDQVIRUPUL üL YDOLGUL ;0/ vQ FDGUXO XQRU DSOLFDLL ILH HOH destinate Web-ului sau nu. ([LVW PDL PXOWH VROXLL OD FDUH SXWHP UHFXUJH DFWLYLWDWHD GH SURFHVDUH D datelor XML putând avea loc: • manual – VH SRDWH VFULH XQ SURJUDP FDUH V UHalizeze prelucrarea documentelor XML prin intermediul unor tehnici inspirate de la DQDOL]D VLQWDFWLF D WH[WHORU UHFXUJkQGX-se – de exemplu – la expresiile regulate; • vQ PDQLHU RELHFWXDO – FRQIRUP VSHFLILFDLHL ;0/ ,QIRVHW SUH]HQWDW vQ FDSLWROXO DQWHULor, putem considera documentul XML ca
  • 614. Tehnologii XML194 fiind un arbore de noduri, prelucrate cu ajutorul obiectelor. O astfel de abordare este oferiW GH PRGHOXO '20 GHWDOLDW vQ VXEFDSLWROXO  • pe baza unor evenimente – un document XML poate fi privit ca o succesiune de eYHQLPHQWH GH DSDULLH D XQRU FRQVWUXFLL VSHFLILFH (început de tag FRQLQXW SURSULX-]LV VIkUüLW GH tag, comentariu etc.) FH SRW DYHD DVRFLDWH IXQFLL GH SUHOXFUDUH $FHDVW YL]LXQH H vPSUWüLW GH LQWHUIDD GH SURJUDPDUH 6$; D VH Yedea subcapitolul 3), GDU üL GH DOWH LPSOHPHQWUL • simplificat – fiecare element prezent într-un document XML poate DYHD DVRFLDW R SURSULHWDWH D XQXL RELHFW DVWIHO vQFkW SULQ SUHOXFUUL FRQYHQLRQDOH GH GDWH V VH UHDOL]H]H vQ IDSW SURFHVUL ;0/ ÍQ cadrul subcapitolului 4 vRU IL SUH]HQWDWH DVWIHO GH VROXLL • în mod particular – SULQ LQWHUPHGLXO XQRU LQWHUIHH GH SURJUDPDUH VSHFLDOL]DWH SRW IL HIHFWXDWH SURFHVUL DVXSUD XQRU FODVH GH documente particulare (e.g., RDF, RSS, SOAP sau SVG). $FWLYLWDWHD GH SURFHVDUH HVWH GHVIüXUDW GH XQ SURFHVRU parser) XML. Putem încadra un astfel de tip de analizor în doX PDUL FDWHJRULL • IU YDOLGDUH – SURFHVRUXO YHULILF GRDU GDF GRFXPHntul este bine formatat. Drept exemple se pot da procesoarele expat, libxml üL MSXML; • cu validare – procHVRUXO YHULILF GDF GRFXPHQWXO HVWH YDOLG IRORVLQG R VFKHP GH YDOLGDUH '7' ;0/ 6FKema, RELAX NG). În DFHDVW FODV LQWU DQDOL]RDUH SUecum Apache Xerces, JAXP, libxml üL MSXML. Uzual, API-urile disponibile pot fi folosite pe mai multe platIRUPH üL limEDMH $FWXDOPHQWH SUDFWLF ILHFDUH OLPEDM GH SURJUDPDUH RIHU SRVLEL- OLWDWHD UHDOL]ULL GH SURFHVUL ;0/ 2. Modelul DOM 2.1. Caracterizare Modelul obiectual pentru documente – Document Object Model (DOM) – UHSUH]LQW R LQWHUID GH SURJUDPDUH D DSOLFDLLORU GHVWLQDWH V SUHOXFUH]H GRFXPHQWHOH ;0/ üL +70/ LQGHSHnGHQW GH SODWIRUP üL GH OLPEDM GHILQLQG VWUXFWXUD ORJLF D GRFXPHQWHORU üL PRGDOLWLOH GH DFFHVDUH üL GH modificare a lor. $FHDVW VWUXFWXU HVWH XQD DUERUHVFHQW RELHFWXDO GRFXPHQWHOH VXQW mRGHODWH XWLOL]kQG RELHFWH 0RGHOXO QX RIHU GRDU R YL]XDOL]DUH VWUXFWXUDW
  • 615. 3URFHVUL ;0/ 195 D GRFXPHQWXOXL FL üL R PDQLeU GH VSHFLILFDUH D FRPSRUWDPHQWXOXL OXL üL D obiectelor componente. Fiecare element al unui document poate fi privit deci ca un obiect, fiecare obiect DYkQG LGHQWLWDWH üL SURSULLOH VDOH IXQFLRQDOLWL Similar metodologiei orientate pe obiect, DOM idenWLILF • LQWHUIHHOH üL RELHFWHOH XWLOL]DWH V UHSUH]LQWH üL V PDQLSXOH]H XQ document; • VHPDQWLFD DFHVWRU LQWHUIHH üL RELHFWH LQFOXVLY FRPSRUWDPHQWXO üL atributele lor); • UHODLLOH üL GHSHQGHQHOH vQWUH DFHVWH LQWHUIHH üL RELHcte. $VWIHO '20 UHSUH]LQW XQ PRGHO FDUH VSHFLILF LQWHUIHH üL QX GHVHPQHD] XQ VHW GH VWUXFWXUL GH GDWH ILH HOH DEVWUDFWH VDX QX
  • 616.  'H DVHPHQHD QX GHILQHüWH QLFL R VHPDQWLF SULYLtoare la XML. Fiind LQGHSHQGHQW GH OLPEDM üL GH SODWIRUP '20 SRDWH IL LPSOHPHQWDW vQ RULFH OLPEDM GH SURJUDPDUH '20 QX HVWH R VSHFLILFDUH ELQDU üL QX GHILQHüWH QLFL R IRUP GH LQWHURSerabilitate la nivel binar, în contrast cu alte tehnologii. ([LVW PDi multe niveluri de specificare: • DOM – nivelul 1 (Apparao et al., 1998) a pus bazele modelului, SUHFL]kQG H[LVWHQD XQXL QXFOHX GH IXQFLRQDOLWL DOM Core) SHQWUX UHDOL]DUHD GH SURFHVUL DVuSUD GRFXPHQWHORU ;0/ üL D XQHL H[WHQVLL GHVWLQDWH SUHOXFUULORU HTML (DOM HTML). O implementare D PRGHOXOXL WUHEXLH V DLE vQ YHGHUH LPSOHPHQWDUHD REOLJDWRULH D WXWXURU LQWHUIHHORU IXQGDPHQWDOH GHILQLWH GH DOM Core, conform semanticii DOM; • DOM – nivelul 2 extinde nivelul precedent, modularizând IXQFLRQDOLWLOH vQ FDGUXO XQRU VSHFLILFDLL PXOWiple. Recomandarea GH ED] HVWH /H +RUV et al. (2000), suplimentar oferindu-se suport pentru: – specificarea evenimentelor: DOM Events; – prelucrarea foilor de stiluri: DOM Style; – traversarea documentelor: DOM Traversal & Range; – vizXDOL]DUHD FRQLQXWXOXL DOM Views; – prelucrarea documentelor HTML: DOM HTML; • DOM – QLYHOXO  HVWH SDULDO VWDQGDUGL]DW RIHULQG PDL PXOWH IDFLOLWL üL R SDOHW PDL ODUJ GH PRGXOH VSHFLDOizate. Modulul DOM Core este detaliat în Le Hors et al. (2004). Alte LQIRUPDLL SULYLWRDUH OD '20 VXQW IXUQL]DWH GH 0DULQL 
  • 617. 
  • 618. Tehnologii XML196 ,QWHUIHHüLLPSOHPHQWUL În cadrul modelului sunt specificate LQWHUIHH care pot fi ulterior utilizate în prelucrarea documentelor XML. Aceste interIHH VXQW DEVWUDFWL]UL VLPLODUH claselRU DEVWUDFWH GH ED] GLQ OLPEDMXO & VDX LQWHUIHHORU -DYD RIHULQG R PRGDOLWDWH GH DFFHVDUH üL GH PRGLILFDUH D UHSUH]HQWULL LQWHUQH D XQXL GRFXPHQW vQ FDGUXO XQHL DSOLFDLL ,QWHUIHHOH QX LPSOLF R LPSOHPHQWDUH FRQFUHW SDUWLFXODU D IXQFLRQDOLWLORU SH FDUH OH GHILQHVF ILHFDUH DSOLFDLH '20 SXWkQG VWRFD GRFXPHQWHOH vQ RULFDUH UHSUH]HQWDUH LQWHUQ FRQYHQDELO DWkW WLPS FkW LQWHUIHHOH '20 VXQW VXSRUWDWH $VWIHO PRGHOXO HVWH FRQFHSXW V HYLWH GHSHQGHQD GH LPSOHPHQWDUH Maniera de specificare a inWHUIHHORU VH UHDOL]HD] SULQ LQWHUPHGLXO XQXL limbaj declarativ – IDL (Interface Description Language), folosit în cadrul PRGHOXOXL GH UHDOL]DUH D DSOLFDLilor distribuite CORBA (Common Object Request Broker Architecture
  • 619.  $FHVW OLPEDM GHILQHüWH WLSXULOH de obiecte prin specificarea interIHHORU DFHVWRUD GDWH-PHPEUX üL PHWRGH SXEOLFH
  • 620.  RIHULQG VXSRUW SHQWUX PRüWHQLUHD PXOWLSO SULQ LnWHUPHGLXO LQWHUIHHORU üL SXQkQG OD GLVSR]LLH FRQVWUXFLL VLQWDFWLFH PHQLWH D GHVFULH PRGXOH LQWHUIHH metode, tipuri de GDWH DWULEXWH H[FHSLL üL FRQVWDQWH 'HWDOLL SULYLQG VLQWD[D üL VHPDQWLFD ,'/ VXQW GLVSRQLELOH vQ 20* Tipurile de date IDL sunt grupate în tipuri scalare (întregi: short, ushort, long, ulong; reale: float üL double; altele: char, string, octal, boolean, enum), compuse (struct, sequence, union, any
  • 621. üL UHIHULQH OD RELHFW 8Q H[HPSOX GH VSHFLILFDLH ,'/ SULYLWRDUH OD GHFODUDUHD XQHL LQWHUIHH – QXPLW NodeList – DYkQG R PHWRG üL XQ DWULEXW SURSULHWDWH
  • 622.  HVWH XUPWRUXO interface NodeList { // metod DYkQG XQ DUJXPHQW GH LQWUDUH Node item (in unsigned long index); // atribut folosit doar pentru consultare readonly attribute unsigned long length; }; ([HPSOLILFDUHD FH XUPHD] LOXVWUHD] PDQLHUD GH VSHFLIiFDUH D PRüWHQLULL LQWHUIDD Attr provine din Node, iar tipul DOMString e definit în cadrul DOM Core üL GHVHPQHD] XQ üLU GH FDUDFWHUH
  • 623.  interface Attr : Node {   SURSULHWL DWULEXWH
  • 624.  XOWLPD SXWkQG IL PoGLILFDW readonly attribute DOMString name; readonly attribute boolean specified; attribute DOMString value; };
  • 625. 3URFHVUL ;0/ 197 )XQFLRQDOLWLGHED] DOM Core 1XFOHXO PRGHOXOXL GHILQHüWH PXOLPHD PLQLPDO IXQGDPHQWDO D LQWHUIHHORU SHQWUX DFFHVDUHD üL PRGLILFDUHD FRQLQXWXOXL RELHFWHORU-nod ale unui document. Structura DOM reprezinW GRFXPHQWHOH FD SH R LHUDUKLH GH obiecte-nod care, la rândul ORU SRW LPSOHPHQWD DOWH LQWHUIHH HYHQWXDO PDL VSHFLDOL]DWH $QXPLWH WLSXUL de noduri pot avea noduri-FRSLO GHVFHQGHQL
  • 626. GH GLYHUVH WLSXUL $OWHOH SRW fi noduri-IUXQ] OLSVLWH GH GHVFHQGHQi. Accesul la date – liste de noduri, atriEXWH YDORUL üL DOWHOH – VH UHDOL]HD] YLD PHWRGHOH SXVH OD GLVSR]LLH GH obiectele-nod. Tipurile fundamentale ale nodurilor DOM sunt prezentate în tabelul 1. 7DEHOXO  7LSXULOH GH QRGXUL üL GHVFHQGHQLL DFHVWRUa Tip 'HVFHQGHQL Document Element, ProcessingInstruction, Comment, DocumentType DocumentFragment Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference DocumentType - EntityReference Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference Element Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference Attr Text, EntityReference ProcessingInstruction - Comment - Text - CDATASection - Notation - Entity Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference ,QWHUIHHIXQGDPHQWDOH ,QWHUIHHOH GHQXPLWH fundamentale trebuie implementate obligatoriu, conform VSHFLILFDLLORU '20 /H YRP SUH]HQWD SH FHOH PDL LPSRUWDQWH vQ FRntinuare.
  • 627. Tehnologii XML198 ,QWHUIDD DOMException GHILQHüWH PHFDQLVPXO GH UVSXQV OD DSDULLD H[FHSLLORU ([FHSLLOH DSDU vQ FLUFXPVWDQH VSHFLDOH GH H[HPSOX FkQG R RSHUDLXQH HVWH LPSRVLELO GH H[HFXWDW SLHUGHUH GH GDWH LPSOHPHQWDUH GHYHQLW LQVWDELO HWF
  • 628.  $QXPLWH OLPEDMH GH SURJUDPDUH SUHFXP & VDX 3+3 QX DX LPSOHPHQWDW FRQFHSWXO GH H[FHSLH 3HQWUX LPSOHPHQWULOH '20 vQ DVWIHO GH OLPEDMH UDSRUWDUHD H[FHSLLORU VH YD UHDOL]D IRORVLQG mecanismele native de semnalare a erorilor. 'HILQLLD FRQIRUP VWDQGDUGXOXL ,'/ HVWH XUPWRDUHD exception DOMException { unsigned short code; }; &RGXULOH GH H[FHSLH VXQW Qumere întregi indicând ce tip de eroare a DSUXW 3RW IL IRORVLWH R VHULH GH FRQVWDQWH SUHGHILQLWH GLQWUH FDUH FHOH PDL importante sunt sintetizate în tabelul 2. 7DEHOXO  &RQVWDQWHOH SULYLWRDUH OD H[FHSLLOH FH SRW VXUYHQL Constante predefinite SemnificDLH INDEX_SIZE_ERR Valoare de index incorecW DOMSTRING_SIZE_ERR /XQJLPH LQYDOLG D XQXL üLU GH FDUDFWHUH HIERARCHY_REQUEST_ERR ,QVHUDUH LQFRUHFW D XQXL QRG WRONG_DOCUMENT_ERR Utilizare de noduri într-un alt document, diferit de cel la care aparineau INVALID_CHARACTER_ERR $SDULLD XQXL FDUDFWHU LQYDOLG GH H[HP- SOX vQ FRPSRQHQD XQXL QXPH GH marcator) NOT_FOUND_ERR ÍQFHUFDUH GH FUHDUH D XQHL UHIHULQH D unui nod într-un context eronat NOT_SUPPORTED_ERR ,PSOHPHQWDUHD QX VXSRUW Iacilitatea FHUXW GH DSOLFDLH SYNTAX_ERR (URDUH GH VLQWD[ FRQVWDQW GLVSRQLELO în DOM nivelul 2) NAMESPACE_ERR 6SDLX GH QXPH LQFRUHFW FRQVWDQW GLVSRQLELO vQ '20 QLYHOXO 
  • 629. VALIDATION_ERR ([FHSLH SULYLWRDUH OD YDOidare (constan- W GLVSoQLELO vQ '20 QLYHlul 3) TYPE_MISMATCH_ERR 1HSRWULYLUH GH WLSXUL GH GDWH FRQVWDQW disponiELO vQ '20 QLYHOXO 
  • 630. ,QWHUIDD DOMImplementation RIHU PHWRGH SHQWUX H[HFXWDUHD RSHUDLilor vQ PDQLHU LQGHSHQGHQW GH RULFH LQVWDQ SDUWLFXODU D XQXL Gocument.
  • 631. 3URFHVUL ;0/ 199 În fapt, niveluO  QX VSHFLILF YUHR PRGDOLWDWH GH FUHDUH D XQHL LQVWDQH GRFXPHQW OVkQG LPSOHPHQWDWRULORU DFHDVW UHVSRQVabilitate. DOM nivelul 2 SXQH OD GLVSR]LLH R PHWRG SHQWUX FUHDUHD XQXL WLS GH GRFXPHQW YLD '7' üL DOWD SHQWUX FUHDUHD XQXL GRFXPHQW SUHFL]kQGX-sH üL VSDLXO VX GH QXPH '20 QLYHOXO  RIHU vQ SOXV üL SRVLELOLWDWHD FRQVXOWULL YLD DOMImplementationList D XQHL OLVWH GH LPSOHPHQWUL SRVLELOH VXUVHOH DFHVWRUD ILLQG VSHFLILFDWH GH LQWHUIDD DOMImplementationSource. 2 DOW LQWHUID IXQGDPHQWDO HVWH DocumentFragment, care poate reprezinta un obiect-GRFXPHQW PLQLPDO ÍQ PXOWH VLWXDLL QX WUHEXLH OXFUDW cu întregul document, ci doar cu diverse fragmente ale sale. Arborele de noduri ale unui fragment de document este un subarbore al structurii de noduri a doFXPHQWXOXL OXDW vQ vQWUHJXO OXL ÍQ IXQFLH GH QHFHVLWL DocumentFragment poate reprezenta o entitate XML, un element XML sau chiar un grup de elemente: interface DocumentFragment : Node { }; 'XS FXP VH UHPDUF DocumentFragment DUH FD LQWHUID GH ED] LQWHUIDD Node, pe care o vom prezenta mai jos. ,QWHUIDD Document UHSUH]LQW XQ GRFXPHQW ;0/ FRQFHSWual desemnând UGFLQD DUERUHOXL GH QRGXUL-obiecte ale docuPHQWXOXL üL RIHULQG DFFHVXO OD LQIRUPDLLOH FRQLQXWH GH DFHVWD 'LQ PRPHQW FH HOHPHQWHOH (marcatorii), QRGXULOH GH WLS WH[W FRPHQWDULLOH LQVWUXFLXQLOH GH SURFHVDUH QX SRW H[Lsta vQ DIDUD FRQWH[WXOXL XQXL GRFXPHQW LQWHUIDD Document FRQLQH GH asemenea metodele necesare pentru a crea aceste obiecte. Obiectele de tip Node LQVWDQLDWH YRU DYea un atribut numit ownerDocument, care le va asocia doFXPHQWXO vQ DO FUXL FRQWH[W DX IRVW FUHDWH ,QWHUIDD Document are ca membri trei atribute: 1. doctype, de tip DocumentType, UHSUH]LQW GHFODUDLD WLSXOXL GH GRFXPHQW '7'
  • 632. DVRFLDW XQXL GRFXPHQW SDUWLFular. În DOM nivelul 1, acest atribut este declarat read-only, deci nu poate fi alterat. 2. implementation, de tip DOMImplementation, VSHFLILF LPSOHPHQWDUHD VDX LPSOHPHQWULOH GLVSRQLELOH SHQWUX SURFHVarea documentului. 3. documentElement, de tip Element, desemnHD] QRGXO-UGFLQ GH accesare a structurii arborescente a documentului. 'UHSW PHWRGH LPSRUWDQWH PHQLRQP • createElement() FUHHD] XQ HOHPHQW ;0/ • createElementNS() FUHHD] XQ HOHPHQW ;0/ DSDULQkQG XQXL VSDLX GH QXPH PHWRG GLVSRQLELO vQ '20 QLYHOXO 2 sau superior);
  • 633. Tehnologii XML200 • createTextNode(), createComment(), createCDATASection(), createProcessingInstruction() vor genera noduri-obiect de tip WH[W FRPHQWDULX VHFLXQH &'$7$ LQVWUXFLXQH GH SURFHVDUH respectiv; • createAttribute() FUHHD] XQ RELHFW DWULEXW FDUH va fi asociat unui element specificat; • createAttributeNS() DUH DFHODüL URO FD PDL VXV GDU RIHU Vuport SHQWUX VSDLLOH GH QXPH • getElementsByTagName() YD UHWXUQD R OLVW RUGRQDW GH Qoduri NodeList SHQWUX WRDWH HOHPHQWHOH FRUHVSXQ]WRDUH XQXL tag, ordonarea nodurilor realizându-se prin parcurgerea în preordine a arborelui; • getElementsByTagNameNS() MRDF DFHODüL URO FD PDL VXV vQV WUHEXLH VSHFLILFDW üL XQ VSDLX GH Qume; • importNode() LPSRUW XQ QRG SURYHQLQG GLQ DOW GRFXPHQW PHWRG LQWURGXV GH '20 QLYelul 2); • renameNode() SHUPLWH UHGHQXPLUHD XQXL QRG PHWRG GLVSRQLELO în DOM nivelul 3). ,QWHUIDD Node GHILQHüWH XQ WLS SULPDU SHQWUX vQWUHJXO PRGHO '20 reprezentând un anumit nod în cadrul arborelui asociat unui document. Atributele nodeName, nodeValue üL attributes sunt introduse ca PHFDQLVP SHQWUX IXUQL]DUHD LQIRUPDLLORU GHVSUH QRGXUL IU FRQYHUVLH GH tipuri (vi]XDOL]DUH ÅVLPSOLILFDWµ QX XQD ÅRULHQWDW SH RELHFWµ
  • 634.  )LHFDUH QRG YD DYHD DVRFLDW R OLVW RUGRQDW FRQLQkQG GHVFHQGHQLL VL SOXV DWULbute specificând nodul-SULQWH SULPXO üL XOWLPXO QRG-copil, daF H[LVW &D PHWRGH SUH]HQWkQG LQWHUHV VH SRW PHQLRQD FHOH FDUH PDQLSXOHD] nodurile-copil: • insertBefore()permite inserarea unui nod înaintea celui curent; • replaceChild()substituie un nod-copil; • removeChild()HOLPLQ XQ QRG-copil specificat; • appendChild()DGDXJ XQ DOW QRG-copil; • cloneChild()FORQHD] XQ DQXPLW QRG-copil; • hasChildNodes()întoarce true GDF H[LVW Qoduri-copil; • hasAttributes()întoarce true GDF QRGXO DUH DWULEXWH PHWoG introduV vQ '20 QLYHOXO 
  • 635.  • isSameNode()întoarce true GDF QRGXO FXUHQW H LGHQWLF FX XQ Dltul VSHFLILFDW PHWRG RIHULW GH '20 QLYHOXO 
  • 636.  ,QWHUIDD NodeList UHSUH]LQW R LQWHUID FDUH RIHU XQ WLS DEVWUDFW GH GaW SHQWUX FROHFLLOH RUGRQDWH GH QRGXUL IU D GHILQL VDX UHVWULFLRQD FXP YD IL LPSOHPHQWDW HIHFWLY DFHDVW FROHFLH )LHFDUH LPSOHPHQWDWRU YD GHFLGH FH WLSXUL GH GDWH FRQFUHWH YRU IL XWLOL]DWH 0HPEULL FROHFLHL VH YRU DFFHVD SULQ
  • 637. 3URFHVUL ;0/ 201 intermediul unui index întreg, numerotarea începând cu valoarea 0. DeILQLLD ,'/ D DFHVWHL LQWHUIHH D IRVW IXUQL]DW PDL VXV ,QWHUIDD NamedNodeMap HVWH IRORVLW SHQWUX UHSUH]HQWDUHD DEVWUDFW D FROHFLLORU QHRUGRQDWH GH QRGXUL SUHOXFUDWH SULQ LQWHUPHGLXO QXPHOXL ,QWHUIDD NamedNodeMap QX GHULY GLQ NodeList 'HFODUDLD IDL este: interface NamedNodeMap { Node getNamedItem(in DOMString name); Node setNamedItem (in Node arg) raises(DOMException); Node removeNamedItem (in DOMString name) raises(DOMException); Node item (in unsigned long index); readonly attribute unsigned long length; // Introduse în DOM nivelul 2: Node getNamedItemNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); Node setNamedItemNS(in Node arg) raises(DOMException); Node removeNamedItemNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); }; CharacterData estH R LQWHUID FDUH H[WLQGH Node FX XQ VHW GH DWULEXWH üL metode pentru accesarea datelor de tip caracter în cadrul DOM. ,QWHUIDD Attr UHSUH]LQW XQ DWULEXW GLQ FDGUXO XQXL RELHFW GH WLS Element. În mod tipic, valorile permise ale atributelor sunt definite în DTD-ul sau VFKHPD ;0/ FRUHVSXQ]WRDUH GRFXPHQWXOXL 8Q RELHFW Attr QX VH FRQVLGHU F DSDULQH Drborelui de noduri-obiect al documentului. Nodurile de tip Attr VXQW Y]XWH FD SURSULHWL DOH HOHPHQWHORU PDUFDWRULORU
  • 638.  SXWkQG IL asociate nodurilor Element FRQLQXWH GH RELHFWH GH WLS DocumentFragment. 'HILQLLD ,'/ D LQWHUIHHL HVWH XrPWRDUHD interface Attr : Node { readonly attribute DOMString name; // numele readonly attribute boolean specified  GDF H VSHFLILFDW attribute DOMString value; // valoarea // Introduse de DOM nivelul 2: readonly attribute Element ownerElement; // proprietarul // Introduse de DOM nivelul 3: readonly attribute TypeInfo schemaTypeInfo; // tip de date readonly attribute boolean isId; // de tip 'ID' };
  • 639. Tehnologii XML202 ,QWHUIDD Element GHULY GLQ Node üL RIHU PHWRGH GH DFFHVDUH D RELHFWelor Attr, prin nume sau prin valoare: getAttribute(), setAttribute(), removeAttribute(), getAttributeNode(), setAttributeNode(), removeAttributeNode(). Variantele priYLWRDUH OD SUHFL]DUHD VSDLLORU GH nume sunt disponibile începând cu DOM nivelul 2. ,QWHUIDD Text este o LQWHUID UHSUH]HQWkQG FRQLQXWXO WH[Wual (date de tip üLUXUL GH FDUDFWHUH
  • 640. DO XQXL QRG Element sau Attr 'DF vQWUH tag-urile de vQFHSXW üL GH VIkUüLW QX H[LVW DOWH tag-XUL WH[WXO YD IL FRQLQXW vQWU-un obiect LPSOHPHQWkQG LQWHUIDD Text. DOM nivelul 3 SXQH OD GLVSR]LLH PHWRGD replaceWholeText() FDUH vQORFXLHüWH FRQLQXWXO WH[WXDO DO QRGXOXL FXUHQW üL DO WXWXURU QRGXULORU-WH[W DGLDFHQWH GLQ SXQFW GH YHGHUH ORJLF DGLF DFHOH QRGXUL FDUH SRW IL YL]LWDWH VHFYHQLDO IU D DFFHVD vQ YUHXQ PRG Qoduri de tip Element, Comment sau ProcessingInstruction). ,QWHUIDD TypeInfo HVWH LQWURGXV GH '20 QLYHOXO  üL VSHFLILF LQIRUPDLLOH SULYLWRDUH OD WLSXO GH GDWH DO FRQLQXWXOXL XQXL HOHPHQWDWULEXW conform schemei de validare asociate: interface TypeInfo { readonly attribute DOMString typeName; readonly attribute DOMString typeNamespace; boolean isDerivedFrom (in DOMString typeNamespaceArg, in DOMString typeNameArg, in unsigned long derivationMethod); }; ,QWHUIHHH[WLQVH 6SHFLILFDLLOH '20 LQWURGXF üL R VHULH GH LQWHUIHH H[WLQVH 'H H[HPSOX VXQW RIHULWH LQWHUIHH UHIHULWRDUH OD DOWH FRQVWUXFLL ;0/ VHFLXQL &'$7$ UHIHULQH OD HQWLWL LQVWUXFLXQL GH SURFHVDUH WLSXO GRFXPHQWului etc. (detalii sunt furnizate în Le Hors et al., 2004). 2.4. Extensii oferite de DOM nivelul 2 1LYHOXO DO GRLOHD DO PRGHOXOXL GH ED] GHILQHüWH H[WHQVLL DOH LQWHUIHHORU QLYHOXOXL  RIHULQG IXQFLRQDOLWL QRL FD SRVLELOLWDWHD GH D FUHD XQ RELHFW Document sau de a copia un nod dintr-un document într-altul. De DVHPHQHD H[LVW PRGXOH VXSOLPHQWDUH SHQWUX FRQWUROXO IRLORU GH VWLOXUL &66  üL &66 
  • 641.  WUDWDUHD HYHQLPHQWHORU üL VSHFLILFDUHD ILOWUHORU üL LWHUDWRULORU (parcurgeri sofisticate de arbori DOM).
  • 642. 3URFHVUL ;0/ 203 Manipularea foilor de stiluri '20 QLYHOXO  GHILQHüWH XQ VHW GH LQWHUIHH GH ED] XWLOL]DWH V UHSUH]LQWH foi de stiluri. ,QWHUIDD StyleSheet HVWH R LQWHUID DEVWUDFW UHSUH]HQWkQG R IRDLH GH VWLOXUL XQLF H[WHUQ DVRFLDW XQXL GRFXPHQW VWUXFWXUDW YLD R LQVWUXFLXQH de procesare. ,QWHUIDD StyleSheetList RIHU R FROHFLH RUGRQDW DEVWUDFW GH IRL GH stiluri, iar MediaList UHSUH]LQW R DEVWUDFWL]DUH D XQHL FROHFLL RUGRQDWH GH WLSXUL GH PHGLL FXP DU IL WH[W DXGLR VDX YLGHR
  • 643.  IU D FRQVWUkQJH implementarea acesteia. De asemeQHD VH SXQH OD GLVSR]LLH LQWHUIDD DocumentStyle, FDUH VSHFLILF XQ PHFDQLVP GH DFFHVDUH D IRLORU GH VWLOXUL asociate unui document (pentru detalii, vezi Wilson et al., 2000). Suportul pentru evenimente Scopurile modulului DOM Events 3L[OH 
  • 644. VXQW XUPWRarele: • SURLHFWDUHD XQXL VLVWHP JHQHULF GH HYHQLPHQWH FDUH V SHUPLW GHILQLUHD DFWLYLWLORU FH YRU IL H[HFXWDWH OD DSDULLD XQXL HYHQLPHQW descrierea fluxului de evenimente printr-R VWUXFWXU DUERUHVFHQW üL oferirea unor informaLL FRQWH[WXDOH SHQWUX ILHFDUH HYHQLPHQW vQ parte. În plus, se concepere un set standard de evenimente pentru FRQWUROXO LQWHUIHHL FX XWLOL]DWRUXO üL QRWLILFDUHD PRGLILFULORU GH VWUXFWXU
  • 645. DOH GRFXPHQWelor; • oferirea unui subset comun al evenimentelor utilizate de naviga- toarele actuale. '20 VXSRUW PDL PXOWH SURFHGXUL GH GHWHFWDUH D HYHQLPHntelor asociate XQXL QRG üL SXQH OD GLVSR]LLH XQ PHFDQLVP GH UHFHSLRQDUH D HYHQLPHQWHORU vQDLQWH üL GXS FH R LPSOHPHQWDUH '20 D SURFHVDW XQ HYHQLPHQW 6H deILQHüWH GH DVHPHQHD XQ PHFDQLVP SURJUDPDELO GH VSHFLILFDUH D Podului GH GHWHFWDUH D HYHQLPHQWHORU GH VLVWHP üL SUHFL]DWH GH XWLOL]DWRU
  • 646.  0RGHOXO IXUQL]HD] UHJXOL GH LQWHUDFLXQH D HYHQLPHQWHORU VSHFLILFDWH ILH OD QLYHOXO marcatorilor, fie prin stiluri sau prin intermediul scripturilor. ÍQ SOXV WUHEXLH V VH SHUPLW FUHDUHD XQRU PXOLPL GH HYHQLPHQWH GLIHULWH GH FHOH VSHFLILFDWH vQ FDGUXO '20 0RGHOXO RIHU VXSRUW SHQWUX eveniPHQWH DOH LQWHUIHHL FX XWLOL]DWRUXO üL SHQWUX GHILQLUHD XQXL VHW GH evenimente privind modiILFDUHD GH VWUXFWXU VDX GH VWLO D XQXL GRFXPHQW DOM Events VSHFLILF XUPWRDUHOH WLSXUL GH HYHQLPHQWH • HYHQLPHQWH WULPLVH GH LQWHUIDD FX XWLOL]DWRUXO QDYLJator Web): click, mousedown, mouseup, mouseover, mousemove, mouseout, keypress, keydown, keyup, resize, scroll;
  • 647. Tehnologii XML204 • evenimente de modificare a structurii documentului: subtree- Modified, nodeInserted, nodeRemoved, attrModified etc.; • HYHQLPHQWH +70/ GHILQLWH GH VSHFLILFDLLOH +70/
  • 648.  load, unload, abort, error, select, submit, focus, blur üL altele. 6XQW LQWURGXVH LQWHUIHHOH • EventTarget – GHVHPQHD] LQWD VSUH FDUH YD IL UHGLUHFWDW HYHQLPHQWXO • EventListener – UHSUH]LQW PHFDQLVPXO SULPDU GH PDQLSXODUH D HYHQLPHQWHORU DYkQG DVRFLDW R PHWRG GH WUDWare a evenimentului survenit; • Event – esWH R LQWHUID XWLOL]DW V RIHUH LQIRUPDLL FRQWHxtuale pentru XQ HYHQLPHQW LQIRUPDLL IRORVLWH GH R SUoFHGXU GH WUDWDUH D DFHOXL eveniment. Tratarea se poate realiza „în jos” (un anume element va WUDWD HYHQLPHQWHOH SURYHQLWH GH OD FRSLLL VL
  • 649. VDX ÅvQ Vus” (eveni- mentul va fi propagat spre nodurile aflate pe nivelurile superioare, HYHQWXDO SkQ OD UGFLQ
  • 650.  ([LVW LQWHUIHH GHUivate din aceasta: UIEvent (desemQHD] HYHQLPHQWHOH GH LQWHUID-utilizator), Mouse- Event VSHFLILF HYHQLPHQWHOH FDX]DWH GH PRXVH
  • 651. üL MutationEvent GHVHPQHD] HYeQLPHQWHOH SULYLWRDUH OD PRGLILFULOH GH VWUXFWXU XML). )LOWUHüLLWHUDWRUL Modulul DOM Traversal & Range (Kesselman et al., 2000) pune la dispoziLH LQWHUIHHOH Iterator, Filter üL TreeWalker, care permit parcurgerea VLPSO üL HILFLHQW D VXEDUERULORU OLVWHORU GH QoGXUL VDX UH]XOWDWHORU LQWHURJULORU efectuate asupra documentelor. Un iterator permite ca nodurile dintr-R VWUXFWXU GH GDWH V ILH UHWXUQDWH vQ PRG VHFYHQLDO 'XS FUHDUHD XQXL LWHUDWRU SULPD DSHODUH D metodei nextNode() YD UHWXUQD SULPXO QRG 'DF QX H[LVW QRGXUL UH]XOWDWXO YD IL null 8Q LWHUDWRU SRDWH IL DFWLY üL FkQG R VWUXFWXU GH GDWH HVWH HGLWDW GLQDPLF
  • 652.  ûWHUJHULOH üL DGXJULOH GH GDWH QX YRU LQYDOLGD LWHUDWRULL QLFLRGDW Iteratorii se creHD] SULQ PHWRGD createNodeIterator(). Nodurile de WLS LWHUDWRU YRU IL DFFHVDWH SULQ LQWHUPHGLXO LQWHUIHHL NodeIterator, SUH]HQWDW în continuare: interface NodeIterator { readonly attribute Node root; readonly attribute unsigned long whatToShow; readonly attribute NodeFilter filter; readonly attribute boolean expandEntityReferences;
  • 653. 3URFHVUL ;0/ 205 Node nextNode() raises(DOMException); Node previousNode() raises(DOMException); void detach(); }; Atributul whatToShow VWDELOHüWH WLSXO GH QRGXri care vor fi returnate de iterator: toate nodurile (SHOW_ALL), elementele (SHOW_ELEMENT), texte (SHOW_TEXT), noduri-document (SHOW_DOCUMENT) etc. 8Q ILOWUX FRQLQH R IXQFLH VFULV GH XWLOL]DWRU FDUH GHWHUPLQ FD XQ QRG V ILH ILOWUDW GLVSRQLELO
  • 654. VDX QX. Un filtru este utilizat de un iterator care DSOLF ILOWUXO ILHFUXL QRG 'DF ILOWUXO UHVSLQJH QRGXO LWHUDWRUXO vO LJQRU WUHFkQG OD XUPWRUXO QRG disponibil. Filtrele sunt facil de conceput din moment ce nu este necesar a VH FXQRDüWH VWUXFWXUD GH GDWH DVXSUD FURUD YRU RSHUD )LOWUHOH SRW IL UHIRORVLWH FX VXFFHV üL vQ Fadrul altor iteratori. interface NodeFilter { // Constante returnate de acceptNode() const short FILTER_ACCEPT = 1; const short FILTER_REJECT = 2; const short FILTER_SKIP = 3; short acceptNode (in Node n); }; &RPSOHPHQWDU LQWHUIHHL Iterator, TreeWalker RIHU R SUH]HQWDUH DUERUHVFHQW D QRGXULORU GLQWU-un subarbore. Navigarea prin nodurile unui doFXPHQW IRORVLQG PHWRGD LQWHUIHHL TreeWalker poate utiliza filtre. 'HILQLLD ,'/ HVWH IXUQL]DW vQ FRQWLQXDUH interface TreeWalker { readonly attribute Node root; readonly attribute unsigned long whatToShow; readonly attribute NodeFilter filter; readonly attribute boolean expandEntityReferences; attribute Node currentNode; Node parentNode(); // nodul-SULQWH Node firstChild(); // primul copil Node lastChild(); // ultimul copil Node previousSibling(); // precedentul frate 1RGH QH[W6LEOLQJ
  • 655.   XUPWRUXO IUDte
  • 656. Tehnologii XML206 Node previousNode(); // precedentul nod 1RGH QH[W1RGH
  • 657.   XUPWRUXO QRG }; 2.5. Extensii oferite de DOM nivelul 3 Pentru nivelul 3, DOM Core SXQH OD GLVSR]LLH QRL WLSXUL GH Gate: DOMTimeStamp QXPU GH PLOLVHFXQGH
  • 658.  DOMUserData (date ale DSOLFDLHL-utilizator), DOMObject UHIHULQ OD XQ REiHFW
  • 659.  &D üL OD '20 QLYHOXO  VH RIHU VXSRUW SHQWUX VSDLLOH GH QXPH – atributele folosite SHQWUX GHFODUDUHD VSDLLORU GH QXPH SULQ GHILQLLH DSDULQ 85,-ului http://www.w3.org/2000/xmlns/. Sunt intrRGXVH LQWHUIHH QRL R SDUWH SUH]HQWDWH PDL VXV
  • 660. üL VXQW H[WLQVH FHOH H[LVWHQWH 'H DVHPHQHD VXQW SURSXVH PRGXOH VXSOLPHQWDUH GHSHQGHQHOH GLQWUH ele fiind ilustrate în figura 1. Figura 1. Modulele specificate de DOM – nivelul 3 (Le Hors et al., 2004) Deja standardizate sunt modulele: • DOM Load & Save 6WHQEDFN üL +HQLQJHU 
  • 661. – RIHU IXQFLR- QDOLWL SHQWUX vQFUFDUHD üL VDOYDUHD vQ PDQLHU VLQFURQ VDX DVLQFURQ D DUERULORU '20 VH SHUPLW üL DQXPLWH ILOWUUL OD PRPHQWXO vQFUFULLVDOYULL
  • 662. 3URFHVUL ;0/ 207 • DOM Validate (Chang et al., 2004) – SXQH OD GLVSR]LLH XQ VHW GH LQWHUIHH SULYLWRDUH OD DFWXDOL]DUHD GLQDPLF D FRQLQXWXOXL üL VWUXFWXULL GRFXPHQWHORU FX DVLJXUDUHD YDOLGLWLL DFHVWRUD DFHVWH IDFLOLWL VXQW IRORVLWRDUH PDL DOHV vQ FD]XO GH]YROWULL GH instrumente pentru creaUHDYDOLGDUHD DXWRPDW
  • 663. D GRFXPHQWHORU XML conformându-se unor scheme de validare; ,PSOHPHQWUL 0DMRULWDWHD SURFHVRDUHORU ;0/ VXQW FDSDELOH V UHDOL]H]H SUHOXFUUL GH documente conform modelului DOM. Nivelul 1 este complet implementat, ceOH PDL PXOWH DQDOL]RDUH RIHULQG VXSRUW üL SHQWUX '20 &RUH QLYHOXO  9RP HQXPHUD R SDUWH GLQWUH ELEOLRWHFLOH üL LQWHUIHHOH GH SURJUDPDUH disponibile în diverse limbaje: • domxml – extensie PHP 4 pentru manipularea arborilor DOM; PHP 5 RIHU R LPSOHPHQWDUH '20 QDWLY GLVSRQLELO GLUHFW vQ OLmbaj; • JAXP (Java API for XML Parsing) – SDUWH LQWHJUDQW D PHGLXOXL -6( RIHULQG R LQWHUID DEVWUDFW GH SURFesare a documentelor XML prin mai multe metode, folosind diverse procesoare; • JDOM – LQWHUID GH SURJUDPDUH VSHFLDO FRQVWUXLW SHntru Java; • JSXML – ELEOLRWHF GH SURFHVDUH ;0/ SHQWUX OLPEDMXO -DYD6FULSW • libxml – ELEOLRWHF GH SURFHVDUH RIHULW GH PHGLXO JUDILF *120( LPSOHPHQWDUHD RULJLQDO ILLQG VFULV vQ OLPEajul C, dar aflându-se la baza unor API-uri pentru C++, Perl, PHP sau Python; suportul SHQWUX WUDQVIRUPUL ;6/7 H RIHULW GH ELEOLRWHFD DGLLRQDO libxslt; de DVHPHQHD RIHU SRVLELOLWL GH YDOLGDUH YLD '7' ;0/ 6FKHPD üL RELAX NG; • MSDOM – parte din MSXML SDK (Microsoft XML Software Development Kit), RIHU SURFHVUL ;0/ SH SDUWHD GH FOLHQWVHUYHU vQ & & -6FULSW üL 9%6FULSW ILLQG XWLOL]DW GH :LQGRZV GH QDYLJDWRUXO ,QWHUQHW ([SORUHU üL GH VHUYHUXO GH DSOLFDLL $63 GH asemenea, sunt oferite o serie de extensii utile (detalii în Buraga, 2001); impOHPHQWDUHD 06'20 HVWH IRORVLW üL GH 'HOSKL DPQXQWH fiind furnizate de Wood, 2001); • QDOM – FRPSRQHQW D $3,-XOXL 7ULOOLDQ 4W GLVSRQLELO vQ & üL UHSUH]HQWkQG XQD GLQWUH FUPL]LOH SH FDUH VH ULGLF PHGLXO .'( • XDK – VXLW GH $3,-uri oferite de Oracle pHQWUX SURFHVDUHD üL validarea documentelor XML în limbaje precum C, C++, Java ori PL/SQL;
  • 664. Tehnologii XML208 • Xerces DOM API – UHSUH]LQW SODWIRUPD ;0/ SHQWUX & üL -DYD SXV OD GLVSR]LLH GH $SDFKH • XmlDocument – FODV GLVSRQLELO vQ .NET Framework, putând fi IRORVLW GH RUice limbaj .NET (C#, J#, VB.NET etc.); • XML() – disponibil în ActionScript, în cadrul mediului Flash DPQXQWH vQ 9kUODQ  üL %XUDJD 
  • 665.  • XML::DOM – modul Perl pentru DOM, bazat pe procesorul Expat; • xml.dom – modul Python, parte a PyXML. Activitatea GH SURFHVDUH HVWH UH]XPDW vQ ILJXUD  Figura 2. Maniera de procesare prin DOM a unui document XML Prelucrarea via DOM a documentelor XML se poate realiza direct în cadrul navigatorului Web, folosind limbajul de scripting suportat: ECMAScript (standard), JavaScript (în Mozilla, Firefox sau Opera), JScript/VBScript (pentru InterQHW ([SORUHU
  • 666.  6H UHFXUJH OD XQ SURFHVRU IU validare (e.g., expat
  • 667.  'XS FXP YRP YHGHD vQ FDSLWROXO XUPWRU VH RIHU VXSRUW SHQWUX SURFHVDUHD DVLQFURQ D LQIRUPDLLORU ;0/ FRnform AJAX. 0R]LOOD SXQH OD GLVSR]LLH üL FRPSRQHQWD DOM Inspector XWLO SHQWUX LQVSHFWDUHD ORFDO D DUERUHOXL '20 DVRFLDW XQXL Gocument Web – vezi figura 3.
  • 668. 3URFHVUL ;0/ 209 Figura 3. Componenta DOM Inspector 2.7. Exemple ÍQ FDGUXO DFHVWHL VHFLXQL YRP SUH]HQWD GLYHUVH H[HPSOLILFUL SULYLWRDUH OD SURFHVDUHD GDWHORU ;0/ OD JHQHUDUHD GH FRQLQXW ;0/ üL GHVLJXU OD WUDQVIRUPDUHD üL YDOLGDUHD GRFXPHQWHORU ;0/ Procesarea documentelor XML 3DUFXUJHUHDüLPRGLILFDUHDXQXLGRFXPHQW;0/IRORVLQG& Pentru început, vom scrie un program C# utilizat la parcurgerea unui GRFXPHQW ;0/ vQ FD]XO QRVWUX FRQLQkQG GDWHOH SULYLWRDUH OD SURLHFWHOH propuse spre implementare la un anumit obiect (vezi cele descrise în FDSLWROXO 
  • 669.  8UPULP V DILüP OD FRQVRO LQIRUPDLL SULYLWRDUH OD ILHFDUH
  • 670. Tehnologii XML210 SURLHFW vQ SDUWH 3HQWUX SURLHFWHOH FDUH QX DX SUHFL]DW QLFL R YDORDUH SHQWUX atributul class, vom insera valoarea „D”. using System; using System.IO; using System.Xml; namespace csbXMLTools { class DOMProcessor { // clasa de procesare via DOM private static XmlDocument doc; public static void Main() { try {  LQVWDQLHP XQ GRFXPHQW ;0/ VSUH D IL vnFUFDW doc = new XmlDocument(); doc.Load("projects.xml");  DGXJP R IXQFLH GH WUDWDUH D HYHQLPHQWului // de inserare a unui nod in arborele DOM doc.NodeInserted += new XmlNodeChangedEventHandler(NodeInsertedHandler);  DILúP LQIRUPDLL JHQHUDOH GHVSUH GRFument XmlElement root = doc.DocumentElement; &RQVROH:ULWH/LQH 6SDLXO GH QXPH DUH 85,-ul {0}.", root.NamespaceURI); &RQVROH:ULWH/LQH (OHPHQWXO UGFLQ HVWH ^`! root.Name);  DILúP LQIRUPDLL SULYLWRDUH OD SURLHFWH XmlNodeList projs = doc.GetElementsByTagName("project"); foreach(XmlElement proj in projs) {  VHOHFWP YLD ;3DWK QRGXULOH WLWOH! XmlNodeList titles = proj.SelectNodes("./title"); foreach (XmlElement title in titles) { Console.Write("Proiect: {0} ", title.InnerXml); }  YHULILFP FDUH H FODVD SURLHFWXOXL if (proj.HasAttribute("class") == true) { Console.WriteLine("de clasa '{0}'.", proj.GetAttribute("class"));
  • 671. 3URFHVUL ;0/ 211  VDX PDL SXLQ H[DFW // proj.Attributes[0].Value; } else { &RQVROH:ULWH/LQH GH FODV QHFXQRVFuW
  • 672.   QX H[LVW DWULEXWXO FODVV vO FUHP XmlNode attr = doc.CreateNode( XmlNodeType.Attribute, "class", "");  LPSOLFLW SURLHFWXO H GH FODV ' 
  • 673. attr.Value = "D";  DWDúP QRGXO FUHDW OLVWHL DWULEXWelor // elementului <project> proj.Attributes.SetNamedItem (attr); } } } // final de "try" catch ( Exception e ) {  D DSUXW R H[FHSLH Console.WriteLine("Exceptie: " + e.Message); return; } } // final de program 'principal' // metoda de tratare a evenimentului de inserare // a unui nod in arborele DOM private static void NodeInsertedHandler(Object src, XmlNodeChangedEventArgs args) { Console.WriteLine("A fost inserat un nod de tip {0}.", args.Node.NodeType); // salvam, indentat, documentul într-un fiúLHU  QXPDL GDF D IRVW LQVHUDW DWULEXWXO FODVV
  • 674. if (args.Node.NodeType != XmlNodeType.Attribute) return; try { XmlTextWriter writer = new XmlTextWriter("projects2.xml", null); writer.Formatting = Formatting.Indented; doc.Save(writer);
  • 675. Tehnologii XML212 writer.Close(); Console.WriteLine("Documentul XML a fost salvat."); } catch ( Exception e ) {  D DSUXW R H[FHSLH Console.WriteLine("Exceptie: " + e.Message); return; } } } } $PQXQWH SULYLQG PRGXO GH SURFHVDUH ;0/ vQ 1(7 VXQW IXUQL]DWH GH OXFUULOH %RUQVWHLQ 
  • 676.  5RELQVRQ 
  • 677. üL :LNH 5HKPDQ üL /HXSHQ (2002). Procesarea datelor XML în PHP $FHHDüL VDUFLQ LPSOHPHQWDW vQ 3+3  üL UHFXUJkQG OD H[WHQVLD '20 VH FRQFUHWL]HD] vQ XUPWRUXO FRGXO-VXUV GHILQH 3$7+
  • 678.   ORFDLD GRFXPHQWXOXL  YDULDELO JOREDO LQGLFkQG GDF GRFXPHQWXO // a fost modificat $modified = 0;  vQFUFP GRFXPHQWXO ;0/ if (!$doc = domxml_open_file(PATH . "projects.xml")) { HFKR S!$ DSUXW R HURDUHS!n"; exit; }  UGFLQD GRFXPHQWXOXL $root = $doc->document_element();  DILúP LQIRUPDLL JHQHUDOH GHVSUH GRFXPHQW HFKR S!(OHPHQWXO UGFLQ HVWH OW  $root->node_name() . "&gt;.</p>";  DILúP LQIRUPDLL SULYLWRDUH OD SURLHFWH $projs = $root->get_elements_by_tagname("project"); foreach ($projs as $proj) {  SUHOXP QRGXULOH WLWOH! $titles = $proj->get_elements_by_tagname("title");
  • 679. 3URFHVUL ;0/ 213 foreach ($titles as $title) { echo "<p>Proiect: " . $title->get_content(); }  YHULILFP FDUH H FODVD SURLHFWXOXL if ($proj->has_attribute("class")) { HFKR  GH FODV   $proj->get_attribute("class") . "</p>"; } else { HFKR  GH FODV QHFXQRVFXWS!;  QX H[LVW DWULEXWXO FODVV vO FUHP  LPSOLFLW SURLHFWXO H GH FODV ' 
  • 680. $attr = $proj->set_attribute("class", "D");  PDUFP GRFXPHQWXO FD ILLQG PRGLILFDW $modified = 1; } }  GDF GRFXPHQWXO D IRVW PRGLILFDW vO DILúP if ($modified) { $xmldoc = $doc->html_dump_mem(); echo "<pre>" . htmlentities($xmldoc) . "</pre>"; } ?> $OWH H[HPSOH GH UHDOL]DUH GH SURFHVUL ;0/ vQ 3+3 VXQW GLVSRQLELOH vQ %XUDJD 
  • 681. üL %XUDJD 
  • 682.  3UHOXFUUL;0/vQ3HUO În continuare, dorim V FRQWRUL]P SURLHFWHOH GH FODV Å$µ 3HQWUX DFHDsta, FRQFHSHP XUPWRUXO SURJUDP 3HUO UHFXUJkQG OD PRGXOXO XML::DOM (detalii în Buraga et al., 2002). #!/usr/bin/perl use XML::DOM; $parser = new XML::DOM::Parser; $doc = $parser->parsefile ('projects.xml'
  • 683.   vQFrFP $proiecte = $doc->getElementsByTagName ('project'); $nr_proiecte = $proiecte->getLength; SURLHFWHBFODVD$   FRQWRUL]HD] SURLHFWHOH $
  • 684. Tehnologii XML214  EDOHLP WRDWH SURLHFWHOH for (my $i = 0; $i < $nr_proiecte; $i++) { $proiect = $proiecte->item ($i);  SUHOXP FODVD SURLHFWXOXL $clasa = $proiect->getAttributeNode ('class')->getValue; $proiecte_clasaA++ if $clasa eq 'A'; }  DILúP OD LHúLUHD VWDQGDUG print "Pentru documentul XML de mai jos:n"; print $doc->toString; print "nSunt $proiecte_clasaA proiecte de clasa A.n";  HOLEHUP PHPRULD $doc->dispose(); 2 DERUGDUH UHODWLY PDL FRPSOH[ HVWH XUPWRDUHD vQ FDUH YRP DSHOD OD IDFLOLWLOH RULHQWDWH SH RELHFW SXVH OD GLVSR]LLH GH 3HUO SHQWUX D UHDOL]D XQ LWHUDWRU GH DUERUL '20 GHWDOLL vQ 5D üi McIntosh, 2002). Astfel, vom scrie un pachet Perl înFDSVXOkQG IXQFLRQDOLWDWHD LWHUDWRUXOXL üL QXPLW XML::DOMIterator.pm: package XML::DOMIterator; sub new { # constructor my $class = shift; my $self = {@_}; $self-!^1RGH` XQGHI  GHVHPQHD] QRGul curent vizitat return bless ( $self, $class ); }  vQDLQWHD] vQ DUERUH sub forward { my $self = shift;  vQFHUFP V FRERUkP OD XUPWRUXO QLYHO GLQ Drbore if ($self->is_element and $self->{Node}->getFirstChild) { $self->{Node} = $self->{Node}->getFirstChild; } else {  DFFHVDP XUPWRUXO IUDWH VDX VWUPRúL DL IUDWelui while ($self->{Node}) { if ($self->{Node}->getNextSibling) { $self->{Node} = $self->{Node}->getNextSibling; return $self->{Node};
  • 685. 3URFHVUL ;0/ 215 } $self->{Node} = $self->{Node}->getParentNode; } } } # merge cu un nod înapoi în arbore sub backward { my $self = shift;  DFFHVP IUDWHOH SUHFHGHQW úL FRERUkP VSUH XOWimul nod # în arbore if ($self->{Node}->getPreviousSibling) { $self->{Node} = $self->{Node}->getPreviousSibling; while ($self->{Node}->getLastChild) { $self->{Node} = $self->{Node}->getLastChild; } } else {  XUFP $self->{Node} = $self->{Node}->getParentNode; } return $self->{Node}; } # întoarce rHIHULQD VSUH QRGXO FXUHQW sub node { my $self = shift; return $self->{Node}; }  VWDELOHúWH QRGXO FXUHQW sub reset { my ($self, $node) = @_; $self->{Node} = $node; }  WHVWHD] GDF QRGXO FXUHQW HVWH HOHPHQW sub is_element { my $self = shift; return ($self->{Node}->nodeType == 1); } 1;
  • 686. Tehnologii XML216 Vom parcurge, folosind modulul XML::DOMIterator, un document XML, DILükQG QXPHOH HOHPHQWHORU üL YDORULOH QRGurilor de tip caracter. Procesorul XML va fi furnizat de modulul XML::LibXML, FDUH DUH OD ED] ELEOLoteca libxml DPLQWLW vQ VHcLXQHD  use lib '/home/busaco/perl-libxml'; use XML::LibXML; use XML::DOMIterator;  LQLLDOL]P SURFHVRUXO úL LWHUDWRUXO my $parser = new XML::LibXML; my $doc = $parser->parse_file (shift @ARGV); my $iter = new XML::DOMIterator;  SRUQLP GH OD UGFLQD GRFXPHQWXOXL $iter->reset ($doc->getDocumentElement);  DILúP WRDWH QRGXULOH DUERUHOXL GH OD SULPXO OD XOWLPXO my $nod = $iter->node; my $ultimul; print "De la primul la ultimul:n"; while ($nod) { afiseaza ($nod); $ultimul = $nod; $nod = $iter->forward; }  DILúP WRDWH QRGXULOH DUERUHOXL GH OD XOWLPXO OD SULPXO print "De la ultimul la primul:n"; $iter->reset ($ultimul); afiseaza ($iter->node); while ($iter->backward) { afiseaza ($iter->node); }  DILúHD] LQIRUPDLL GHVSUH XQ QRG sub afiseaza { my $nod = shift; if (ref($nod) =~ /Element/) { # nod element print "<" . $nod->nodeName . ">n"; } elsif (ref($nod) =~ /Text/) { # nod caracter print """ . $nod->nodeValue . ""n"; } }
  • 687. 3URFHVUL ;0/ 217 În continuare, GRULP V UHDOL]P FRQWRUL]DUHD DXWRULORU XQLFL DL XQHL FUL IRORVLQG FD GRFXPHQW GH LQWUDUH XQXO FX VWUXFWXUD <a:carti xmlns:a="urn:infoiasi-ro:carti"> <carte> <a:autor>Sabin Buraga</a:autor> DDXWRU!'UDJRú $FRVWFKLRDLHDDXWRU! <a:titlu>Utilizare Linux</a:titlu> </carte> </a:carti> Programul Perl are codul-VXUV XUPWRU P DXWRUL  FRQLQH QXPUXO GH DSDULLL DOH XQXL DXWRU  LQLLDOL]P SURFHVRUXO úL LWHUDWRUXO my $parser = new XML::LibXML; my $doc = $parser->parse_file ('carti.xml'); my $iter = new XML::DOMIterator; $iter->reset ($doc->getDocumentElement); $nod = $iter->node; while ($nod) { contorizeaza ($nod); $ultim = $nod; $nod = $iter->forward; } foreach $autor (sort keys %autori) { SULQW $XWRUXO DXWRU D DSUut de $autori{$autor} ori.n"; } VXE FRQWRUL]HD]D ^  FRQWRUL]P HOHPHQWHOH DDXWRU my $nod = shift; return unless ($nod->nodeType == 1); if ($nod->nodeName eq 'a:autor') { $autori{$nod->textContent}++; } } Un posibil rezultat este ilustrat mai jos: (infoiasi)$ perl numara_autori.pl $XWRUXO 'UDJRú $FRVWFKLRDLH D DSUXW GH  RUL $XWRUXO 6DELQ %XUDJD D DSUXW GH  RUL Autorul Victor Tarhon-2QX D DSUXW GH  RUL
  • 688. Tehnologii XML218 Traversarea documentelor XML în Java 3HQWUX D QXPUD DWULEXWHOH FRUHVSXQ]WRDUH ILHFUXL HOHPHQW VSHFLILFDW vQ FDGUXO XQXL GRFXPHQW ;0/ YRP DGRSWD R VROXLH VFULV vQ -DYD  6H poate observa utilizarea unei maniere recursive de traversare a arborelui DOM: import org.w3c.dom.*; import javax.xml.parsers.*; // clasa de procesare DOM public class DOM {  DUJY>@ UHSUH]LQW 85,-ul documentului XML public static void main (String argv []) { if (argv.length != 1) { System.err.println ("Sintaxa: DOM <fisier.xml>"); return; } try {  LQVWDQLHUL... DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder docb = dbf.newDocumentBuilder();  SUHJWLP SURFHVDUHD GRFXPHQWXOXL Document doc = docb.parse (argv[0]);  WUDYHUVP UHFXUVLY Drborele DOM traverseaza (doc.getDocumentElement()); } catch (Exception e) { System.err.println ("Eroare de procesare DOM: "); e.printStackTrace (); } }  WUDYHUVHD] UHFXUVLY XQ DUERUH '20 static private void traverseaza (Node nod) {  DILúP QXPHOH QRGXULORU GH WLS HOHPHQW  SOXV QXPUXO GH DWULEXWH if (nod.getNodeType() == Node.ELEMENT_NODE) { System.out.println ("Elementul '" + nod.getNodeName() + "' are " + nod.getAttributes().getLength() + " atribute.");
  • 689. 3URFHVUL ;0/ 219 }  FRQWLQXP WUDYHUVDUHD Node copil = nod.getFirstChild(); // primul copil if (copil != null) traverseaza (copil); FRSLO QRGJHW1H[W6LEOLQJ
  • 690.   XUPWRUXO IUDWH if (copil != null) traverseaza (copil); } } 8UPWRUXO H[HPSOX RIHU XQ VFKHOHW SULYLWRU OD R SDJLQ -63 JavaServer Pages
  • 691. FDUH YD JHQHUD PDUFDWRUL ;+70/ FXSULQ]kQG LQIRUPDLL GHVSUH nodul-UGFLQ DO XQXL GRFXPHQW ;0/ <%@ page import="javax.xml.parsers.*, org.w3c.dom.*" %> <%  vQFUFP úL SURFHVP XQ GRFXPHQW ;0/ DocumentBuilder builder; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); builder = factory.newDocumentBuilder(); Document document = builder.parse("cuprins.xml");  SUHOXP QRGXO-UGFLQ úL SULPXO OXL FRSLO Element root = document.getDocumentElement(); Node text = root.getFirstChild(); %> <html><body> <p><%=text.getNodeValue() %></p> </body></html> Mai multe detalii despre modul de procesarH ;0/ VXQW H[SXVH vQ OXFUUL SUHFXP 0F/DXJKOLQ 
  • 692. üL 7DQDV et al. (2003). Consultarea unui document XML via un program C++ )XUQL]P vQ FRQWLQXDUH XQ SURJUDP & IRORVLQG ELEOLRWHFD 4W GLQ /LQX[ SHQWUX D JHQHUD R DSOLFDLH JUDILF .'( DILükQG OLVWD SURiectelor. Programul principal, numit main.cpp, are forma: #include <qapplication.h> #include "projects.h" int main (int argc, char **argv) { // programul principal
  • 693. Tehnologii XML220 QApplication a (argc, argv); Projects project ("projects.xml"); a.setMainWidget (&project); // VHWP SURSULHWLOH IHUHVWUHL SULQFLSDOH project.setCaption ("XML -- Procesare DOM în Qt"); project.resize (150, 200); SURMHFWVKRZ
  • 694.   úL R DILúP return a.exec (); } )LüLHUXO DQWHW projects.h VSHFLILF R FODV GHULYDW GLn controlul ListView üL UHVSRQVDELO FX SURFHVDUHD GRFXPHQWXOXL ;0/ (D YD FRQVWUXL HOHPHQWHOH listei, parcurgând arborele DOM: #include <qlistview.h> #include <qdom.h>  GHILQLP FODVD 3URMHFWV GHULYDW GLQ FRQWUROXO /LVW9LHZ class Projects:public QListView { Q_OBJECT public: Projects (const QString fileName, // constructorul QWidget * parent = 0, const char *name = 0); ~Projects (); // destructorul private: QDomDocument domTree; // arborele DOM // metoda de DILúDUH D LQIRUPDLLORU GHVSUH SURLHcte void getProjectInformation (QDomElement & proj); }; ,PSOHPHQWDUHD FODVHL H UHDOL]DW vQ ILüLHUXO projects.cpp: #include "projects.h" #include <qfile.h> #include <qmessagebox.h> // constructorul Projects::Projects (const QString fileName, QWidget * parent, const char *name): QListView (parent, name) {  ILLQG XQ FRQWURO GH WLS 4/LVW9LHZ YRP DGXJD R FRORDQ  FDUH YD FRQLQH LQIRUPDLL SULYLWRDUH OD SURLHcte addColumn ("Proiect");  úL vQF XQD, specificând clasele proiectelor
  • 695. 3URFHVUL ;0/ 221 addColumn ("Clasa"); setColumnAlignment (1, Qt::AlignCenter); VHW$OO&ROXPQV6KRZ)RFXV WUXH
  • 696.   DPEHOH RELQ IRFXV-ul  FLWLP GRFXPHQWXO ;0/ úL FUHP DUERUHOH '20 QFile projFile (fileName); if (!projFile.open (IO_ReadOnly)) { QMessageBox::critical (0, tr ("Eroare fataO
  • 697.  tr ("Nu am putut deschide %1").arg (fileName)); return; } if (!domTree.setContent (&projFile)) { 40HVVDJH%R[FULWLFDO  WU (URDUH IDWDO
  • 698.  tr ("Eroare de procesare %1").arg (fileName)); projFile.close (); return; } projFile.close ();  SUHOXP LQIRUPDLL GLQ '20 QDomElement root = domTree.documentElement (); QDomNodeList projects;  RELQHP OLVWD GH SURLHFWH projects = root.elementsByTagName ("project"); for (unsigned i = 0; i < projects.length (); i++) { QDomElement node = projects.item (i).toElement (); getProjectInformation (node); }  VHWP IRFXVXO SH XOWLPXO HOHPHQW DO OLVWHL setCurrentItem (lastItem ()); } // destructorul Projects::~Projects () { }  IXUQL]HD] LQIRUPDLL GHVSUH SURLHFWH void Projects::getProjectInformation (QDomElement & proj) {  YL]LWP QRGXULOH-copil ale elementului <project> QDomNode node = proj.firstChild (); while (!node.isNull ()) {
  • 699. Tehnologii XML222 if (node.isElement ()) {  SUHOXP WLWOXO if (node.nodeName () == "title") { QDomText textChild = node.firstChild ().toText (); if (!textChild.isNull ()) { QListViewItem *item = 0; item = new QListViewItem (this, item);  LQVHUP WLWOXO SURLHFWXOXL vQ OLVW item->setText (0, textChild.nodeValue ());  YHULILFP GDF H VSHFLILFDW DWULEXWXO FODVV QDomAttr attr = proj.attributeNode ("class"); if (!attr.isNull ()) { item->setText (1, attr.value ()); } } } } node = node.nextSibling ();  XUPWRUXO IUate' } } Pentru compilare, vom recurge mai întâi la qxml.pro ILüLHU-proiect generat de Qt Assistant care va folosi la crearea unui fiüLHU Makefile: (infoiasi)$ /usr/lib/qt3/bin/qmake qxml.pro $SRL YRP FRPSLOD VXUVHOH XWLOL]kQG ILüLHUXO Makefile, iar la final vom executa programul: (infoiasi)$ make (infoiasi)$ ./qxml 8Q LQVWDQWDQHX DO LQWHUIHHL FX XWLOL]DWRUXO HVWH SUezentat în fiJXUD XUP- toare.
  • 700. 3URFHVUL ;0/ 223 )LJXUD  5H]XOWDWXO SURFHVULL SULQ 4'20 D XQXL GRFXPHQW ;0/ Traversarea unui document XML prin JavaScript /D ILQDOXO DFHVWHL VHFLXQL YRP GD R VROXLH -DYD6FULSW SULYLWRDUH OD DILüarea elementelor unui document XML „scufundat” într-R SDJLQ :HE 3HQWUX DFHDVWD UHFXUJHP OD IXQFLRQDOLWLOH DOM 2 Traversal & Range implementate de navigatorul Mozilla Firefox. Vom folosi un obiect de tip TreeWalker în YHGHUHD SDUFXUJHULL GRFXPHQWXOXL üL FRQVWUXLULL XQXL DUERUH FH VWRFKHD] re]XOWDWXO SDUFXUJHULL $SHOP üL OD XQ ILOWUX GHRDUHFH QX YRP DILüD GHFkW QRGXULOH GH WLS HOHPHQW 0DQLHUD GH SUH]HQWDUH D LQIRUPDLLORU YD IL FRQWURODW YLD SURSULHWL GH VWLO &66 – nivelul 2. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Traversare via DOM2</title> <!-- SURSULHWL &66 SHQWUX DILúDUHD UH]XOWDWXOXL --> <style><![CDATA[ div#date { display: none; } tag { display: block;
  • 701. Tehnologii XML224 margin-left: 1em; font-weight: bold; font-family: sans-serif; } tag:before { content: '<' attr(nume) '>' } tag:after { content: '</' attr(nume) '>' } text { display: inline; font-weight: normal; font-family: sans-serif; } text:before { content: attr(valoare) } ]]></style> <script><![CDATA[ IXQFWLRQ WUDYHUVHD]D
  • 702. ^  WUDYHUVHD] XQ DUERUH var pieton; // obiect de tip TreeWalker pieton = document.createTreeWalker( document.getElementById ('date'), NodeFilter.SHOW_ALL, null, true);  JVLP QRGXO FH YD FRQLQH UH]XOWDWXO WUDYHUVULL var rezultat = document.getElementById ('rezultat'); // copiem arborele rezultat adaugaArbore (pieton, rezultat); }  IXQFLH DSHODW UHFXUVLY SHQWUX FUHDUHD DUERUHOXL UH]XOWDW  UXOHD] LQGHSHQGHQW GH ILOWUX
  • 703. function adaugaArbore (pieton, destinatie) { LI SLHWRQILUVW&KLOG
  • 704. ^  vQF PDL SXWHP SDUFXUJH GR ^  JHQHUP FkWH XQ QRG SHQWUX ILHFDUH QRG SDUFXUV var nod; switch (pieton.currentNode.nodeType) { FDVH 1RGH(/(0(17B12'(  FUHP XQ HOHPHQW WDJ! nod = document.createElementNS (null, "tag"); nod.setAttribute ("nume", pieton.currentNode.nodeName); break; GHIDXOW  DOWIHO FUHP WH[W! FX DWULEXWXO YDORDUH nod = document.createElementNS (null, "text");
  • 705. 3URFHVUL ;0/ 225 nod.setAttribute ("valoare", pieton.currentNode.nodeValue); break; }  LQVHUP QRGXO vQ GLY!-XO IRORVLW SHQWUX DILúDUH  úL SDUFXUJHP QRGXULOH UPDVH destinatie.appendChild (nod); adaugaArbore (pieton, nod); } while (pieton.nextSibling());  UHVWDXUP VWDUHD SLHWRQXOXL pieton.parentNode (); } } ]]></script> </head> <body> EXWWRQ RQFOLFN WUDYHUVHD]D
  • 706. !$ILúHD] HOHPHQWHOHEXWWRQ! <!-- va include arborele rezultat în urma parcurgerii --> <div id="rezultat"/> <!-- date ce vor fi traversate ('scufundate' în XHTML) --> <div id="date"> <muzeu xmlns="urn:muzeu.ro"> <tablou id="rmud"> <autor>Ren&#233; Magritte</autor> <curent>suprarealist</curent> <titlu>Universul demascat</titlu> </tablou> <tablou id="hbjda"> <autor>Hieronymus Bosch</autor> <titlu>Judecata de apoi</titlu> </tablou> </muzeu> </div> </body> </html>
  • 707. Tehnologii XML226 Figura 5. Rezultatul traversULL YLD '20 – nivelul 2 5H]XOWDWXO RELQXW vQ XUPD WUDYHUVULL FRQVWUXFLLORU ;0/ üL UHLQHULL GRDU D LQIRUPDLLORU GHVSUH HOHPHQWH HVWH SUH]HQWDW vQ ILJXUD  5HDOL]DUHDWUDQVIRUPULORU;6/ ÍQ FRQMXQFLH FX SURFHVDUHD PRGHOXO '20 SHUPLWH üL DSOLFarea de foi de VWLOXUL ;6/7 )LHFDUH SODWIRUP VDX OLPEDM DUH R LQWHUID GH SURJUDPDUH GHGLFDW DFHVWHL DFWLYLWL /H YRP HQXPHUD SH FHOH PDL IUHcvent folosite: • libxslt – ELEOLRWHF FH SRDWH IL XWLOL]DW vQ FDGUXO SURJUDPHORU VFULVH în C, Perl, Python sau PHP; • Sablotron – LQWHUID GH SURJUDPDUH & IRORVLW üL GH H[WHQVLD 3+3 IXQFLLOH xslt_*() din PHP 4), plus de modulul XML::Sablotron pentru Perl; • Saxon – SXQH OD GLVSR]LLH XQ $3, -DYD RIHULQG VXSRUW üL SHQWUX H[WHQVLLOH (;6/7 üL ;6/7  PDL PXOW SULQWUH DOWHOH H[LVW SRUWUL pentru .NET; • MSXML – SRDWH IL LQWHJUDW vQ DSOLFDLL VDX SDJLQL :HE YLD &20 (ActiveX); • XslTransform – FODV GLQ VSDLXO GH QXPH System.Xml, disponibiO în .NET Framework 1.1; • TrAX (Transformation API for XML) – parte din JAXP, oferit de JDK; • Xalan – RIHU IXQFLRQDOLWL SHQWUX UHDOL]DUHD GH WUDQVIRUPUL ;6/ în C, Perl sau Java pe baza Apache Xerces; • XML::XSLT – modul Perl.
  • 708. 3URFHVUL ;0/ 227 'H DVHPHQHD SHQWUX WUDQVIRUPUL ;6/ H[LVW VXSRUW üL vQ FDGUXO navigatoarelor Web actuale, prin intermediul JavaScript (o serie de detalii în Buraga, 2001). Vom prezenta în continuare diverse exemple. 7UDQVIRUPUL;6/vQ& Un program C# utilizat la transformarea, via o foaie XSL, a documentelor XML are codul-VXUV GH PDL MRV $FHVW SURJUDP UHFXUJH OD VXSRUWXO RIerit de .NET Framework versiunea 1.1. using System; using System.IO; using System.Xml; using System.Xml.Xsl; using System.Xml.XPath; namespace csbXMLTools { class XMLTransformer { // clasa de transformare // 'programul' principal public static void Main(string[] args) { if ( args.Length == 0 ) { // nu sunt argumente Console.WriteLine("Sintaxa: xml-transformer <fisier.xml> <fisier.xsl>n"); return; } // o serie de variabile utilizate XslTransform xslt = null; XPathDocument xmlIn = null; XmlWriter xmlOut = null;  vQFHUFP V SURFHVP GRFXPHQWXO ;0/ try { xslt = new XslTransform();  vQFUFP IRDLD GH VWLOXUL ;6/ xslt.Load(args[1]);  FUHP XQ RELHFW ;3DWK'RFXPHQW FDUH YD FRQine  ILúLHUXO ;0/ GRULW D IL WUDQVIRUPDW xmlIn = new XPathDocument(args[0]);  FUHP XQ RELHFW ;PO7H[W:ULWHU FDUH YD FRQine  UH]XOWDWXO WUDQVIRUPULL DILúDW OD FRQVoO
  • 709. Tehnologii XML228 xmlOut = new XmlTextWriter(Console.Out);  UHDOL]P WUDQVIRUPDUHD xslt.Transform(xmlIn, null, xmlOut, null); } // final de "try" FDWFK ([FHSWLRQ H