xml/xhtml’ · xml/xhtml’ esa2012/2013’ adam’belloum’ [email protected]’ ’...

51
XML/XHTML ESA 2012/2013 Adam Belloum [email protected] Material Prepared by Eelco Schatborn

Upload: others

Post on 19-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XML/XHTML  

ESA  2012/2013  Adam  Belloum  

[email protected]    

Material  Prepared  by  Eelco  Schatborn    

Page 2: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Content  (part1)  

•  Why  XML  evolved  •  What  it  is  XML  •  Document  Type  DeclaraKon  •  XML  Schema  DefiniKon  

Page 3: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Why  XML  evolved  •  1960-­‐1980    Infrastructure  for  the  Internet  •  1986    SGML  (Standard  Generalized  Markup  Language)  for  defining  and  represenKng  structured  documents  

•  1991    WWW  and  HTML  introduced  for  the  Internet  •  1991    Business  adopts  the  WWW  technology;    expansion  in  the  use  of  the  Internet  

•  1995    New  businesses  evolve,  based  on  the  connecKvity  of  people  all  over  the  world  and  connecKvity  of  applicaKons  built  by  various  soZware  providers  (B2C,  B2B)  

Urgent  need  for  a  common  data  format  for  the  Internet  

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 4: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Why  XML  evolved  •  Needs:  –  Simple,  common  rules  easy  to  understand  by  people  with  different  backgrounds    (like  HTML)  

–  Capability  to  describe  Internet  resources  and  their  relaKonships  (like  HTML)  

–  Capability  to  define  informa5on  structures  for  different  kinds  of  business  sectors  (unlike  HTML,  like  SGML)  

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 5: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Why  XML  evolved  

•  Needs  (cont’d):  –  Format  formal  enough  for  computers          &  clear  enough  to  be  human-­‐legible  (like  SGML)  

–  Rules  simple  enough  to  allow  easy  building          of  soZware  (unlike  SGML)  

–  Strong  support  for  diverse  natural  languages          (unlike  SGML)  

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 6: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XML  =  Extensible  Markup  Language  

A  set  of  rules  for  defining  and  represenAng  informaAon  as  structured  documents  for  applicaKons  on  the  Internet;  a  restricted  form  of  SGML  

T.  Bray,  J.  Paoli,  and  C.  M.  Sperberg-­‐McQueen  (Eds.),  Extensible  Markup  Language  (XML)  1.0,  W3C  RecommendaAon  10-­‐  February-­‐1998,    hfp://www.w3.org/TR/1998/REC-­‐xml-­‐19980210/.      T.  Bray,  J.  Paoli,  C.  M.  Sperberg-­‐McQueen,  and  E.  Maler  (Eds.),  Extensible  Markup  Language  (XML)  1.0  (Second    EdiKon),  W3C  RecommendaAon  6  October  2000,  hfp://www.w3.org/TR/2000/REC-­‐xml-­‐20001006/.    

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 7: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Markup  languages    A  markup  language  is  a  modern  system  for  annotaAng  a  text  in  a  way  that  is  syntacKcally  disKnguishable  from  that  text.    The  idea  and  terminology  evolved  from  the  "marking  up"  of  manuscripts  •  DocBook  •  HTML  •  MathML  •  RTF  •  TEX  •  Troff  •  Wikipedia/WikiMedia  markup  language  •  DokuWiki  •  .  .  .  

hfp://en.wikipedia.org/wiki/List_of_markup_languages  

Page 8: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

SGML          SGML  was  originally  designed  to  enable  the  sharing  of  

machine-­‐readable  large-­‐project  documents  in  government,  law,  and  industry  

•  A  conforming  SGML  document  must  be  either  a  type-­‐valid  SGML  document,  a  tag-­‐valid  SGML  document,  or  both.    

•  Standard  Generalized  Markup  Language  •  You  can  define  markup  languages  for  documents  •  ISO  standard;  ISO  8879:1986  SGML  •  Metalanguage  •  Borne  from  the  publishing  world  •  Existed  before  HTML  •  Extensively  used  

Wikipedia:  A  fragment  of  the  OED  (1985),  showing  SGML  markup  

Page 9: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

