Xml authoring assignment #7 | Computer Science homework help
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 file, and save them as homes.xml and homes.xsl , respectively.
2. Go to the homes.xml file 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 file in your editor, and review the content of the style sheet and the different templates it contains. At the top of the file, 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 firmID that matches the firm element, using values of the firmNum 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:
<a href=”#id”>style</a> (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 </section> 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:
<h2 id=”id”>style</h2>
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 firm 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 firm in the result document:
a. Declare a variable named fID , containing the value of the firm 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 firm contact information:
name <br /> street <br /> city, state   zip <br />
phone <br /> 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 <br />
phone <br />
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 firm data are correctly retrieved from the agencies.xml file.
homestxt.xml
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<!–
New Perspectives on XML, 3rd Edition
Tutorial 7
Review Assignment
Real estate listings
Author: Juliet Mercado
Date: 6/20/2017
Filename: homes.xml
Supporting Files: homes.xsl
–>
<listings>
<property rln=”r317080″ firm=”f102″ agent=”a2140″>
<street>2638 Maple Avenue</street>
<city>Padua</city>
<state>WI</state>
<zip>53701</zip>
<price>229000</price>
<style>2-Story Transitional</style>
<sqfeet>2328</sqfeet>
<bathrooms>2 1/2</bathrooms>
<bedrooms>4</bedrooms>
<garage>2 car, attached</garage>
<age>22</age>
<description>Very nice home on a one block dead end street with woods nearby.
Very special location for quiet and privacy! Home features open floor plan with
large rooms – new patio doors to pretty yard. updates: shingles, vinyl siding,
refrig and dishwasher, garage door. Fireplace in family room flanked by great
built-ins. add first floor laundry and award winning Padua schools.
</description>
</property>
<property rln=”r317081″ firm=”f103″ agent=”a2141″>
<street>3014 Allen Lane</street>
<city>Broxton</city>
<state>WI</state>
<zip>53987</zip>
<price>314200</price>
<style>2-Story Transitional</style>
<sqfeet>2752</sqfeet>
<bathrooms>2 1/2</bathrooms>
<bedrooms>4</bedrooms>
<garage>3 car, attached</garage>
<age>15</age>
<description>Surround fireplace. Quality thru-out! Call lister for completion
date. Wow! Expect to be impressed with this new 4-bdrm transitional home! All
the upgrades for the distinguished buyer. Large entertaining kitchen w/corian counters,
birch cabinets, maple flr and trim, lg work island. Pella windows everywhere. 200amp,
ge profile appliances, whirlpool bath, kohler plumbing, trayed master,
exposed ll w/8ft9in ceilings. 15-yr waterproof warrty, tile surround fireplace.
Quality thru-out! Call lister for completion date.
</description>
</property>
<property rln=”r317082″ firm=”f104″ agent=”a2142″>
<street>505 Brandit Road</street>
<city>Cutler</city>
<state>WI</state>
<zip>55709</zip>
<price>305200</price>
<style>2-Story Colonial</style>
<sqfeet>2900</sqfeet>
<bathrooms>2</bathrooms>
<bedrooms>4</bedrooms>
<garage>2 car, attached</garage>
<age>17</age>
<description>A picture perfect home in a fantastic location. 4 bedrooms, formal
dining and living room, a family room with wood burning fireplace and a lower level
rec room. Close to Padua and Argyle with 1.67 acres of breathing space. Wood
floors throughout, tile entry, 6 panel doors, 2 car garage and a home warranty so you
can buy with confidence!
</description>
</property>
<property rln=”r317083″ firm=”f105″ agent=”a2143″>
<street>77 East Creek Road</street>
<city>Argyle</city>
<state>WI</state>
<zip>56981</zip>
<price>290000</price>
<style>2-Story Colonial</style>
<sqfeet>3169</sqfeet>
<bathrooms>2</bathrooms>
<bedrooms>4</bedrooms>
<garage>3 or more car, attached</garage>
<age>14</age>
<description>Quality built 2-Story on wooded lot adjacent to park. Large entry with
tile flr. Formal lr and dr w/chair rail and crown molding. Eat-in kitchen with breakfast
bar and patio door that opens to a lrg deck. Fam rm w/built-in bookcases and woodburning
fp. 4 bdrms on 2nd flr. Master w/walk-in closet and 3/4 bath. Fin ll has rec rm and
office/exercise rm. Lots of space in the unfinished lower level. 3 car tandem garage.
Home warranty included.
</description>
</property>
<property rln=”r317084″ firm=”f102″ agent=”a2144″>
<street>41 Mohawk Street</street>
<city>Stratmore</city>
<state>WI</state>
<zip>58105</zip>
<price>241900</price>
<style>1-Story Ranch</style>
<sqfeet>1710</sqfeet>
<bathrooms>2</bathrooms>
<bedrooms>3</bedrooms>
<garage>2 car, attached</garage>
<age>12</age>
<description>Spectacular new ranch w/ extra deep yard! Vaulted great room has gas frplc.
Spacious kitch w/pantry and brkfst bar. 1st flr laundry rm, walk-in closet and double
vanity bath in master. Br 3 set up as a study w/french doors walkout ll w/over
1200 sq ft for future finish! 14’x10′ deck. Landscaping. Also an air-air exchanger for
a healthier home w/hepa filter, 20 yr warranty tuff n dri water proofing, too! 6 panel
doors, oak trim. Ready for move in!
</description>
</property>
<property rln=”r317085″ firm=”f102″ agent=”a2144″>
<street>88 Atkins Avenue</street>
<city>Padua</city>
<state>WI</state>
<zip>53704</zip>
<price>305200</price>
<style>1-Story Ranch</style>
<sqfeet>2800</sqfeet>
<bathrooms>2</bathrooms>
<bedrooms>4</bedrooms>
<garage>3 car, attached</garage>
<age>New</age>
<description>Expect to be impressed with this stunning ranch home situated on wooded
lot backing to city bike trail. Home features include maple flrs, painted trim, spacious
kitchen with 2 pantries and island with breakfast bar, huge great room with gorgeous view.
Tray clg in dining, large master wp suite with tray ceiling, 10×18 deck, 12×12 patio, walkout
ll, prof landscaping, air exchanger for healthier home and so much more!!
</description>
</property>
<property rln=”r317086″ firm=”f103″ agent=”a2145″>
<street>3810 Stamford Lane</street>
<city>Oseola</city>
<state>WI</state>
<zip>53414</zip>
<price>315400</price>
<style>2-Story Transitional</style>
<sqfeet>2751</sqfeet>
<bathrooms>2 1/2</bathrooms>
<bedrooms>4</bedrooms>
<garage>3 or more car, attached</garage>
<age>2</age>
<description>Stunning custom built 2-Story 4 br home features 1st floor large master suite
w/wic, dual vanitites, whirlpool tub and separate shower. Large great rm w/gas fp, formal dr/lr.
Large kitchen w/center island, planning desk, and dinette. Hardwood flrs cover 2-Story foyer,
dinette, kitchen and powder rm. Cathedral ceiling highlights open flr plan. Maple cabinets,
solid oak trim throughout. Job relo-highly motivated seller. All measurements approx.
</description>
</property>
<property rln=”r317087″ firm=”f102″ agent=”a2140″>
<street>57 East Raulston Lane</street>
<city>Fenmore</city>
<state>WI</state>
<zip>56729</zip>
<price>329900</price>
<style>2-Story Colonial</style>
<sqfeet>2770</sqfeet>
<bathrooms>2 1/2</bathrooms>
<bedrooms>4</bedrooms>
<garage>3 car, attached</garage>
<age>8</age>
<description>Wonderful 2-Story colonial in super area. Homestead builder quality with
custom cabinetry, oak trim, 6 panel doors, crown molding, elegant 2-Story foyer.
4 season sunroom overlooks huge backyard. Walkin closets.2 stairways to partially
finished basement with lots of storage/expansion area. Nicely decorated and landscaped.
Master bath with whirlpool! Fireplace in sunken family room. Huge
kitchen with island and desk. Nice! Call seller direct and save!
</description>
</property>
<property rln=”r317088″ firm=”f103″ agent=”a2146″>
<street>14 Haywood Street</street>
<city>Cutler</city>
<state>WI</state>
<zip>55710</zip>
<price>319500</price>
<style>2-Story Other</style>
<sqfeet>2565</sqfeet>
<bathrooms>2 1/2</bathrooms>
<bedrooms>4</bedrooms>
<garage>3 car, attached</garage>
<age>New</age>
<description>New 2-Story by Eton homes 4 bedroom, 9′ ceilings 1st floor wood
floors kitchen and foyer, formal dining room, 1st floor study and laundy room, exposed
lower level w/ 8′ 6′ ceilings. Large landscaped yard, 3 car tandom garage.
</description>
</property>
<property rln=”r317089″ firm=”f105″ agent=”a2143″>
<street>515 Lawrence Avenue</street>
<city>Padua</city>
<state>WI</state>
<zip>53706</zip>
<price>274500</price>
<style>2-Story Other</style>
<sqfeet>2100</sqfeet>
<bathrooms>2 1/2</bathrooms>
<bedrooms>4</bedrooms>
<garage>2 car, attached</garage>
<age>New</age>
<description>Spacious 4 bedroom 2-Story home featuring 9′ ceilings first floor,
wood floors kitchen and foyer, great room with gas fireplace, large kitchen with
dinette, first floor laundry room, exposed lower level with 8’6 ceilings for future
living area, 2 car tandem garage.
</description>
</property>
<property rln=”r317090″ firm=”f104″ agent=”a2147″>
<street>9 Alston Court</street>
<city>Cutler</city>
<state>WI</state>
<zip>55712</zip>
<price>361500</price>
<style>2-Story Transitional</style>
<sqfeet>3360</sqfeet>
<bathrooms>3</bathrooms>
<bedrooms>4</bedrooms>
<garage>3 or more car, attached</garage>
<age>9</age>
<description>Great curb appeal in this 9 yr old transitional w/2-Story entry,
tile flr. Formal lr and dr w/12′ ceilings. Beautiful oak cabinetry w/center island,
wet bar and dinette. Patio door opens to cobblestone patio. Fr w/gas fp. 2nd flr w/3
bdrms. Double french doors leads to master suite w/walk-in shower, soaking tub and walk-in
closet. Finished ll w/perfect in-law suite. Nicely landscaped yard w/inground
sprinkler system.
</description>
</property>
<property rln=”r317091″ firm=”f105″ agent=”a2143″>
<street>3211 Stamford Lane</street>
<city>Oseola</city>
<state>WI</state>
<zip>53414</zip>
<price>285200</price>
<style>Multilevel Contemporary</style>
<sqfeet>2911</sqfeet>
<bathrooms>2 1/2</bathrooms>
<bedrooms>3</bedrooms>
<garage>2 car, attached</garage>
<age>7</age>
<description>Expect a beautiful surprise when you walk into this contemporary home.
The 3 bdrm, 2 1/2 bath home is filled with personality. Home offers formal dining,
office, rec room, seperate master suite, mst ba has whrlpool tub. The sunroom (14×19)
opens up to the fenced-in back yard which is a national hemerocallis garden. Location
is unbeatable, backyard is next to preschool park and schools are minutes away. Slr will
be removing some plants.
</description>
</property>
</listings>
homestxt.xsl
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<!–
New Perspectives on XML, 3rd Edition
Tutorial 7
Review Assignment
Real Estate Listings Style Sheet
Author: Juliet Mercado
Date: 6/20/2017
Filename: homes.xsl
Supporting Files:
–>
<xsl:stylesheet version=”1.0″
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”>
<xsl:output method=”html”
doctype-system=”about:legacy-compat”
encoding=”UTF-8″
indent=”yes” />
<xsl:template match=”https://www.sweetstudy.com/”>
<html>
<head>
<title>Real Estate Listings</title>
<link href=”https://www.sweetstudy.com/content/homestyles.css” rel=”stylesheet” type=”text/css” />
</head>
<body>
<div id=”wrap”>
<header>
<img src=”https://www.sweetstudy.com/content/homelogo.png” alt=”Bowline Realty” />
</header>
<h1>New Listings</h1>
<section id=”style_list”>
|
</section>
</div>
</body>
</html>
</xsl:template>
<xsl:template match=”property”>
<table class=”head” cellpadding=”2″>
<tr>
<td rowspan=”9″ class=”description”>
<xsl:value-of select=”description” />
</td>
<th>Listing #</th>
<td><xsl:value-of select=”@rln” /></td>
<th>Real Estate Agency</th>
</tr>
<tr>
<th>Price</th>
<td><xsl:value-of select=”format-number(price,’$#,##0′)” /></td>
<!– Place information about the firm here –>
<td rowspan=”4″>
</td>
</tr>
<tr>
<th>Address</th>
<td>
<xsl:value-of select=”street” /><br />
<xsl:value-of select=”city” />, <xsl:value-of select=”state” />
<xsl:text> </xsl:text><xsl:value-of select=”zip” />
</td>
</tr>
<tr>
<th>Style</th>
<td><xsl:value-of select=”style” /></td>
</tr>
<tr>
<th>Age</th>
<td><xsl:value-of select=”age” /></td>
</tr>
<tr>
<th>Sq. Feet</th>
<td><xsl:value-of select=”sqfeet” /></td>
<th>Agent</th>
</tr>
<tr>
<th>Baths</th>
<td><xsl:value-of select=”bathrooms” /></td>
<!– Place information about the agent here –>
<td rowspan=”3″>
</td>
</tr>
<tr>
<th>Bedrooms</th>
<td><xsl:value-of select=”bedrooms” /></td>
</tr>
<tr>
<th>Garage</th>
<td><xsl:value-of select=”garage” /></td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
agencies.xml
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<!–
New Perspectives on XML, 3rd Edition
Tutorial 7
Review Assignment
List of agents
Filename: agencies.xml
–>
<firms>
<firm firmNum=”f101″>
<name>Acer Realty</name>
<street>400 Hawthorne Avenue</street>
<city>Longmont</city>
<state>CO</state>
<zip>80504</zip>
<phone>(303) 555-9092</phone>
<web>http://www.example.com/acerrealty</web>
<agents>
<agent agentNum=”a2148″>
<name>Gary Ubersetzing</name>
<phone>(303) 555-9091</phone>
<email>[email protected]/acerrealty</email>
</agent>
<agent agentNum=”a2149″>
<name>Kari Lawrence</name>
<phone>(970) 555-8799</phone>
<email>[email protected]/acerrealty</email>
</agent>
<agent agentNum=”a2150″>
<name>Patty Becker</name>
<phone>(303) 555-0933</phone>
<email>[email protected]/acerrealty</email>
</agent>
</agents>
</firm>
<firm firmNum=”f102″>
<name>Toffer Realty</name>
<street>311 Allen Court</street>
<city>Berthoud</city>
<state>CO</state>
<zip>80513</zip>
<phone>(970) 555-5081</phone>
<web>http://www.example.com/tofferrealty</web>
<agents>
<agent agentNum=”a2140″>
<name>Karen Fawkes</name>
<phone>(303) 555-3414</phone>
<email>[email protected]/tofferrealty</email>
</agent>
<agent agentNum=”a2144″>
<name>Peter Grumwald</name>
<phone>(970) 555-3419</phone>
<email>[email protected]/tofferrealty</email>
</agent>
</agents>
</firm>
<firm firmNum=”f103″>
<name>Carson Homes</name>
<street>981 Frontage Road</street>
<city>Longmont</city>
<state>CO</state>
<zip>80503</zip>
<phone>(303) 555-0912</phone>
<web>http://www.example.com/carsonhomes</web>
<agents>
<agent agentNum=”a2141″>
<name>Linda DeJesus</name>
<phone>(970) 555-4140</phone>
<email>[email protected]/carsonhomes</email>
</agent>
<agent agentNum=”a2146″>
<name>Ian Oppelganger</name>
<phone>(303) 555-5439</phone>
<email>[email protected]/carsonhomes</email>
</agent>
<agent agentNum=”a2145″>
<name>Cynthia Cho</name>
<phone>(970) 555-5432</phone>
<email>[email protected]/carsonhomes</email>
</agent>
</agents>
</firm>
<firm firmNum=”f104″>
<name>The Rawlings Company</name>
<street>678 Grimble Street</street>
<city>Lyons</city>
<state>CO</state>
<zip>80540</zip>
<phone>(970) 555-6780</phone>
<web>http://www.example.com/rawlingscompany</web>
<agents>
<agent agentNum=”a2142″>
<name>Lawrence Rao</name>
<phone>(970) 555-8580</phone>
<email>[email protected]/rawlingscompany</email>
</agent>
<agent agentNum=”a2147″>
<name>Allan Lee</name>
<phone>(303) 555-8900</phone>
<email>[email protected]/rawlingscompany</email>
</agent>
</agents>
</firm>
<firm firmNum=”f105″>
<name>Premier Realty</name>
<street>87 Crawford Court</street>
<city>Fort Lupton</city>
<state>CO</state>
<zip>80622</zip>
<phone>(303) 555-8915</phone>
<web>http://www.example.com/premierrealty</web>
<agents>
<agent agentNum=”a2143″>
<name>Michael Menschen</name>
<phone>(303) 555-8918</phone>
<email>[email protected]/premierrealty</email>
</agent>
</agents>
</firm>
</firms>
homestyle.css
/*
New Perspectives on XML, 3rd Edition
Tutorial 7
Review Assignment
Bowline Realty style sheet
Filename: homestyles.css
Supporting Files: none
*/
/* Default styles */
* {
margin: 0px;
}
header, section, article {
display: block;
}
/* Body styles */
body {
font-family: Verdana, Geneva, sans-serif;
background-color: #e3dbaf;
}
div#wrap {
background-color: white;
margin: 0px auto;
width: 1200px;
border-left: 2px solid rgb(151, 151, 151);
border-right: 2px solid rgb(151, 151, 151);
box-shadow: rgb(51, 51, 51) 10px 0px 30px,
rgb(51, 51, 51) -10px 0px 30px;
padding-bottom: 50px;
}
div#wrap > h1 {
font-size: 2.5em;
letter-spacing: 0.12em;
font-weight: normal;
color: #6bd51b;
text-shadow: black 1px 1px 1px;
padding: 15px 0px;
font-family: ‘Century Gothic’, sans-serif;
text-align: left;
margin-left: 100px;
}
#style_list {
margin: 0px auto;
width: 80%;
text-align: center;
background-color: #e3dbaf;
vertical-align: bottom;
padding-top: 20px;
padding-bottom: 20px;
border-top: 3px solid #b9ac55;
border-bottom: 3px solid #b9ac55;
font-size: 0.8em;
}
#style_list a {
color: rgb(51, 51, 51);
}
div#wrap > h2 {
margin: 25px 0px 5px 100px;
font-weight: normal;
font-size: 1.9em;
letter-spacing: 0.08em;
font-family: ‘Century Gothic’, sans-serif;
text-align: left;
}
table.head {
border-collapse: collapse;
margin: 5px 170px 30px 170px;
border: 2px solid #c3b451;
}
table.head th {
font-size: 0.8em;
text-align: left;
background-color: #b4ef87;
border: 1px solid rgb(91, 91, 91);
font-weight: normal;
vertical-align: top;
padding: 3px;
width: 100px;
}
table.head td {
font-size: 0.8em;
text-align: left;
vertical-align: top;
border: 1px solid rgb(91, 91, 91);
padding: 3px;
width: 300px;
}
table.head td.description {
font-family: ‘Courier New’, monospace;
padding: 20px;
background-color: rgb(231, 231, 231);
}