Add an output element to indicate to the xslt processor


XML Authoring Assignment

Rafael Garcia has worked with the stock report you generated and has made a few modi?cations 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 ?le, 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 ?le 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 ?le should be in HTML5 format.

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


Portfolio Stocks




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



Last Updated: date at time

Chesterton Financial


Portfolio Stocks



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 tag, insert the following HTML code three times, one for each of three categories of stock (Industrials, Utilities, and Transportation):


Category


stock template

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 speci?ed 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:
















Current Open High Low Volume
current open high low volume

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:






















Web Address link
52wk. Range low - high
P/E pe_ratio
EPS eps
Div. and Yield dividend (yield)

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:


today
summary

stock name (symbol)


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 and closing tags in the stock template, use a choose structure to insert the following h2 heading and paragraph:


change
current


description

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.

Attachment:- Attachment.rar

Request for Solution File

Ask an Expert for Answer!!
: Add an output element to indicate to the xslt processor
Reference No:- TGS02315396

Expected delivery within 24 Hours