Advanced Web Technologies

Blog posts as part of the BSc Internet Application Development programme to discuss my experience while working on the tasks that will be given during the Advanced Web Technologies module.

During this course of 11 weeks, various aspects have been covered about advanced web technologies which are the following:
  • eXtensible Markup Language (XML) - is a markup language used to store and share data. An XML document should consist of a root element and also should contain proper nesting in tags (forming a tree structures). Also, the tags are case sensitive and each element should have a closing tags. For further information as regards an element, attributes (that should be quoted) are used. When these rules are followed, the XML document is well-formed. A valid document should be well-formed and also should follow the restrictions which have been specified in the Document Type Definition (DTD).[1]
  • Document Type Definition (DTD) - A DTD is used to describe the elements of an XML document. A DTD can either be declared inside the XML document or externally. Elements are declared using the ELEMENT declaration, while attributes are declared using the ATTLIST declaration. In a DTD, entities are variables that are used to create shortcut to text.[2] An ENTITY can also be known as escape sequences, used for special characters.[3]
  • XML CDATA - In a Parsed Character Data (PCDATA), data will be parsed by the XML parser. On the other hand, in Character Data (CDATA), data will not be parsed, that is, data will be ignored.[4]
  • XML Encoding - An XML document can consist of characters that are not (American Standard Code for Information Interchange) ASCII. Therefore to eliminate errors, an XML encoding should be specified. Another alternative is by saving the XML documents as Unicode.[5]
  • XML Namespaces - Namespaces are used to avoid conflicts on element names.
  • Cascading Style Sheets (CSS) - Cascading Style Sheets can be used to style both the XML and HTML document. Usually in an XML document, eXtensible Stylesheet Language (XSL) is used for styling.
  • XML Path Language (XPath) - Is used to extract specific information inside the XML document.
  • XLink and Xpointer - XLink is used to embed hyperlinks inside the XML document. To make a hyperlink pointing to particular parts of the XML document, XPointer should be used.[6]
  • XML Schema - An XML schema is an alternative to a DTD, but has more benefits. XML schemas are written using XML and includes data types and namespaces. In an XML schema, complex types (complexType) can contain attributes or child nodes, whereas simple types (simpleType) cannot contain attributes or child elements[7].

XML Editors

A web developer can create XML documents using XML editors instead of a normal text editor. These editors will help the developer creating a well-formed and valid XML document. Two known XML editors are:

Sematic Web Stack

To sum things up, to create Semantic web, the following languages or technologies (forming a stack)[8] are used:

Semantic Web Stack
  • Unicode and Uniform Resource Identifier (URI) - Unicode is used to encode character sets that are international, whereas a URI is used to uniquely identify resources;
  • eXtensible Markup Language (XML) - The XML layer uses namespaces and XML schema definitions to ensure that the syntax used is common. Namespaces and XML schema have been briefly described above;
  • Resource Description Framework (RDF) - RDF is a framework used to represent information on resources;
  • RDF Schema (RDFS) - RDFS is an extension to RDF. It can be used to depict taxonomies (classification) of classes;
  • Web Ontology Language (OWL) - OWL is an extension to RDF and RDFS used to describe logics;
  • Simple Protocol and RDF Query Language (SPARQL) - It is used to query RDF data, RDFS and OWL ontologies;
  • Rules - Rule languages are used to produce rules. Exaples of rule languages are Rule Interchange Format (RIF) and Semantic Web Rule Language (SWRL);
  • Proof and Trust - Results will be trusted when the inputs for the proof are trusted;
  • Cryptography - Digital signatures are used to verify the sources.

Sources:

[1] http://www.w3schools.com/xml/xml_summary.asp
[2] http://www.w3schools.com/dtd/dtd_summary.asp
[3] http://www.w3schools.com/dtd/dtd_entities.asp
[4] http://www.w3schools.com/xml/xml_cdata.asp
[5] http://www.w3schools.com/xml/xml_encoding.asp
[6] http://www.w3schools.com/xlink/xlink_intro.asp
[7] http://www.xaprb.com/blog/2006/03/16/simple-and-complex-types-in-xml-schema/
[8] http://www.obitko.com/tutorials/ontologies-semantic-web/semantic-web-architecture.html

