Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am new to XML I am not getting this. Any help would be appreciated. Thanks. --

ID: 3699278 • Letter: I

Question

I am new to XML I am not getting this. Any help would be appreciated. Thanks.

----- This is

<?xml version="1.0" encoding="UTF-8" ?>
<!--
   New Perspectives on XML, 3rd Edition
   Tutorial 5
   Tutorial Case

   Denison Public Library XSLT Style Sheet
   Author:
   Date:

   Filename:         library.xsl
   Supporting Files: book.png, dvd.png

-->

<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:output method="html"
      doctype-system="about:legacy-compat"
      encoding="UTF-8"
      indent="yes" />

   <xsl:apply-templates match="items">
   <html>
       <head>
           <title>Denison Public Library</title>
           <link href="libstyles.css"
                  rel="stylesheet"
                  type="text/css" />
       </head>
       <body>
           <header>
               <h1>Denison Public Library</h1>
               <h2>Ennis, Montana</h2>              
           </header>
       <section>
           <h1>Item List</h1>
               item template
              
           <article>
               <h1>title</h1>
               <h2>by: </h2>
               <!--<td>-->
                   <xsl:choose>
                       <xsl:when type="Book" img src="book.png" alt="Book" /> </xsl:when>
                         <xsl:when type="Visual Material" img src="film.png" alt="Film" /> </xsl:when>
                   </xsl:choose>
               <!--</td>       -->
           <p>
               Type:
               <span>
                   <img src="file.png" alt="type" />
               </span>
               </p>
               <xsl:for-each select="itemlist/item/authors">
                   <article>
                       <h1>
                           <xsl:value-of select="author" />
                       </h1>
                   </article>
               </xsl:for-each>
           </article>
       </section>  
       </body>
   </html>
   </xsl:template>

</xsl:stylesheet>

Explanation / Answer

fixed the issue. its working with the below code and xml data...but if we had the complete data it wud have been great.

<?xml version="1.0" encoding="UTF-8" ?>
<!--
New Perspectives on XML, 3rd Edition
Tutorial 5
Tutorial Case

Denison Public Library XSLT Style Sheet
Author:
Date:

Filename: library.xsl
Supporting Files: book.png, dvd.png

-->

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"
doctype-system="about:legacy-compat"
encoding="UTF-8"
indent="yes" />

<xsl:template match="/">
<html>
<head>
<title>Denison Public Library</title>
<link href="libstyles.css"
rel="stylesheet"
type="text/css" />
</head>
<body>
<header>
<h1>Denison Public Library</h1>
<h2>Ennis, Montana</h2>   
</header>
<section>
<h1>Item List</h1>
item template
  
<article>
<h1>title</h1>
<h2>by: </h2>
<!--<td>-->
<xsl:choose>
<xsl:when test="Book"><img src="book.png" alt="Book" /> </xsl:when>
<xsl:when test="Visual Material"><img src="film.png" alt="Film" /> </xsl:when>
</xsl:choose>
<!--</td> -->
<p>
Type:
<span>
<img src="file.png" alt="type" />
</span>
</p>
<xsl:for-each select="itemlist/item/authors">
<article>
<h1>
<xsl:value-of select="author" />
</h1>
</article>
</xsl:for-each>
</article>
</section>   
</body>
</html>
</xsl:template>

</xsl:stylesheet>

And this is how the data should be in XML file.

<itemlist>

<item>

<authors>

<author>A1</author>

<type>Book</type>

</authors>

<authors>

<author>A1</author>

<type>Visual Material</type>

</authors>

</item>

</itemlist>