Universiteit Leiden

Objective


To transform an assigned XML file into HTML using XSLT.

Where to start?

  • From Brightspace, download "DMT_Assignment2.pdf" (in the "Assigments" tab.)
  • Download the "JATS.zip" file which is linked to in this document. Find and extract your assigned XML file, along with the stylesheet article.xsl. For the assignment, you will need to edit "article.xsl". You do NOT need to create blank stylesheet from a template.
  • Transform the article you have been assigned using “article.xsl”. In Oxygen, you first need to configure a transformation scenario. The transformation can be applied by clicking on the button with the tooltip “Run Transformation”. In Blackboard, under the tab “Software” you can find information about other ways in which you can work with XSLT.
  • To do the assignment, you need to make some changes in the "article.xsl file". To see the results of these changes, you need to transform the XML file again using the stylesheet. Every time you make a change, check if the result is what you expected.
  • The comments in "article.xsl" are there to assist you.
  • If you get stuck, consult the XSLT tutorial on bookandbyte.universiteitleiden.nl or ask you questions in a search engine.

The required transformations

The following is a copy of Part A of the assignment, with added indications on where you can find help to code the solution. Use "article.xsl" as your starting point. Note that you need to make seven changes.

1. At the top of the page, in the first <h1> element, add the title of the Article.

See chapter 5: "Selecting text"
Note that the <h1> element with the title is selected in a <xsl:template> with a @match attribute that is set to <front>. To select the title, you need to construct a path to the element contain the title of the article departing from <front>. “front” itself is not included. If you choose “Show View” > “Outline” in Oxygen, this can help you determine the path.  

2. Following the label ‘Publication date’, add the publication date in the format DD-MM-YYYY.

The day, month and year are encoded individually underneath <pub-date>. As for activity (1), you need to explain in the stylesheet how these elements can be reached, with <front> as a starting point.

3. Articles may have multiple authors. Under the header “Author(s)”, add the name(s) of the author(s). If the case of a co-authored article, make sure that each name is displayed. For each name, give the last name, followed by the first name(s). Also provide the institution of the author (encoded in <institution> under <aff>), and, if provided, the email address (in <email> under <aff>). Separate these texts by a line break.


See XSLT Tutorial chapter 6: Iteration

Remember that <xsl:for-each> is an element which changes the context. Within the opening and the closing tag of this element, all the path depart from the element mentioned in the @select attribute after <xsl:for-each>.


4. Under the header “Journal”, add the title of the journal, the volume number and the issue number (if available), the ISSN for the print version (if available), the ISSN for the ePub version (if available), the name of the publisher and the location of the publisher.

One difficulty here is that the <journal-meta> element may contain two separate ISSNs, one for the print version, and one for the ePub version. To be able to select the correct ISSN, you need to add a condition in a set of square brackets:

<xsl:value-of select="journal-meta/issn[@pub-type = 'ppub']"/>

To select the ISSN for the ePub versions, you need to change the value to the right of the equals sign within the square brackets. Before you select the ISSN, however, you need to test whether this element is present. See XSLT tutorial Chaopter 7: Setting conditions.

 
5. Add the abstract under the header “Abstract”


See the instructions under activity (1).

6. Underneath “Contents”, make sure that the titles of all the sections are displayed correctly.

 As you can see, the section titles need to be selected within a <xsl:for-each> element. The @select attribute of this element has been set to <sec>. This element encoded the various sections of the article. Which element underneath <sec> contains the section titles?