QUICK QUESTIONS

  1. The following passage is to be found in the middle of a particular XML document:
    The heavily-used <service xlink:type = "simple"
    xlink:href ="http://www.thetrams.co.uk/croydon">
    Croydon Tramlink </service> provides a cross
    link to nearby <location>Wimbledon</location>,
    <location>Addington</location> and <location>Beckenham</location>
    .
    What can you say about how the text Croydon Tramlink will be treated by a browser such as Mozilla Firefox?

    The text 'Craydon Tramlink' will be treated as a link, which will be redirected to 'http://www.thetrams.co.uk/croydon'. It will be treated like this because it contains the xlink:href attribute.
  2. It’s possible to provide validation for a class of XML document using a Document Type Definition (.dtd) file, or using an XML schema. The DTD approach is easier. Why might you want to use the XML schema approach?

    As already explained in previous a previous post, a Document Type Definition (DTD) is used to describe how an XML document should be constructed. A DTD is used to validate an XML document. Although the DTD is easier, it also has limitations and therefore an alternative to DTD is an XML schema. Some benefits of XML schema over DTD are the following[1]:
    • XML schemas include data types and namespaces;
    • XML schemas are written using XML;
    • XML schemas are more powerful.

LONGER QUESTIONS

  1. Here is an XML document:
    <?xml version="1.0" encoding="UTF-8"?>
    <book isbn="0836217462">
     <title>
      Being a Dog Is a Full-Time Job
     </title>
     <author>Charles M. Schulz</author>
     <character>
       <name>Snoopy</name>
       <friend-of>Peppermint Patty</friend-of>
       <since>1950-10-04</since>
       <qualification>
        extroverted beagle
       </qualification>
     </character>
     <character>
       <name>Peppermint Patty</name>
       <since>1966-08-22</since>
       <qualification>bold, brash and tomboyish</qualification>
     </character>
    </book>

    An XML schema is to be constructed, which will validate this document and other similar documents. Make notes on the elements etc that this document contains, and record any significant factors about them.

    The datatypes of the above elements are:
    • title - string
    • author - string
    • charater - string
    • name - string
    • friend-of - string
    • since - date
    • qualification - string
    Attribute "isbn" is of string datatype.
    1:  <?xml version="1.0"?>  
    2:  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">  
    3:    <xs:element name="book">  
    4:     <xs:complexType>  
    5:       <xs:sequence>  
    6:        <xs:element name="title" type="xs:string"/>  
    7:        <xs:element name="author" type="xs:string" maxOccurs="unbounded"/>  
    8:         <xs:element name="character" type="xs:string" maxOccurs="unbounded">  
    9:          <xs:complexType>  
    10:           <xs:sequence>  
    11:             <xs:element name="name" type="xs:string"/>  
    12:             <xs:element name="friend-of" type="xs:string" minOccurs="0"/>  
    13:             <xs:element name="since" type="xs:string"/>  
    14:             <xs:element name="qualification" type="xs:string"/>  
    15:           </xs:sequence>  
    16:          </xs:complexType>  
    17:        </xs:element>  
    18:       </xs:sequence>  
    19:       </xs:attribute name="isbn" type="xs:string" use="required"/>  
    20:     </xs:complexType>  
    21:    </xs:element>  
    22:  </xs:schema>  
    
    The XML schema produced above consists of maxOccurs and minOccurs attributes. In the "character" element and the "author" element, the maxOccurs attribute have been set to "unbounded" because there might be many occurences of the "character" element. The element "friend-of" have the minOccurs attribute set to zero because the element is optional.

Question Sheet:

Question Sheet: Lab 10b

Sources:

[1] http://www.w3schools.com/schema/schema_intro.asp
[2] http://www.w3schools.com/schema/schema_example.asp

QUICK QUESTIONS

  1. One of the advantages claimed for the "extended links", that the W3C consortium intended to be part of the XLink language, was that the definition of a particular hyperlink could be located, not in the local resource (the document where the link starts), or the remote resource (the document where the link ends), but in a quite different "third party" document. Why might this be an advantage?

    This might be an advantage because the third-party document is independent from the document that has the link. A linkbase (also known as a link database) is a file that consists of a number of third-party links.[1]
  2. The XLink language provides an attribute for a hyperlink called show – it has several possible values. What is the effect of providing such a link with each of the following attribute values?
    show="replace"
    show="new"
    show="embed"

    Which of these three attribute values is the default?

    The show attribute in the XLink language is used to determine how the object will be displayed. The show attribute consists of the following values:[2]
    • show="new" - This value is used to open the page in a new window;
    • show="replace" - This value is used to replace the current page with the new page;
    • show="embed" - This value is used to put the target inside the current page or inline;
    • show="other" - This value is used to search for an alternative markup inside the page;[3]
    • show="none" - This value contains no instructions.
    The default value of the show attribute is replace.

