Create a key named agentid that matches the agent element


XML Authoring Assignment

Lisa asks you to design another style sheet for her. Many of her clients are not looking for a house in a particular geographic area as much as they are looking for one of a particular style. She wants you to create a new style sheet based on her property data that groups the property report by housing style. She has already created the style sheet for the property report, but she needs your help in grouping the properties.

The property report should also contain information on the real estate agencies and agents handling the properties. Since working on her last project, Lisa has placed all of this information within a single file.You have to extract information from this second source document to complete the report.

1. Using your editor, open homestxt.xml and homestxt.xsl files. Enter your name and the date in the comment section of each ?le, and save them as homes.xml and homes.xsl , respectively.

2. Go to the homes.xml ?le in your editor. Add a processing instruction after the comment section that attaches the homes.xsl style sheet to the document. Close the file, saving your changes.

3. Go to the homes.xsl ?le in your editor, and review the content of the style sheet and the different templates it contains. At the top of the ?le, directly below the opening tag, do the following:

a. Create a variable named agencies that selects the agencies.xml file.

b. Create a key named agentID that matches the agent element, using values of the agentNum attribute to generate the key index.

c. Create a key named ?rmID that matches the ?rm element, using values of the ?rmNum attribute to generate the key index.

d. Create a key named houseStyles that matches the property element, using values of the style element to generate the key index.

4. At the bottom of the style sheet, insert a template with a mode value of styleList that matches the property element. The purpose of this template is to create a list of the different housing styles associated with the properties in the style.xml document. Have the template write the following code:

style (count) |

where id is an ID value generated automatically by the XSLT processor using the generate-id() function, style is the value of the style element, and count is the number of properties that contain that style. ( Hint : Use the key() function and the houseStyles key to retrieve the node set of properties belonging to a particular style, and use the count() function to calculate the number of properties in that node set.)

5. Go to the root template. Within the style_list section after the | character, apply a template of the styleList mode to the step pattern: "listings/property[not(style=preceding::property/style)]" in order to display a list of unique housing styles. Sort the application of the template by order of the style element.

6 Directly below the closing tag in the root template, insert a for-each element using the Muenchian grouping with the location path "//property[generate-id()=generate-id(key(‘houseStyles', style)[1])]" for the select attribute in order to select each housing style. Within the for-each element, add

a. Sort the output by values of the style element.
b. For each unique housing style, write the following code to the result document:

style

where id is an ID value generated automatically by the XSLT processor using the generate-id() function and style is the value of the style element.c. Apply a template for each property belonging to the selected housing style. ( Hint : Use the key() function with the houseStyles key and the value of the style element.) Sort the applied template by the sqfeet element in descending order.

7. Go to the property template. The purpose of this template is to write the HTML code for a web table describing each property. Most of the contents of the table have already been created for you. Your task is to insert the ?rm and agent data into the table in the appropriate cells. Within the table cell following the comment "Place information about the firm here", add the following styles to display information about the listing ?rm in the result document:

a. Declare a variable named fID , containing the value of the ?rm attribute
b. Insert a for-each element, selecting the value of the agencies variable to change the context node to the agencies.xml file.
c. Within the for-each element, write the following ?rm contact information:

name
street
city, state   zip

phone
web

where name , street , city , state , zip , phone , and web are the values of the name, street, city, state, zip, phone, and web elements for the selected firm in the agencies.xml file. ( Hint : Use the key() function with the firmID key and the value of the fID variable to select the appropriate firm element from the agencies.xml file.)

8. Scroll down the web table and, within the table cell directly after the comment "Place information about the agent here", add the following styles:

a. Declare a variable named aID , selecting the value of the agent attribute.

b. Insert a for-each element, selecting the value of the agencies variable in order to change the context node to the agencies.xml file.

Within the for-each element, write the following code to the result document: name
name

phone

email

where name , phone , and email are the values of the name, phone, and email elements for the selected agent in the agencies.xml file.

9. Save your changes to the homes.xsl file.

10. Use your web browser or your XSLT processor to generate the result document. Verify that the property report displays each property grouped by housing style, that the list of housing styles includes a count of the number of each property within each style, that links within the style list jump the browser to the appropriate style section in the report, and that the agent and ?rm data are correctly retrieved from the agencies.xml file.

Attachment:- Attachments.rar

Request for Solution File

Ask an Expert for Answer!!
: Create a key named agentid that matches the agent element
Reference No:- TGS02336753

Expected delivery within 24 Hours