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.

QUICK QUESTIONS

  1. Suppose that a CSS file is used to determine how an XML document will appear when viewed in a browser. Suppose that the CSS file contains two rules, one dictating that a particular piece of text will appear in bold type, the other dictating that it will not. What will happen?

    If the CSS is written as specified, that is, the first one dictating that a particular piece of text will appear in bold type and the second one dictating that it will not; the text will not be bold. This is because the latest definition will be applied.
  2. An XML document contains the sentence "The grand old Duke of York, he had 10000 men." Would XPath be able to extract the piece of data "10000" from such a document?

    XPath is used to select nodes from the XML documents using path expressions[1], and therefore could not extract data inside the elements. One possible way to extract the piece of data "10000" is by using the substring() function.[2]
      substring(source-string, start-position, number-of-characters)
      substring("The grand old Duke of York, he had 10000 men.", 35, 5)

LONGER QUESTIONS

  1. Download the following file from the OasisPlus CMT3315 web page for Unit 10 Learning Materials: 'chemElements2.xml'
    However, the file is supposed to be displayed as a table, with five columns. The top row of the table is supposed to be headings for the 5 columns: this row is supposed to have a distinctive background colour. The next 99 rows are supposed to show details of 99 of the chemical elements – these rows are also supposed to have a distinctive background colour, different from the heading.

    1. Open JCreator and open the chemElements2.xml file in it. Add a line to the document that will cause it to be viewed (in the browser) in conjunction with a CSS file called stylesheet01.css

      <?xml-stylesheet href="stylesheet01.css" type="text/css"?>
    2. Write the file, stylesheet01.css, and store it in the same folder. The content of this CSS file should cause the table to appear in the Mozilla Firefox browser, as described above. Make your own decisions about suitable typefaces, borders, background colours, alignment, etc.

      1:  chemElements {text-align:center;display:table; border: thin dotted black; width:50%; margin-left:25%; margin-top:5px; font-family:Arial; font-size: 12px; color:#181818;}  
      2:  tableHead {display:table-row;font-weight:bold;}  
      3:  anumHead, nameHead, symbolHead, mptHead, bptHead{display:table-cell; padding: 5px; border: thin dotted black; background-color:#666633;}  
      4:  element {display:table-row; background-color: #E0E0E0;}  
      5:  anum, name, symbol, mp, bp{display:table-cell; padding: 5px; border: thin dotted black;}  
      
      The above CSS will produce the following table:
    3. chemElements2.xml

  2. Consider the following XML document:
    <?xml version= "1.0" ?>
    <!DOCTYPE book SYSTEM "musicList.dtd">
    <?xml-stylesheet href="stylesheet04.css" type="text/css"?>
    <musicList
    number="2" title="miscellaneous CDs"
    xmlns:cdlist="http://middlesex_press.co.uk/CDcollection ">
      <cd number="711">
       <title>The Best of Ivor Cutler</title >
       <artist>Ivor Cutler</artist >
       <tracks total="19"/>
       <cdlist:refnum> POL767 </ cdlist:refnum >
      </cd>
      <cd number="712">
       <title>Penderecki’s First Symphony</title >
       <artist>Middlesex Symphony Orchestra</artist >
       <tracks total="5"/>
       <cdlist:refnum> DGM987 </ cdlist:refnum >
      </cd>
      <cd number="713">
       <title>Penderecki’s Last Symphony</title >
       <artist>Middlesex Symphony Orchestra</artist >
       <cdlist:refnum> DGM988 </ cdlist:refnum >
       <tracks total="5"/>
      </cd>
      <cd number="714">
       <title>Boris the Spider Rides Again</title >
       <artist>The Renegades</artist >
       <cdlist:refnum> CHR328 </ cdlist:refnum >
       <tracks total="19"/>
      </cd>
    </musicList>

    Provide XPath expressions which will do the following:

    1. Select all the elements subordinate to the root node.
    2. musicList

    3. Select all track elements that have a total attribute with the value of 5.
    4. //tracks[@total=5]

    5. Select all elements that contain the word "Penderecki" in their title.
    6. /musicList/cd/title[contains(., 'Penderecki')]

    7. Select any elements that have titles with greater than 11 characters.
    8. /musicList/cd/title[string-length() > 11]

    9. Select all the siblings of the first cd element
    10. /musicList/cd[1]/*

Question Sheet:

Question Sheet: Lab 9

Sources:

[1] http://www.w3schools.com/xpath/xpath_syntax.asp
[2] XPath: navigating XML with XPath 1.0 and 2.0 : kick start - Pg 119