Web publishing and XHTML


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Web publishing and XHTML

  1. 1. Web publishing and xhtml
  2. 2. This lecture <ul><li>Goal </li></ul><ul><ul><li>Introduce XML based markup languages, using xhtml as example </li></ul></ul><ul><ul><li>Understand &quot;well formed&quot; and &quot;valid&quot; </li></ul></ul><ul><ul><li>Understand difference between structure and presentation </li></ul></ul><ul><ul><li>Differences between the ”old” html and the ”new” xhtml </li></ul></ul>
  3. 3. Web - basic principles <ul><li>Two main components. </li></ul><ul><ul><li>http - Hypertext Transfer Protocol </li></ul></ul><ul><ul><ul><li>A computer protocol for transferring small files over the internet. </li></ul></ul></ul><ul><ul><li>html - Hypertext Markup Language </li></ul></ul><ul><ul><ul><li>A markup language used to describe hypertext documents, that is documents with links to other documents. Also the main topic of this lecture </li></ul></ul></ul>
  4. 4. Markup languages <ul><li>A family of computer languages for encoding information using elements/tags </li></ul><ul><ul><li><title>A Midsummer Night's Dream</title> </li></ul></ul><ul><li>Many different markup languages for different purposes </li></ul><ul><ul><li>html for web pages </li></ul></ul><ul><ul><li>Wml for (old) wap pages (mobile phones) </li></ul></ul><ul><ul><li>SVG for vector graphics </li></ul></ul><ul><ul><li>SMIL for multimedia </li></ul></ul><ul><ul><li>JDF for ”job tickets” (printing industry) </li></ul></ul>
  5. 5. Why use markup for content? <ul><li>Structure adds flexibility. Compare </li></ul><ul><ul><li>A scanned text. No possibilities to change the text, change pictures, fonts, colours… </li></ul></ul><ul><ul><li>A word document where only different fonts and font sizes have been used to indicate headings: changes in heading fonts/sizes must be done for each heading individually, no possibilities for creating indexes. </li></ul></ul><ul><ul><li>A word document where headings are coded as actual headings (heading1, heading2…). Changes can easilly be done in the templates which affect the entire document instantly, indexes can be created… </li></ul></ul>
  6. 6. Example of markup language:xhtml <ul><li>Elements start with <element_name> and are finished with </element_name> </li></ul><ul><li>Different markup languages have different elements </li></ul><ul><li>The elements to the right are from the xhtml vocabulary, but does not exist in, for example, SVG. </li></ul><ul><li><html> </li></ul><ul><li><head> </li></ul><ul><li><title> </li></ul><ul><li>A Title </li></ul><ul><li></title> </li></ul><ul><li></head> </li></ul><ul><li><body> </li></ul><ul><li><h1>Hello World</h1> </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul>
  7. 7. Hierarchical strukture <ul><li><html> </li></ul><ul><li><head> </li></ul><ul><li><title> </li></ul><ul><li>A Title </li></ul><ul><li></title> </li></ul><ul><li></head> </li></ul><ul><li><body> </li></ul><ul><li><h1>Hello World</h1> </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul>html head body title h1 A Title Hello World Element nodes Text nodes
  8. 8. Example - XHTML <ul><li><?xml version=&quot;1.0&quot;> </li></ul><ul><li><?xml-stylesheet type=&quot;text/css&quot; href=&quot;style.css&quot; type=&quot;text/css&quot; /> </li></ul><ul><li><!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;> </li></ul><ul><li><html> </li></ul><ul><li><head> </li></ul><ul><li><title>Personal web page </title> </li></ul><ul><li></head> </li></ul><ul><li><body> </li></ul><ul><li><p align=&quot;center&quot;> </li></ul><ul><li><img src=&quot;/kth/bilder/nada.gif&quot; alt=&quot;Nada&quot; width=&quot;468&quot; height=&quot;68&quot;/> </li></ul><ul><li></p> </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul>
  9. 9. Exemple - SMIL <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><smil> </li></ul><ul><li><head> </li></ul><ul><li><layout> </li></ul><ul><li><root-layout height=&quot;350&quot; width=&quot;600&quot; title=&quot;Universal SMIL Document&quot;/> </li></ul><ul><li><region id=&quot;w&quot; left=&quot;174&quot; top=&quot;100&quot; height=&quot;47&quot; width=&quot;63&quot; z-index=&quot;3&quot; /> </li></ul><ul><li></layout> </li></ul><ul><li></head> </li></ul><ul><li><body> </li></ul><ul><li><video src=&quot;Help.mov&quot; begin=&quot;0.00s&quot; end=&quot;11.00s&quot; /> </li></ul><ul><li></body> </li></ul><ul><li></smil> </li></ul>
  10. 10. Example - Data format <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><imf> </li></ul><ul><li><head> </li></ul><ul><li><version>3.0</version> </li></ul><ul><li><source supplier=&quot;PrintingCompany-1&quot; application=&quot;Application-1&quot;/> </li></ul><ul><li><time>1997-10-06T00:11:00.00+2</time> </li></ul><ul><li></head> </li></ul><ul><li><body> </li></ul><ul><li><object action=&quot;modify&quot;> </li></ul><ul><li><PrintingJob/> </li></ul><ul><li><object_uid> </li></ul><ul><li><source supplier=&quot;PrintingCompany-1&quot; application=&quot;Application-1&quot;/> </li></ul><ul><li><local_id>17</local_id> </li></ul><ul><li></object_uid> </li></ul><ul><li><attributes> </li></ul><ul><li><ActualCopies>14322</ActualCopies> </li></ul><ul><li></attributes> </li></ul><ul><li></object> </li></ul><ul><li></body> </li></ul><ul><li></imf> </li></ul>
  11. 11. Element contents <ul><li>Most elements have content, either text content or other elements </li></ul><ul><li>Some elements does not have content, the presence of the element is all information that is required </li></ul><ul><li>Element content </li></ul><ul><li><head> </li></ul><ul><li><title>Hello</title> </li></ul><ul><li></head> </li></ul><ul><li>Text content </li></ul><ul><li><title>Hello</title> </li></ul><ul><li>Empty content </li></ul><ul><li><br></br>, <hr></hr> </li></ul><ul><li>Or the short form </li></ul><ul><li><br/>, <hr/> </li></ul>
  12. 12. Attributes <ul><li>Additional aspects of an element can be encoded as ”attributes” of the element </li></ul><ul><ul><li><img src=”monkey.gif&quot; alt=”Picture of a monkey&quot;/> </li></ul></ul><ul><ul><ul><li>An empty element with two attributes; src and alt </li></ul></ul></ul><ul><ul><li>General syntax: attribute_name = ” attribute_value &quot; </li></ul></ul><ul><ul><li>Single quotes ok: attribute_name = ' attribute_value ' </li></ul></ul><ul><li>Note! It must be regular quotes (&quot;), not typographical quotes (”). </li></ul>
  13. 13. Images <ul><li>Images are inserted using the element <img> with the attribute src with a reference to an image file </li></ul><ul><li>Starting with xhtml all image elements must also contain the attribute ”alt” with a text-based description of the image </li></ul><ul><li><img src=&quot;http://www.kth.se/logos/kth.gif&quot; alt=”Image of KTH&quot; /> </li></ul>
  14. 14. html and xhtml <ul><li>Xhtml is based on XML, when html was based on SGML. More on XML in a later lecture. </li></ul><ul><li>Being based on XML makes it possible to use a number of tools and sofware. </li></ul><ul><li>Important differences between html and xhtml </li></ul><ul><ul><li>All tags must be closed:. <br></br> (or the short form <br/> for line breaks instead of just <br> which was used in html </li></ul></ul><ul><ul><li>All tag names and element names must be in ”small” letters. </li></ul></ul>
  15. 15. Well-formed <ul><li>An XML document is &quot;well formed&quot; if it fulfills a number of criteria. All XML documents (including xhtml) must be well-formed. </li></ul><ul><li>Example </li></ul><ul><li>All start-tags must have a corresponding end-tag (<html></html>) </li></ul><ul><li>The elements must form a tree structure <i><p></p></i> but NOT <i><p></i></p>) </li></ul><ul><li>Attribute values must be enclosed by quotes. </li></ul>
  16. 16. Logical vs physical tags <ul><li>XHTML separates content and the presentation of content </li></ul><ul><li>Tags like <font> and attributes like bgcolor are no longer allowed, all layout should be done using style sheets, CSS. </li></ul><ul><li>This makes it easier to interpret content for other devices than web browsers (like voice synthesizes, search engines, mobile web browsers…) . </li></ul>
  17. 17. Validation <ul><li>To check if xhtml code is correct, you can use a process called validation </li></ul><ul><li>This process checks that only xhtml elements and attributes are used, and are used correctly </li></ul><ul><li>Web based validation service at http://validator.w3.org/ </li></ul><ul><li>To be able to validate a web page, it is important to denote exactly which xhtml version the web page conforms to. In an xhmlt document, lines like this are added in the beginning of the document. </li></ul><ul><li><!DOCTYPE html </li></ul><ul><li>PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; </li></ul><ul><li>&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;> </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.