META  languages  •  languages  used  to  make  statements  about  statements  in  

another  language  (called  the  object  language)  •  can  refer  to  any  terminology  or  language  used  to  discuss  

language  itself  

•  Backus–Naur  Form,  developed  in  the  1960s  by  John  Backus  and  Peter  Naur,  is  one  of  the  earliest  metalanguages  used  in  compuKng.  

•  XML  –  eXtensible  Markup  Language  – W3C  standard  

Page 10: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

InternaKonal  OrganizaKon  for  StandardizaKon  (ISO)  

•  senng  internaKonal  Standards  •  representaKves  from  various      naKonal  standards  organizaKons  

•  founded  23  February  1947,  headquartered  in  Geneva,  Switzerland  

•  abbreviaKon  ISO  comes  from  greek  isos  meaning  `equal’  •  named  ISO  because  the  acronym  would  be  different  in  

each  Country  •  naming  ISO  the  acronym  was  the  first  standardisaKon    

Page 11: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

eXtensible  Markup  Language  (XML)  (1)  

•  general-­‐purpose  specificaAon  for  creaKng  custom  markup  Languages  

•  you  can  define  your  own  elements  for  structuring  data  

•  recommended  by  the  World  Wide  Web  ConsorKum  (W3C)  

•  open  standard  •  started  as  a  simplified  subset  of  the  (SGML),  a  more  restricAve  subset  of  SGML  

•  designed  to  be  relaAvely  human-­‐legible    

Page 12: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

eXtensible  Markup  Language  (XML)  (2)  

•  By  adding  semanAc  constraints,  applicaKon  languages  can  be  implemented  in  XML.  

•  These  include  XHTML,  RSS,  MathML,  GraphML,  Scalable  Vector  Graphics,  MusicXML,  .  .  .  

•  XML  is  someKmes  used  as  the  specificaKon  language  for  such  applicaKon  languages.  

Page 13: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XML  based  languages  •  XHTML  Markup  language  for  WWW  pages  •  RSS  Markup  language  for  Really  Simple  SyndicaKon  (v2)  •  MathML  Markup  language  for  formula's  •  GraphML  Markup  language  for  graphs  •  SVG  Scalable  Vector  Graphics  •  MusicXML  Markup  language  for  sheet  music  •  SAML  Security  AsserKon  Markup  Language  •  VML  Voice  Markup  language  •  SYNCML  Device  SynchronisaKon  •  .  .  .  

hfp://en.wikipedia.org/wiki/List_of_XML_markup_languages  

Page 14: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Document  Markup  Languages  

•  Open  Document  Format  (ODF)  •  OpenOffice.org  XML  •  ReportML  •  SpreadsheetML  •  WordprocessingML  •  LATEX  

hfp://en.wikipedia.org/wiki/List_of_document_markup_languages  

Page 15: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

What is XML? •  Rule  1:    –  InformaKon  is  represented  in  units  called  XML  documents.  

•  Rule  2:    – An  XML  document  contains  one  or  more  elements.  

•  Rule  3:    – An  element  has  a  name,  it  is  denoted  in  the  document  by  explicit  markup,  it  can  contain  other  elements,  and  it  can  be  associated  with  a;ributes.  

and  lots  of  other  rules  ...  Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 16: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Example of an XML document <?xml version="1.0"?> <catalog> <product category = "mobile phone"> <mfg>Nokia</mfg><model>8890</model> <description> Intended for EGSM 900 and GSM 1900 networks … </description> <clock setting= "nist" alarm = "yes"/>

</product> <product category = "mobile phone"> <mfg>Ericsson</mfg><model>A3618</model>

<description>...</description> </product> ... </catalog>

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 17: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Classes of text markup

XML  is  primarily  for  descripKve  markup.  

presenta+onal   Mobile  phones:        Nokia      8890        Ericsson    A3618  

procedural  

<document>      <newPage  style="box"/>      <bold>Mobile  phones:</bold>      <list>              <newItem/><italic>Nokia      8890</italic>              <newItem/><italic>Ericsson    A3618</italic>      </list>  </document>  

descrip+ve   (the  previous  example)  

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 18: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Physical (storage) units

•  XML  document  comprises  one  or  more  en++es  – A  “document  enAty”  serves  as  the  root  – Other  enKKes  may  include  

•  external  porKon  of  DTD  •  parsed  character  data,  which  replaces  any  references  to  the  enKty  •  unparsed  data  

•  EnKKes  located  by  URIs  

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 19: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XML  1.0  fundamentals  •  XML  declaraKon:  <?xml version=”1.0”?> •  Logical  data  components:  

–  Markup  vocabulary:  elements,  afributes  

   <product category = "mobile phone"> <mfg>Nokia</mfg><model>8890</model> <clock setting = "nitz" alarm = "yes"/> …

</product>  –  White  space                                                                        xml:space  –  Parsed  and  unparsed  Character  Data            PCDATA and CDATA  –  EnKty  references                                                                      &diagram;  –  Comments     <!-- how interesting… --> –  Processing  instrucKons  

<?xml-stylesheet href="catalog-style.css" type="text/css"?>

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 20: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XML 1.0 fundamentals  •  Markup  declaraKons:  Document  Type  DefiniKon  (DTD):  –  Internal  vs.  external  declaraKons  –  Element  types:  EMPTY,  children,  mixed,  ANY  

<!ELEMENT category (mfg, model, description , clock?)> <!ELEMENT description (#PCDATA | feature)*> <!ELEMENT clock EMPTY>

–  AXribute  types:  CDATA,  ID,  IDREF(-­‐S),              ENTITY(-­‐TIES),  NMTOKEN(-­‐S)  <!ATTLIST clock setting CDATA #IMPLIED alarm (yes, no, dual) "yes" >

–  NotaKons  –  EnKKes  

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 21: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XML 1.0 fundamentals  

•  Conformance:  – Well-­‐formed:  •  syntacKcally  correct  tags  •  matching  tags  •  nested  elements  •  all  enKKes  declared  before  they  are  used  

–  Valid:  •  well-­‐formed    •  DTD  +  doctype  matches  DTD  •  unique  IDs  •  no  dangling  IDREFs  

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 22: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

3. XML 1.0 fundamentals XML  

document  

XML  processor  

applicaKon  

may  or  may  not  be  “validaKng”  

“XML  InformaKon  Set”  

Frank  Tompa  and  Airi  Salminen  University  of  Waterloo  

Page 23: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Example  SVGML  <svg id="body" width="21cm" height="13.5cm” viewBox="0 0

210 135"> <title>Example</title> <desc> Rectangle with red border and light blue interior, with (intended) gray shadow rectangle.

</desc> <rect x="10" y="20" width="150" height="70”

fill="#eeeeff" stroke="red" stroke-width="1" /> <rect x="10" y="20" width="150" height="70”

transform="translate(3, 3)” fill="#999999" stroke="#999999" stroke-width="1" />

</svg>

Page 24: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Document  Type  DefiniKon  (DTD)  

•  set  of  declaraAons  that  conform  to  a  parKcular  markup  syntax  that  describe  a  class,  or  type  of  document,  in  terms  of  constraints  on  the  structure  of  that  document  

•  oZen  used  to  describe  a  document  authored  in  the  DTD  language  

•  specifies  the  syntax  of  an  “applicaKon”  of  SGML  or  XML,  (like  HTML  or  XHTML)  

•  one  of  several  SGML  and  XML  schema  languages,  others  include  XML  Schema  and  RELAX  NG  

Page 25: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

DTD  declaraKons  •  A  DTD  is  associated  with  an  XML  document  via  a  

–   Document  Type  DeclaraAon,  –   a  tag  near  the  start  of  the  XML  document.  

•  declaraKons  can  be  internal  (in  the  DTD  declaraKon  itself)  or  external  (located  in  a  separate  file)  

•  external  declaraAons  may  be  referenced  via  a  –   public  idenKfier  and/or  a  system  idenKfier  

•  Example    <!DOCTYPE  html  PUBLIC  "-­‐//W3C//DTD  XHTML  1.0  TransiAonal//EN"  "hXp://www.w3.org/TR/xhtml1/DTD/xhtml1-­‐transiAonal.dtd">  

Page 26: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XML  DTD  Example  

•  An  example  of  a  very  simple  XML  DTD  to  describe  a  list  of  persons  (taken  from  Wikipedia)  

<!ELEMENT people_list (person*)> <!ELEMENT person (name, birthdate?, gender?, socialsecuritynumber?)>

<!ELEMENT name (#PCDATA)> <!ELEMENT birthdate (#PCDATA)> <!ELEMENT gender (#PCDATA)> <!ELEMENT socialsecuritynumber(#PCDATA)>

Page 27: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Using  the  DTD  Example  

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE people_list SYSTEM "example.dtd"> <people_list> <person> <name>Eelco Schatborn</name> <birthdate>6/6/1974</birthdate> <gender>Male</gender> </person> </people_list>

Page 28: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XML  Schema  DefiniKon  (XSD)  •  published  as  a  W3C  recommendaKon  in  May  2001  •  one  of  several  XML  schema  languages  (like  DTD)  •  the  first  separate  schema  language  for  XML  to  achieve  

RecommendaKon  status  by  the  W3C  •  typically  has  extension  .xsd  •  wrifen  in  XML,  has  a  schema  of  its  own  •  more  powerful  than  DTD,  namespace  aware,  type  

support.  .  .  •  no  root  element,  more  verbose  than  DTD,  user  cannot  add  

more  types.  .  .  

Page 29: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XSD  Example  •  An  example  of  a  very  simple  XSD  to  describe  a  country  (taken  from  

Wikipedia)   <xs:schema xmlns:xs=

http://www.w3.org/2001/XMLSchema> <xs:element name="country" type="Country"/>

<xs:complexType name="Country"> <xs:sequence> <xs:element name="name" type="xsd:string"/> <xs:element name="population” type="xs:decimal"/>

</xs:sequence> </xs:complexType>

</xs:schema>  

Page 30: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Using  the  XSD  Example  

<country xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

xsi:noNamespaceSchemaLocation="country.xsd"> <name>France</name> <population>64473140</population>

</country>

Page 31: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

What  is  XML  good  for:  

Listen  to  Bob  Boiko's  who  give  an  interesKng  introducKon  to  XML          (Bob  Boiko  is  a  Senior  Lecturer  for  the  iSchool.  University  of  Washington)  

Page 32: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Content  (part2)  

•  HTML  •  Dynamic  HTML  •  XHTML  •  Difference  between  HTML  and  XHTML  •  XHTML  1.0  •  Some  details  about  HTML  documents    

Page 33: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

HTML  •  HTML  2.0  published  November  1995  as  IETF  RFC  1866,  and  

declared  obsolete/historic  by  RFC  2854  in  June  2000  

•  HTML  3.2  published  January  14,  1997  as  W3C  RecommendaKon  

•  HTML  4.0  published  December  18,  1997  as  W3C  RecommendaKon  

•  HTML  4.01  (minor  fixes)  published  December  24,  1999  as  a  W3C  RecommendaKon  

•  ISO/IEC  15445:2000  (“ISO  HTML”,  based  on  HTML  4.01  Strict)  –  published  May  15,  2000  as  an  ISO/IEC  internaKonal  standard  

Page 34: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Dynamic  HTML  (DHTML)  •  Dynamic  HTML  is  used  for  the  creaKon  of  interacAve  

web  sites.  

•  collecKon  of  technologies  used  together  to  create  interacAve  and  animated  web  sites  

•  it  uses  a  combinaKon  of:  –  a  staKc  markup  language  (such  as  HTML)  –  a  client-­‐side  scripAng  language  (such  as  JavaScript)  –  a  presentaKon  definiAon  language  (such  as  CSS)  –  Document  Object  Model  (DOM)  

Page 35: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

eXtensible  Hypertext  Markup  Language  (XHTML)  

•  XHTML  1.0  became  a  World  Wide  Web  ConsorKum  (W3C)  RecommendaKon  on  January  26,  2000.  

•  XHTML  1.1  became  a  W3C  RecommendaKon  on  May  31,  2001.  

•  XHTML  is  an  applicaKon  of  XML,  so  must  be  well-­‐formed  

•  automated  processing  can  be  performed  using  standard  XML  tools  

•  XHTML  is  a  reformulaKon  of  HTML  in  XML.  –  Pure  specificaKon  –  Clear  separaKon  between  content  and  layout  

Page 36: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Differences  between    XHTML  and  HTML  

•  All  tags  are  lowercase  (<p>)  •  All  documents  have  a  doctype  and  an  XHTML  namespace  

•  All  documents  must  be  well-­‐formed  •  All  tags  (elements)  must  be  closed,  even  empty  ones  (<leeg  />)  

•  Afribute  values  must  be  bounded  by  double  quotes  (")  

•  All  tags  must  be  nested  correctly  

Page 37: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XHTML  1.0  •  December  1998,  publicaKon  of  W3C  Working  DraZ  enKtled  

“ReformulaKng  HTML  in  XML”  

•  “Voyager”  the  codename  for  a  new  markup  language  based  on  HTML  4  but  adhering  to  the  stricter  syntax  rules  of  XML.  

•  February  1999  the  specificaKon  had  changed  name  to  XHTML  1.0  \The  Extensible  HyperText  Markup  Language”  

•  January  26,  2000  officially  adopted  as  a  W3C  RecommendaKon  

•  2nd  ediKon  of  XHTML  1.0  became  a  W3C  RecommendaKon  in  August  2002.  

Page 38: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

XHTML  1.0  There  are  three  formal  Document  Type  DescripAons  (DTDs)  for  

XHTML  1.0,  corresponding  to  the  three  different  versions  of  HTML  4.01  

XHTML  1.0  Strict    the  equivalent  to  HTML  4.01  strict  ,  includes  elements  and  aXributes  not  

marked  deprecated  in  the  HTML  4.01  specificaKon.  

XHTML  1.0  TransiAonal  the  equivalent  of  HTML  4.01TransiAonal,  includes  the  presentaAonal  

elements  (such  as  center,  font  and  strike)  excluded  from  the  strict  version.  

XHTML  1.0  Frameset  the  equivalent  of  HTML  4.01  Frameset,  allows  for  the  definiKon  of  

frameset  documents  a  common  Web  feature  in  the  late  1990s.  

Page 39: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Document  type  declaraKons  •  XHTML  1.0  Strict  

<!DOCTYPE  html  PUBLIC  "//W3C//DTD  XHTML  1.0  Strict//EN”  "hfp://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd">  

•  XHTML  1.0  TransiKonal  <!DOCTYPE  html  PUBLIC  "//W3C//DTD  XHTML  1.0  TransiAonal//EN"  "hfp://www.w3.org/TR/xhtml1/DTD/  

               xhtml1transiAonal.dtd">  

•  XHTML  1.0  Frameset  <!DOCTYPE  html  PUBLIC  "//W3C//DTD  XHTML  1.0  Frameset//EN"  "hfp://www.w3.org/TR/xhtml1/DTD/                    xhtml1frameset.dtd">  

Page 40: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Document  structure  <?xml version="1.0" encoding="ISO-8859-15"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> </head> <title>Home Page</title> <body> <p>Hallo!</p> </body> </html>

Page 41: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Common  mistakes  (1)  •  Not  closing  an  empty  element  –  wrong:  <br>  –  right:  <br  />  

•  Not  closing  non  empty  elements  –  wrong:  <p>  paragraph.<p>another  paragraph.  –  right:  <p>  paragraph.</p><p>another  paragraph.</p>  

•  Bad  nesKng  –  wrong:  <em><strong>This  is  some  text.</em></strong>  –  right:  <em><strong>This  is  some  text.</strong></em>  

Page 42: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Common  mistakes  (2)  •  Missing  alternate  text  –  wrong:  <img  src="/images/konijn.png"  />  –  right:            <img  src="/images/konijn.png"  alt="Knuffeldier"  />    

•  Using  text  directly  in  the  body  –  wrong:  <body>Welcome  to  my  page.</body>  –  right:  <body><p>Welcome  to  my  page.</p></body>  

•  NesKng  block  levels  and  inline  elements  –  wrong:  <em><h2>IntroducKon</h2></em>  –  right:  <h2><em>IntroducKon</em></h2>  

Page 43: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Common  mistakes  (3)  

•  Missing  quotes  – wrong:  <td  rowspan=3>  –  right:  <td  rowspan="3">  

•  Literal  use  of  the  ampersand  (&)  – wrong:  <Ktle>Cars  &  Trucks</Ktle>  –  right:  <Ktle>Cars  &amp;  Trucks</Ktle>  

•  Uppercase  vs.  lowercase  – wrong:  <BODY><P>The  Best  Page  Ever</P></BODY>  –  right:  <body><p>The  Best  Page  Ever</p></body>  

Page 44: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

VerificaKon  •  VerificaKon  of  the  code  can  be  done  locally  or  on-­‐line  –  You  can  use  the  W3C  Validator  on  the  web  –  You  can  use  Kdy  locally  –  You  can  use  a  browser  

•  Note:  browsers  use  different  engines  and  can  have  different  results!  

       VerificaKon  covers  most  errors,  though  finding  what  the  mistake  was  can  be  tricky.  Verifiers  are  genng  befer  and  befer  though.  

Page 45: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Editors  

•  vi  •  gedit  •  NVU  •  quanta  •  screem  •  frontpage  

Page 46: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Layout  engines  •  Trident  (MSHTML)  à  Internet  Explorer  4  to  8  •  Tasman  à    Internet  Explorer  5  for  Mac  •  Gecko  à    All  Mozilla  soZware,  including  Firefox;  Galeon;  

Flock;  also  Epiphany  •  WebKit  à  Safari;  Shiira;  iCab  4;  Epiphany;  Adobe  Air;  

Google  Chrome;  Midori  •  KHTMLà  Konqueror  •  Presto  à    Opera;  Nintendo  DS  Browser;  Internet  

Channel;  future  Adobe  Systems  products  •  iCab  à    iCab  1-­‐3  •  Prince  XML  à  Prince  XML  •  Amaya  à  Amaya  

Page 47: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

Assignment  •  create  few  enKKes  that  are  related  to  each  other  

(nested)  that  can  uniquely  idenKfy  by  characterisKcs  –  the  following  animals:  cow,  sheep,  horse,  pig,  mockingbird,  eal  

–  do  they  have  skin?  make  noise?  eyes?  .  .  .      •  now  create  data  for  each  animal    •  create  a  DTD  for  them,  each  enKty  should  have  at  least  

one  property  •  create  a  XML  schema  for  them  •  use  a  validator  to  check  schemas  (online)  •  validate  your  data  against  both  schemas  

Page 48: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

IntroducKon  to  XML  

•  hfp://www.youtube.com/watch?v=Q0k5ySZGPBc  •  hfp://www.youtube.com/watch?v=16q5bbeO3xI&feature=related  

•  hfp://www.youtube.com/watch?v=R63g3h5f5oA&feature=related  

IBM  technical  Series  …  

Page 49: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

IntroducKon  to  XML  

•  What  is  XML  good  for:  –  hfp://www.youtube.com/watch?v=CDawM8F-­‐fqY&feature=related  

•  Just  Enough  XML  to  Survive  –  hfp://www.youtube.com/watch?v=clJcs2-­‐UB40&feature=related  

•  Learn  XML  in  4  Minutes  –  hfp://www.youtube.com/watch?v=saQK7SlFiho&feature=related  

Page 50: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’

IntroducKon  to  HTML/XTML  •  Tutorial  1:  

–  hfp://www.youtube.com/watch?v=UfBvTsF3fqU  •  Tutorial  2:  

–  hfp://www.youtube.com/watch?v=jW1JmeLBWwk&feature=channel  •  Tutorial  3:  

–  hfp://www.youtube.com/watch?v=Xi6XBQPym2I&feature=channel  •  Tutorial  4:      

–  hfp://www.youtube.com/watch?v=UwD-­‐cVGbTAM&feature=channel  •  Tutorial  5:    

–  hfp://www.youtube.com/watch?v=H8b5zZ0LscU&feature=channel  •  Tutorial  6:    

–  hfp://www.youtube.com/watch?v=4Us2q5eSWNc&feature=channel  

Marc  Lassoff  LearnToPorgram.tv  

Page 51: XML/XHTML’ · XML/XHTML’ ESA2012/2013’ Adam’Belloum’ a.s.z.belloum@uva.nl’ ’ Material’Prepared’by’Eelco’Schatborn’’