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

1. Create a web page in which the user is allowed to select the page\'s backgrou

ID: 3759491 • Letter: 1

Question

1. Create a web page in which the user is allowed to select the page's background color and whether the page uses serif fonts. Then change the body element's style attribute accordingly.

Gray background

White background

Sans-serif text

Serif text

If the user onclicks any of the options, the webpage will turn into that format. For example, if the user clicks "Gray backgound", the background color of the webpage will be Gray. If the user clicks Serif-text, the text in the web page will be in Serif text.

That's it! You do not have to consider the user to really edit the webpage. Please see the attached webpage image.

2. Modify the follwoing figure to sort bu the number of pages rather than by chapter number. Save the modified document as sorting_byPage.xsl

ISBN - by , ( pages ) Chapter ( pages ) Appendix ( pages ) Pages: Media Type:

Explanation / Answer

1. Create a web page in which the user is allowed to select the page's background color and whether the page uses serif fonts. Then change the body element's style attribute accordingly.

<html>

<head>
<script type = "text/javascript">

function changeBGC(color)
{
document.bgColor = color;
}

function changeFontFamily(fontFam)
{

document.getElementById("para").style.fontFamily = fontFam;

}

</script>
<meta charset = "utf-8">
<title>Webpage</title>
</head>
<body>
<a href="#">Click white</a>
<a href="#">Click Grey</a>
<br>
<a href="#"> Make it SansSerif!!!</a>
<a href="#"> Make it Serif!!!</a>
<p id='para'> Sample Text
<br>
</body>
</html>

2. Modify the follwoing figure to sort bu the number of pages rather than by chapter number. Save the modified document as sorting_byPage.xsl

<?xml version="1.0"?>

<!--sorting_byPage.xsl -->
<!-- Transformation of book information into XHTML -->
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<!-- write XML declaration and DOCTYPE DTD information -->
<xsl:output method="html" omit-xml-declaration="no"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />


<!-- match document root -->
<xsl:template match="/">
   <html xmlns="http://www.w3.org/1999/xhtml">
       <xsl:apply-templates />
   </html>
</xsl:template>


<!-- match book -->
<xsl:template match="book">
   <head>
       <title>ISBN <xsl:value-of select="@isbn" /> -
           <xsl:value-of select="title" />
       </title>
   </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="@pages" data-type="number" order="descending" />
   <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" data-type="text" order="ascending" />
<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>


<br /> <p>Pages:
   <xsl:variable name="pagecount"
       select="sum(chapters//*/@pages)" />
   <xsl:value-of select="$pagecount" />
   <br />Media Type: <xsl:value-of select="media/@type" /></p>
</body>
</xsl:template>
</xsl:stylesheet>