LONGER QUESTIONS

  1. Here is an XML document:
    <?xml version="1.0"?>
    <!DOCTYPE memo SYSTEM memo.dtd">
    <?xml-stylesheet href="stylesheet02.css" type="text/css"?>
    <memo>
     <heading>memo 1334</heading>
     <date>date: 11 November 09</date>
     <time>time: 09:30</time>
     <sender>from: The Managing Director</sender>
     <addressee>to: Heads of all Departments</addressee>
     <message>I think we should be making wind-turbines. Have a look at this website. Tell me what you think. </message>
    </memo>


    The accompanying .dtd file looks like this:
    <?xml version= "1.0" ?>
    <!DOCTYPE memo [
    <!ELEMENT memo (heading, date, time, sender, addressee, message)>
    <!ELEMENT heading (#PCDATA)>
    <!ELEMENT date (#PCDATA)>
    <!ELEMENT time (#PCDATA)>
    <!ELEMENT sender (#PCDATA)>
    <!ELEMENT addressee (#PCDATA)>
    <!ELEMENT message (#PCDATA)>
    ]>

    At the point where the document says this website, there is supposed to be a hyperlink that
    takes the reader to the website:
    http://engineering.suite101.com/article.cfm/wind_power.

    1. Amend the document, so that the link is in fact there. Make any necessary changes to the .dtd file as well.

      The XML file will look like the following:
        1: <?xml version="1.0"?>    
        2: <!DOCTYPE memo SYSTEM memo.dtd">    
        3: <?xml-stylesheet href="stylesheet02.css" type="text/css"?>    
        4: <memo xmlns:xlink="http://www.w3.org/1999/xlink">    
        5:   <heading>memo 1334</heading>    
        6:   <date>date: 11 November 09</date>    
        7:   <time>time: 09:30</time>    
        8:   <sender>from: The Managing Director</sender>    
        9:   <addressee>to: Heads of all Departments</addressee>    
        10:  <message>I think we should be making wind-turbines. Have a look at <websiteLink xlink:type="simple" xlink:href="http://engineering.suite101.com/article.cfm/wind_power">this website</websiteLink> Tell me what you think. </message>    
        11: </memo>   
      

      The DTD file will look like the following:
       1:  <?xml version= "1.0" ?>   
       2:  <!DOCTYPE memo [   
       3:  <!ELEMENT memo (heading, date, time, sender, addressee, message)>   
       4:  <!ELEMENT heading (#PCDATA)>   
       5:  <!ELEMENT date (#PCDATA)>   
       6:  <!ELEMENT time (#PCDATA)>   
       7:  <!ELEMENT sender (#PCDATA)>   
       8:  <!ELEMENT addressee (#PCDATA)>   
       9:  <!ELEMENT message (#PCDATA)>   
       10: <!ATTLIST memo xmlns:xlink CDATA #FIXED “http://www.w3.org/1999/xlink”>   
       11: <!ATTLIST websiteLink    
       12:    xlink:type (simple | extended) "simple"   
       13:    xlink:href CDATA #REQUIRED>   
       14: ]>   
      
    2. Suppose that the heading of one of the sections in the target website is <A NAME="WE Elec Facts">Wind Energy Electricity Facts</A>, including the tags as shown. What changes would you have to make to the link in the managing director’s memo, to make the hyperlink finish at that point rather than at the wind_power document as a whole?

      To specify a part of a document rather than a whole document, XPointers should be used
      <websiteLink xlink:type="simple"
      xlink:href="http://engineering.suite101.com/article.cfm/wind_power
      #xpointer(name('WE Elec Facts'))">this website</websiteLink>
  2. Here is another XML document:
    <?xml version="1.0"?>
    <!DOCTYPE memo SYSTEM memo.dtd">
    <?xml-stylesheet href="stylesheet02.css" type="text/css"?>
    <memo>
     <heading>memo 1335</heading>
     <date>date: 11 November 09</date>
     <time>time: 09:45</time>
     <sender>from: The Managing Director</sender>
     <addressee>to: Heads of all Departments</addressee>
     <message>I think we should be making solar panels. Have a look at this website. Tell me what you think. </message>
    </memo>

    At the point where the document says this website, there is supposed to be a hyperlink that takes the reader to a suitable website. Find one, and amend the document, so that the link is in fact there. Is it necessary to make any changes to the .dtd file, or can we use the file as you amended it before?

    The <websiteLink> tag will consist the following:
    1:  <websiteLink xlink:type="simple" xlink:href="http://www.solarpages.co.uk/Solar-Panels-Information/">this website</websiteLink>  
    
    The .dtd file that have been amended before can still be used.

Question Sheet:

Question Sheet: Lab 10a

Sources:

[1] Xpath, XLink, XPointer, and XML: a practical guide to Web hyperlinking and transclusion - Pg 61
[2] http://webdesign.about.com/od/xlink/a/how-to-write-xlink.htm
[3] http://www.cafeconleche.org/books/bible2/chapters/ch19.html