Question details

XML Authoring Assignment 5
$ 12.00

Teacher is very picky, document must have all of these things

 

Rafael Garcia has worked with the stock report you generated and has made a few modifications to the source document. Rafael has added a few more elements providing information on each stock’s high and low value over the previous year, the stock’s P/E ratio, earnings per share (EPS), dividend, and yield. He’s also included the URL to the company’s website. Rafael wants to try a new design, in which these new stock values appear in a table alongside a description of the stock. He also wants to show the current stock value and whether it’s rising, falling, or remaining level, which is to be prominently displayed below the company name. Figure 5-38 shows a preview of the revised content and layout of the report. 

 

Rafael has already created the CSS style sheet for this web page, but he needs you to create the XSLT style sheet, which will generate the HTML code used in the report. Because creating a style sheet can be complicated, it is strongly recommended that you save your changes and generate the result document as you complete each step below to check on your progress and detect any problems early. Complete the following: 

 

1. Using your text editor, open the portfoliotxt.xml and portfoliotxt.xsl files. Enter your name and the date in the comment section of each file, and save them as portfolio.xml and portfolio.xsl , respectively.

 

2. Go to the portfolio.xml file in your text editor. Take some time to review the content of the file and its structure. Add a processing instruction after the comment section that attaches the portfolio.xsl style sheet to this XML document. Close the file, saving your changes.

 

3. Go to the portfolio.xsl file in your text editor. Below the comment section, set up this document as an XSLT style sheet by adding a stylesheet root element and declaring the XSLT namespace using the namespace prefix xsl.

 

4. Add an output element to indicate to the XSLT processor that the transformed file should be in HTML5 format. 

 

 5. Create a root template and, within that template, enter the following HTML code:

<html>

  <head>

     <title>Portfolio Stocks</title>

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

      </head>

<body>

</body>

</html>

 

6. Directly after the opening <body> tag in the root template, insert the following code:

 <header>

   <section>

      Last Updated: date at time

</section>

<h1>Chesterton Financial</h1>

<h2>Portfolio Stocks</h2>

</header>

where date and time are the values of the date and time elements from the source document using the XSLT value-of elements. 

 

 7. Directly below the closing </header>  tag, insert the following HTML code three times, one for each of three categories of stock (Industrials, Utilities, and Transportation):

 <section>

    <h1>Category</h1>

       stock template

</section>

where Category is either Industrials, Utilities, or Transportation, and stock template applies the template for elements from the portfolio/stock location path for stocks of the specified category. Sort the applied templates in alphabetical order by stock name. 

 

8. Create a template for the today element, and then, within the template, enter the following HTML code: 

<table>

  <tr>

    <th>Current</th>

    <th>Open</th>

    <th>High</th>

    <th>Low</th>

    <th>Volume</th>

</tr>

 

<tr>

    <td>current</td>

    <td>open</td>

    <td>high</td>

    <td>low</td>

    <td>volume</td>

    </tr>

</table>

 where current , open , high , low , and volume are the values of the current, open, high, low, and vol attributes using the XSLT value-of element. 

 

 9. Create a template for the summary element, and then, within the template, enter the following HTML code: 

<table>

   <tr>

      <th>Web Address</th>

      <td><a href="link">link</a></td>

   </tr>

 

<tr>

    <th>52wk. Range</th>

    <td>low - high</td>

</tr>

 

<tr>

   <th>P/E</th>

   <td>pe_ratio</td>

</tr>

 

<tr>

   <th>EPS</th>

   <td>eps</td>

</tr>

 

<tr>

   <th>Div. and Yield</th>

   <td>dividend (yield)</td>

</tr>

</table>

 where link , low , high , pe_ratio , eps , dividend , and yield are the values of the corresponding elements from the source document using the XSLT value-of element. 

 

 10 Create a template for the stock element and, within the template, enter the following HTML code:

<article>

   today

   summary

   <h1>stock name (symbol)</h1>

</article> 

 where today and summary apply the today and summary templates, stock name is the name of the stock, and symbol is the value of the symbol attribute using the XSLT value-of element. 

 

11 Directly between the closing </h1> and closing </article> tags in the stock template, use a choose structure to insert the following h2 heading and paragraph: 

<h2 class="change">

    <img src="change.png" alt="change" />

    current

</h2>

<p>description</p>

where change has the value “up”, “down”, or “same” depending on whether the value of the current attribute is less than, greater than, or equal to the open attribute; current is the value of the current attribute; and description is the value of the description element. Note that the current and open attributes must be referenced from within the today element. Be sure to replace the HTML code with the proper value of expressions.

 

