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

Modify code to sort by the number of pages rather than by chapter number: <?xml

ID: 3533277 • Letter: M

Question

Modify code to sort by the number of pages rather than by chapter number:


<?xml version="1.0"?>

<!-- Fig. 15.21: sorting.xsl -->

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

<!-- write XML declaration and DOCTYPE DTD information -->

<xsl:output doctype-system="about:legacy-compat" method="html"/>

<!-- match document root -->

-<xsl:template match="/"> -<html> <xsl:apply-templates/> </html> </xsl:template>

<!-- match book -->

-<xsl:template match="book">

<head> <meta charset="utf-8"/>

<link href="style.css" type="text/css" rel="stylesheet"/>

</head>

<body>

<h1><xsl:value-of select="title"/></h1>

<h2>by <xsl:value-of select="author/lastName"/>, <xsl:value-of select="author/firstName"/></h2>

<table> -<xsl:for-each select="chapters/frontMatter/*">

<tr>

<td>

<xsl:value-of select="name()"/> </td>

-<td> ( <xsl:value-of select="@pages"/> pages ) </td>

</tr>

</xsl:for-each>

<xsl:for-each select="chapters/chapter"> <xsl:sort select="@number" order="ascending" data-type="number"/>

<tr>

<td> Chapter <xsl:value-of select="@number"/> </td>

<td> <xsl:value-of select="text()"/> ( <xsl:value-of select="@pages"/> pages ) </td>

</tr>

</xsl:for-each> -<xsl:for-each select="chapters/appendix"> <xsl:sort select="@number" order="ascending" data-type="text"/> -

<tr>

<td> Appendix <xsl:value-of select="@number"/> </td>

<td> <xsl:value-of select="text()"/> ( <xsl:value-of select="@pages"/> pages ) </td>

</tr> </xsl:for-each>

</table>

<p>Pages: <xsl:variable select="sum(chapters//*/@pages)" name="pagecount"/>

<xsl:value-of select="$pagecount"/>

</p>

<p>Media Type: <xsl:value-of select="media/@type"/></p>

</body>

</xsl:template>

</xsl:stylesheet>


Explanation / Answer


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote