• Graphics Exercises
  • Security Exercises
  • XML Exercise
  • XML Exercise
  • DOM/SAX Exercises
  • Regular Expression exercises
  • Unicode questions

    Graphics Exercises

    1) A company wants to generate ER diagrams from their databases and wants to publish them on the web. What graphics format could be used to display the diagrams on web pages? What software tools would be involved in creating the diagrams: list all required tools starting with the database software.

    2) Write SVG-like tags for a stop sign. Since you don't have the SVG documentation available, you are allowed to invent the tag names and attributes used in the tags. You can leave the attribute values empty apart from the colour attributes. Include only the tags for the stop sign, not the general tags that are at the start of every SVG document.

    Security Exercises

    1) Below are two adjacent lines from a server-side script.
    $user = param("user"); 
    $db->prepare("SELECT $user from this_table;"); 
    
    Is this code secure? Provide a reason for your answer.

    2) An inexperienced web developer installs a script from CPAN on a webserver. Because of this web developer's action, a few weeks later the security of the webserver is compromised. What is a likely possibility for the break-in? How did the hacker find out about the security problem on the server?

    3) In PHP the directive "register globals" means that all sorts of variables are automatically inserted into a script. For example, if "register globals" is "on", a variable "username" from an HTML form, can simply be printed as "$username" without using "$_REQUEST[]". In early versions of PHP, the default for "register globals" was set to "on". But starting with version 4.2, the default for "register globals" has been set to "off". Provide one argument for why "register globals" should be "on" and one argument for why it is better to turn this directive off. If PHP were to require all variables to be initialised, would it then be secure to leave "register globals" on?

    XML Exercise

    Create an XML format for a cooking recipe. It should contain: If an ingredient is used in a cooking instruction, this relationship should be marked-up.

    The example used in this exercise should be: "Cooking pasta with tomato sauce".

    XML Exercise

    Which of the following XML documents are well-formed:

    1) <module></module>

    2) <module><lecture></lecture></lecture> <lecture></module>

    3) <module><lecture></lecture><lecture/> <practical /></module>

    4) <module> </lecture><lecture/><practical></module>

    5) <module><lecture><slide Nr="1"/></lecture> </module>

    6) <module><lecture><slide Nr=1></lecture> </slide></module>

    7) <module> <lecture> <slide Nr="1"/> <image><jpg/></image> </lecture>
    <practical><slide Nr="2" size="12" > </slide> </practical> </module>

    8) <module><lecture>First lesson with <exercise> One</exercise> </lecture></module>

    9) <module><lecture><lecture> </lecture></lecture></module>

    10) <module><lecture>This is a square bracket: &#60; </lecture></module>

    11) <module>C & IT</module>

    12) <html><h3>Hello<p> World! </h3></html>

    13) <html><img src="file.gif"></html>

    14) <html><font color=blue>Hello</font></html>

    DOM/SAX Exercises

    With respect to an XHTML document, write the DOM/SAX statements that retrieve ...
    1. all level 3 headings
    2. all URLs that are linked to
    3. the link text of the A tags
    4. all child nodes of the first paragraph
    5. all child nodes of the second paragraph
    6. all attributes and their values of an image tag
    Optional: outline a pseudocode sequence that parses a complete XHTML document and stores it in a tree data structure.

    Regular Expression exercises

    Write a regular expression for
    1. email addresses
    2. phone numbers (with area code)
    3. punctuation marks: ?, !, .
    4. a three word sentence
    5. a string that contains at least one word character and at least one non-word character
      (note: the pipe symbol "|" means "or")
    6. nouns in a sentence (i.e. words preceded by "the" or "a")
    7. a sequence of 0's and 1's that is exactly 10 characters long
    8. all filenames other than ones with extension ".txt"
    9. a word that is repeated (e.g. "the the")
    Write the split/implode statements that split a sentence into words and then join the words with a comma between.

    XML processing with regular expressions:
    (Note: "+?" means "any number of characters, but as little as possible")

    1. level 3 headings
    2. URLs that are linked to
    3. the link text of the A tags
    4. all attributes and their values of an image tag

    Unicode questions

    1. What is the Unicode code for happy faces? What is the HTML numeric character reference for happy faces?
    2. Can users define their own Unicode characters (for things such as a company logo)?
    3. What is the difference between Unicode and UTF8?
    4. How much more space is required to represent ASCII characters in UTF32 compared to UTF8? What about characters outside the basic multilingual plane?
    5. Are fonts, spell checkers and formatting instructions part of Unicode?
    6. There is a one-to-one correspondence between which two out of these three:
      code point, glyph, code element.
    7. In future versions of the Unicode standard, will any of the existing code points be reassigned for new purposes?