12 Save your changes to the portfolio.xsl file

 

13 Generate your result document using either an XML editor or your web browser. Verify that the layout matches what is shown in Figure 5-38 and that each link in the summary table jumps the user to the corresponding stock’s website. 

 

portfolio.css

/*

   New Perspectives on XML, 3rd Edition

   Tutorial 5

   Review Assignment

 

   Chesterton Financial Style Sheet

  

 

   Filename:         portfolio.css

   Supporting Files: none

 

*/

 

/* Default styles */

 

* {

   margin: 0px;

   list-style: none;

}

 

header, section, article {

   display: block;

}

 

 

 

/* Body styles */

body {

   background-color: white;

   font-family: Verdana, Geneva, sans-serif;

   margin: 10px auto;

   width: 75%;

   max-width: 800px;

}

 

/* Header styles */

header section {

   border: 1px dotted rgb(51, 51, 51);

   -moz-border-radius: 10px;

   -webkit-border-radius: 10px;

   border-radius: 10px;

 

   font-size: 0.7em;

   color: rgb(191, 91, 91);

   float: right;

   padding: 4px;

   margin-top: 5px;

   text-align: right;

}

 

header {

   font-family: "Times New Roman", serif;

   margin-bottom: 20px;

}

 

header h1 {

   font-size: 2.8em;

   font-weight: normal;

   text-shadow: rgb(111, 111, 111) 5px 5px 8px;

}

 

header h2 {

   font-size: 2.3em;

   font-weight: normal;

   color: rgb(211, 211, 211);

   text-shadow: rgb(0, 0, 0) 1px 1px 0px;

}

 

body > section {

   border: 3px solid rgb(51, 51, 51);

   -moz-border-radius: 40px;

   -webkit-border-radius: 40px;

   border-radius: 40px;

 

   clear: right;

   margin: 10px 0px;

}

 

body > section > h1 {

   background-color: transparent;

   border-bottom: 3px solid rgb(51, 51, 51);

   color: rgb(101, 101, 101);

   font-weight: normal;

   font-size: 1.6em;

   padding: 5px 0px;

   text-indent: 40px;

}

 

body > section > article {

   clear: left;

   margin: 25px 25px 50px 25px;

}

 

article > h1 {

   font-weight: normal;

   font-size: 1.3em;

   margin: 0px 0px 0px 42%;

}

 

article > h2 {

   margin-left: 42%;

}

 

article > h2.up {

   color: green;

}

 

article > h2.down {

   color: red;

}

 

article > h2.same {

   color: orange;

}

 

 

article > p {

   font-size: 0.85em;

   margin: 0px 0px 0px 42%;

   max-width: 50%;

}

 

 

table {

   border-collapse: collapse;

   clear: left;

   float: left;

   margin: 10px 10px 0px 0px;

   width: 40%;

}

 

article table:last-of-type th {

   text-align: left;

   width: 35%;

}

 

td, th {

   border: 1px solid rgb(191, 191, 191);

   font-weight: normal;

   font-size: 0.7em;

   padding: 3px;

}

 

td {

   text-align: right;

}

 

th {

   background-color: rgb(101, 101, 101);

   color: white;

}

 

 

 

portfoliotxt.xsl

<?xml version="1.0" encoding="UTF-8" ?>

<!--

   New Perspectives on XML, 3rd Edition

   Tutorial 5

   Review Assignment

 

   Chesterton Financial XSL Style Sheet

   Author: 

   Date:   

 

   Filename:         portfolio.xsl

   Supporting Files: down.png, same.png, portfolio.css, up.png

 

-->

 

<?xml version="1.0" encoding="UTF-8" ?>

<!--

   New Perspectives on XML 3rd Edition

   Tutorial 5

   Review Assignment

 

   Chesterton Financial Stock Information

   Author: 

   Date:   

 

   Filename:         portfolio.xml

   Supporting Files: down.png, same.png, portfolio.css, portfolio.xsl, up.png

 

-->

 

 

portfoliotxt.xml

