﻿<?xml version="1.0" encoding="UTF-8"?>

<!-- First, we anounce this is a stylesheet. -->


<xsl:stylesheet version="2.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<!-- Then we anounce this is some HTML code. -->

  <html>
  <body>

<!-- Here, we make a basic HTML table and give the columns titles. -->

    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Journal</th>
	<th>Volume</th>
	<th>Issue</th>
	<th>Year</th>
	<th>Article Title</th>
	<th>Primary Author</th>
      </tr>

<!-- Here, we extract XML data into table rows using XPATH to tell the stylesheet where to find the XML elements/data. The 'for each' syntax has to do with repeating this over and over until all the XML data is displayed. -->

      <xsl:for-each select="PubmedArticleSet/PubmedArticle/MedlineCitation/Article">
      <tr>
      <td><xsl:value-of select="Journal/Title" /></td>
	<td><xsl:value-of select="Journal/JournalIssue/Volume" /></td>
	<td><xsl:value-of select="Journal/JournalIssue/Issue" /></td>
	<td><xsl:value-of select="Journal/JournalIssue/PubDate/Year" /></td>
        <td><xsl:value-of select="ArticleTitle" /></td>
        <td><xsl:value-of select="AuthorList/Author/LastName" />, <xsl:value-of select="AuthorList/Author/Initials" /></td>
      </tr>

</xsl:for-each>
    </table>

<!-- Here, we end the HTML code and finally the XML stylesheet. -->

  </body>
  </html>
</xsl:template>
</xsl:stylesheet>


