THIS IS THE .XML FILE
This was provided and I am trying to create the .XSL file to populate the table with this (XML) file's information.
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="sigmod.xsl"?>
<!DOCTYPE SigmodRecord [
<!ELEMENT SigmodRecord (issue)* >
<!ELEMENT issue (volume,number,articles) >
<!ELEMENT volume (#PCDATA)>
<!ELEMENT number (#PCDATA)>
<!ELEMENT articles (article)* >
<!ELEMENT article (title,initPage,endPage,authors) >
<!ELEMENT title (#PCDATA)>
<!ELEMENT initPage (#PCDATA)>
<!ELEMENT endPage (#PCDATA)>
<!ELEMENT authors (author)* >
<!ELEMENT author (#PCDATA)>
<!ATTLIST author position CDATA #IMPLIED>
]>
<SigmodRecord>
<issue>
<volume>11</volume>
<number>1</number>
<articles>
<article>
<title>Annotated Bibliography on Data Design.</title>
<initPage>45</initPage>
<endPage>77</endPage>
<authors>
<author position="00">Anthony I. Wasserman</author>
<author position="01">Karen Botnich</author>
</authors>
</article>
<article>
<title>Architecture of Future Data Base Systems.</title>
<initPage>30</initPage>
<endPage>44</endPage>
<authors>
<author position="00">Lawrence A. Rowe</author>
<author position="01">Michael Stonebraker</author>
</authors>
</article>
<article>
<title>Database Directions III Workshop Review.</title>
<initPage>8</initPage>
<endPage>8</endPage>
<authors>
<author position="00">Tom Cook</author>
</authors>
</article>
</articles>
</issue>
</SigmodRecord>
This is the .XSL file
I am not sure if my Xpath is correct, I'm guessing it isn't and that's why my table won't populate but for some reason I cannot seem to figure it out...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:template match="SigmodRecord">
<html>
<body>
<h2>Articles</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Volume</th>
<th>Number</th>
<th>Title</th>
<th>Start Page</th>
<th>End Page</th>
<th>Page Length</th>
</tr>
<xsl:for-each select="SigmodRecord/issue/articles/article">
<tr>
<td><xsl:value-of select="issue/volume"/></td>
<td><xsl:value-of select="issue/number"/></td>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="initPage"/></td>
<td><xsl:value-of select="endPage"/></td>
<td><xsl:value-of select="((endPage)-(initPage))"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
No comments:
Post a Comment