Assignments Data Integration 0

Handing In Assignments

You must hand in by using git

Hand In by git

  • Create an empty repo on bitbucket.org, gitlab.com, or github.com,
  • git push your local repo to the above remote repo.
  • For node assignments please put the line(s)

    node_modules/

    into your .gitignore file.

Send a mail to with:

  • The word 'handin <subjectname>' in the subject line of your mail
  • The url of your repo(s).

Assignment XML.0.0

First write the xml document:

Example 39.1. letter.xml
<?xml version="1.0" encoding="UTF-8"?>
<emails>
    <email>
        <to>Mum</to>
        <from>Porky</from>
        <subject>Greetings</subject>
        <message>Hello Mums, could you PLEASE send some more money</message>
    </email>
</emails>

Here follows the first XSLT, key it into your editor:

Example 39.2. letter0.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:output method="text"/>
   
  <!-- 1st step -->
  <xsl:template match="/emails/email">
    <xsl:apply-templates select="*"/>
  </xsl:template>
  
  <!-- 2nd step -->
  <xsl:template match="from">
    From: <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="subject">
    Subject: <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="message">
    Message: <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="to">
    To: <xsl:apply-templates/>
  </xsl:template>

</xsl:stylesheet>

Key in both documents and display them separately in your browser. When you have done that, add the following line as line 2 of the xml file above. Then display the altered xml file in the browser with the http protocol, ie not file:///

<?xml-stylesheet type="text/xsl" href="./letter0.xsl"?>

Then write the following, different, stylesheet document, aka xsl-document.

Example 39.3. letter1.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns="http://www.w3.org/1999/xhtml"
    version="1.0">
  <xsl:output method="xml"/>
  
  <!-- 1st step -->
  <xsl:template match="/emails/email">
    <html>
      <head><title>Letter</title></head>
      <body><xsl:apply-templates/></body>
    </html>
  </xsl:template>
  
  <xsl:template match="to">
    <b>To: </b><xsl:apply-templates/><br />
  </xsl:template>
  <xsl:template match="from">
    <b>From: </b><xsl:apply-templates/><br />
  </xsl:template>
  <xsl:template match="subject">
    <b>Subject: </b><xsl:apply-templates/><br />
  </xsl:template>
  <xsl:template match="message">
    <b>Message: </b><xsl:apply-templates/><br />
  </xsl:template>

</xsl:stylesheet>

That sheet will transform the XML document to html. Apply a reference to that stylesheet instead in your xml document, and check again in the browser.

Check out the results. Learn from your typing errors, and possibly do some experiments.

Assignment XML.0.1

Try to think of creating notes when listening to a lecture, or a presentation. Then think of an XML format that might hold those notes. It could be context, date, lecturer, headline, notes etc.

Write an xml file lecturenotes.xml with tags corresponding to your ideas. Put imaginary notes into the file from at least two different lectures, each containing at least two notes.

Assignment XML.0.2

Write each of the following, and test in your browser before submitting. No CSS in this assignment.

  1. Write countries.xml containing an XML representation of a couple of countries from the world database.
  2. Write cities.xml containing an XML representation of a couple of cities from the world database.
  3. Write languages.xml containing an XML representation of a couple of countrylanguages from the world database.
  4. Write continents.xml containing an XML representation of the continents from the world database.
  5. Write governmentforms.xml containing an XML representation of a couple of governmentforms from the world database.