<portfolio>

 

   <author>Rafael Garcia</author>

   <date>4/17/2017</date>

   <time>13:17</time>

 

   <stock>

      <sName symbol="BA">Boeing Company</sName>

      <description>The Boeing Company engages in the design, development, manufacture, sale, and support 

                   of commercial jetliners, military aircraft, satellites, missile defense, 

                   human space flight, and launch systems and services worldwide. It also offers aviation 

                   services support, aircraft modifications, spares, training, maintenance documents, 

                   and technical advice to commercial and government customers. Its financing portfolio 

                   consists of equipment under operating leases, finance leases, notes and other 

                   receivables, assets held for sale or re-lease, and investments. The Boeing Company 

                   was founded in 1916 and is based in Chicago, Illinois.

      </description>

      <category>Industrials</category>

      <summary>

         <link>http://www.boeing.com</link>

         <high>133.99</high>

         <low>69.30</low>

         <pe_ratio>23.59</pe_ratio>

         <eps>5.63</eps>

         <dividend>1.94</dividend>

         <yield>1.50%</yield>

      </summary>

      <today open="125.68" high="125.72" low="124.81" current="125.68" vol="6274500" />

   </stock>

 

   <stock>

      <sName symbol="HPQ">Hewlett-Packard Company</sName>

      <description>Hewlett-Packard Company provides products, technologies, software, solutions, and 

                   services to individual consumers, small-and medium-sized businesses, and large 

                   enterprises, including customers in the government, health, and education sectors 

                   worldwide. Its Software segment offers enterprise information management solutions 

                   for structured and unstructured data, IT management software, and appliance 

                   deployment models. The company was founded in 1939 and is headquartered in 

                   Palo Alto, California.

      </description>

      <category>Industrials</category>

      <summary>

         <link>http://www.hp.com</link>

         <high>27.78</high>

         <low>11.35</low>

         <pe_ratio>N/A</pe_ratio>

         <eps>-1.63</eps>

         <dividend>0.58</dividend>

         <yield>2.20%</yield>

      </summary>

      <today open="23.78" high="25.15" low="23.78" current="23.78" vol="15922600" />

   </stock>

 

   <stock>

      <sName symbol="LUV">Southwest Airlines Corporation</sName>

      <description>Southwest Airlines Co. operates passenger airlines that provide scheduled air 

                   transportation services in the United States. It serves 97 destinations in 41 states, 

                   the District of Columbia, and the Commonwealth of Puerto Rico, as well as 6 

                   near-international countries. The company was founded in 1967 and is headquartered 

                   in Dallas, Texas.

      </description>

      <category>Transportation</category>

      <summary>

         <link>http://www.southwest.com</link>

         <high>18.13</high>

         <low>8.70</low>

         <pe_ratio>20.85</pe_ratio>

         <eps>0.86</eps>

         <dividend>0.16</dividend>

         <yield>0.90%</yield>

      </summary>

      <today open="17.21" high="17.94" low="16.77" current="17.73" vol="6554700" />

   </stock>

 

   <stock>

      <sName symbol="ED">Consolidated Edison Company of New York, Inc.</sName>

      <description>Consolidated Edison, Inc. engages in regulated electric, gas, and steam delivery 

                   businesses. The company provides electric services to approximately 3.3 million 

                   customers in New York City and Westchester County; gas to approximately 1.1 million 

                   customers in Manhattan, the Bronx and parts of Queens, and Westchester County; and 

                   steam to approximately 1,717 customers in parts of Manhattan. In addition, the company 

                   engages in the sale and related hedging of electricity to wholesale and retail customers.

                   Consolidated Edison, Inc. was founded in 1884 and is based in New York, New York.

      </description>

      <category>Utilities</category>

      <summary>

         <link>http://www.conedison.com</link>

         <high>64.03</high>

         <low>53.63</low>

         <pe_ratio>17.10</pe_ratio>

         <eps>3.43</eps>

         <dividend>2.46</dividend>

         <yield>4.20%</yield>

      </summary>

      <today open="59.15" high="59.89" low="59.03" current="59.89" vol="1298000" />

   </stock>

 

   <stock>

      <sName symbol="AA">Aluminum Company of America</sName>

      <description>Alcoa Inc. engages in the production and management of primary aluminum, 

                   fabricated aluminum, and alumina. Its products are used in aircraft, automobiles, 

                   commercial transportation, packaging, building and construction, oil and gas, 

                   defense, consumer electronics, and industrial applications. Alcoa Inc. was founded 

                   in 1888 and is based in New York, New York.

      </description>

      <category>Industrials</category>

      <summary>

         <link>http://www.alcoa.com</link>

         <high>9.97</high>

         <low>7.63</low>

         <pe_ratio>36.07</pe_ratio>

         <eps>0.28</eps>

         <dividend>0.12</dividend>

         <yield>1.30%</yield>

      </summary>

      <today open="9.39" high="9.56" low="9.32" current="9.48" vol="16815260" />

   </stock>

 

   <stock>

      <sName symbol="AEP">American Electric Power Company, Incorporated</sName>

      <description>American Electric Power Company, Inc., a public utility holding company, engages 

                   in the generation, transmission, and distribution of electric power to retail 

                   customers. The company generates electricity using coal and lignite, natural gas, 

                   nuclear energy, and hydroelectric energy. It operates primarily in the states of 

                   Arkansas, Indiana, Kentucky, Louisiana, Michigan, Ohio, Oklahoma, Tennessee, 

                   Texas, Virginia, and West Virginia. American Electric Power Company, Inc. was founded 

                   in 1906 and is headquartered in Columbus, Ohio.

      </description>

      <category>Utilities</category>

      <summary>

         <link>http://www.aep.com</link>

         <high>51.60</high>

         <low>40.56</low>

         <pe_ratio>19.86</pe_ratio>

         <eps>2.38</eps>

         <dividend>2.00</dividend>

         <yield>4.30%</yield>

      </summary>

      <today open="46.92" high="47.15" low="46.25" current="46.25" vol="20315100" />

   </stock>

 

   <stock>

      <sName symbol="CNI">Canadian National Railway Company</sName>

      <description>Canadian National Railway Company engages in rail and related transportation business 

                   in North America. It transports various goods, including petroleum and chemicals, 

                   grain and fertilizers, coal, metals and minerals, forest products, intermodal, and 

                   automotive products. The company operates a network of approximately 20,100 route miles 

                   of track that spans Canada and mid-America. The company was founded in 1922 and is 

                   headquartered in Montreal, Canada.

      </description>

      <category>Transportation</category>

      <summary>

         <link>http://www.cn.ca</link>

         <high>112.27</high>

         <low>83.83</low>

         <pe_ratio>17.95</pe_ratio>

         <eps>6.18</eps>

         <dividend>0.82</dividend>

         <yield>0.70%</yield>

      </summary>

      <today open="110.02" high="111.15" low="109.59" current="110.21" vol="573400" />

   </stock>

 

   <stock>

      <sName symbol="CVX">Chevron Corporation </sName>

      <description>Chevron Corporation engages in petroleum, chemicals, mining, power generation, and 

                   energy operations worldwide. The Upstream segment is involved in the exploration, 

                   development, and production of crude oil and natural gas. The Downstream segment engages 

                   in refining crude oil into petroleum products; marketing crude oil and refined products. 

                   The company is also involved in coal and molybdenum mining operations. The company was 

                   founded in 1879 and is headquartered in San Ramon, California.

      </description>

      <category>Industrials</category>

      <summary>

         <link>http://www.chevron.com</link>

         <high>127.83</high>

         <low>100.66</low>

         <pe_ratio>9.66</pe_ratio>

         <eps>12.23</eps>

         <dividend>4.00</dividend>

         <yield>3.40%</yield>

      </summary>

      <today open="120.81" high="121.57" low="120.68" current="121.21" vol="8235300" />

   </stock>

 

   <stock>

      <sName symbol="DAL">Delta Air Lines Inc.</sName>

      <description>Delta Air Lines, Inc. provides scheduled air transportation for passengers and cargo in 

                   the United States and internationally. The company sells its tickets through various 

                   distribution channels, including telephone reservations, and online travel agencies. 

                   Its also provides aircraft maintenance, repair, and overhaul services for other aviation 

                   and airline customers. The company was founded in 1924 and is headquartered in 

                   Atlanta, Georgia.

      </description>

      <category>Transportation</category>

      <summary>

         <link>http://www.southwest.com</link>

         <high>27.79</high>

         <low>9.21</low>

         <pe_ratio>11.37</pe_ratio>

         <eps>2.42</eps>

         <dividend>0.24</dividend>

         <yield>0.90%</yield>

      </summary>

      <today open="26.07" high="26.35" low="25.89" current="25.89" vol="10321500" />

   </stock>

 

   <stock>

      <sName symbol="MPC">Marathon Petroleum Corporation</sName>

      <description>Marathon Petroleum Corporation engages in refining, transporting, and marketing petroleum 

                   products primarily in the United States. The company owns and operates seven 

                   refineries in the Gulf Coast and Midwest regions of the United States. The company 

                   also transports crude oil and other feedstocks to its refineries and other locations.

                   The company is headquartered in Findlay, Ohio.

      </description>

      <category>Industrials</category>

      <summary>

         <link>http://www.marathonpetroleum.com</link>

         <high>92.73</high>

         <low>52.65</low>

         <pe_ratio>10.46</pe_ratio>

         <eps>6.86</eps>

         <dividend>1.68</dividend>

         <yield>2.40%</yield>

      </summary>

      <today open="71.28" high="71.28" low="70.17" current="70.91" vol="2550200" />

   </stock>

 

   <stock>

      <sName symbol="PPL">PPL Resources Incorporated</sName>

      <description>PPL Corporation, an energy and utility holding company, engages in the generation, 

                   transmission, distribution, and sale of electricity to wholesale and retail customers 

                   in the United States and the United Kingdom. The company develops renewable energy 

                   projects; and provides energy-related products and services to commercial and 

                   industrial customers. PPL Corporation was founded in 1920 and is headquartered in 

                   Allentown, Pennsylvania.

      </description>

      <category>Utilities</category>

      <summary>

         <link>http://www.pplweb.com</link>

         <high>33.55</high>

         <low>27.74</low>

         <pe_ratio>12.30</pe_ratio>

         <eps>2.51</eps>

         <dividend>1.47</dividend>

         <yield>4.80%</yield>

      </summary>

      <today open="31.28" high="31.28" low="30.17" current="30.91" vol="4655200" />

   </stock>

 

   <stock>

      <sName symbol="R">Ryder System, Incorporated</sName>

      <description>Ryder System, Inc. provides transportation and supply chain management solutions. 

                   It also offers fleet support services, such as fuel, insurance, safety, administration, 

                   environmental management, and information technology services. Ryder System, Inc. serves 

                   customers operating in various industries, such as automotive, food service, electronics, 

                   transportation, consumer packaged goods, grocery, lumber and wood products, and home 

                   furnishings. The company was founded in 1933 and is based in Miami, Florida.

      </description>

      <category>Transportation</category>

      <summary>

         <link>http://www.ryder.com</link>

         <high>67.07</high>

         <low>42.78</low>

         <pe_ratio>15.38</pe_ratio>

         <eps>4.36</eps>

         <dividend>1.36</dividend>

         <yield>2.10%</yield>

      </summary>

      <today open="66.73" high="66.81" low="65.44" current="65.89" vol="763900" />

   </stock>

 

   <stock>

      <sName symbol="T">ATT Corporation</sName>

      <description>ATT Inc. provides telecommunications services to consumers, businesses, and other

                  providers in the United States and internationally. The company operates in three 

                  segments: Wireless, Wireline, and Other. The Wireless segment offers various wireless 

                  voice and data communication services. The Wireline segment provides data services

                  and network integration. The Other segment provides application management, security 

                  services, and satellite video services. The company was founded in 1983 and is based 

                  in Dallas, Texas.

      </description>

      <category>Industrials</category>

      <summary>

         <link>http://www.att.com</link>

         <high>39.00</high>

         <low>32.71</low>

         <pe_ratio>27.91</pe_ratio>

         <eps>1.31</eps>

         <dividend>1.80</dividend>

         <yield>5.00%</yield>

      </summary>

      <today open="36.18" high="36.24" low="35.14" current="35.78" vol="19065800" />

   </stock>

 

   <stock>

      <sName symbol="UNP">Union Pacific Corporation</sName>

      <description>Union Pacific Corporation provides rail transportation services in North America. 

                   The company offers freight transportation services for agricultural products, 

                   food, and beverage products; and automotive products. It also provides transportation 

                   services for petrochemicals. In addition, the company offers freight transportation 

                   services for industrial products and construction products. Union Pacific Corporation 

                   was founded in 1862 and is headquartered in Omaha, Nebraska.

      </description>

      <category>Transportation</category>

      <summary>

         <link>http://www.up.com</link>

         <high>165.18</high>

         <low>116.06</low>

         <pe_ratio>16.95</pe_ratio>

         <eps>9.07</eps>

         <dividend>3.16</dividend>

         <yield>2.10%</yield>

      </summary>

      <today open="151.58" high="151.89" low="149.78" current="150.23" vol="1714000" />

   </stock>

 

   <stock>

      <sName symbol="WEC">Wisconsin Energy Corporation</sName>

      <description>Wisconsin Energy Corporation generates and distributes electric energy, as well as 

                  distributes natural gas. The company provides electric utility services to customers 

                  in the mining, paper, foundry, food products, and machinery production industries.

                  It also generates, distributes, and sells steam. The company was founded in 1981 and 

                  is headquartered in Milwaukee, Wisconsin.

      </description>

      <category>Utilities</category>

      <summary>

         <link>http://www.wisconsinenergy.com</link>

         <high>45.00</high>

         <low>36.01</low>

         <pe_ratio>18.39</pe_ratio>

         <eps>2.31</eps>

         <dividend>1.53</dividend>

         <yield>3.60%</yield>

      </summary>

      <today open="42.81" high="43.14" low="42.81" current="42.93" vol="1252000" />

 

Available solutions