Question

I need help referencing an XML file that serves as a lookup for another XML file using XSL and keys. Instead of just printing the customer ID from the main XML file as shown in the screenshot, I need to also print the customer's first name, last name, etc., as referenced in the supplemental customersxml file. Thank you.

The Good Earth Quality Landscaping and Construction Equipment Rental Current Rentals cust123 cust779 cust381 cust403 cust976

----------------------------------------------------------------------

XSL:

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

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="rentals" select="rentals"/>

<xsl:output method="html"
doctype-system="about:legacy-compat"
encoding="UTF-8"
indent="yes" />

<xsl:template match="/">
<html>
               <head>
                   <title>Current Rentals</title>
               </head>
               <body>
                   <header>
                       <img alt="header" src="tgelogo.png"></img>
                       <h1>Current Rentals</h1>
                       <xsl:for-each select="rentals/rental">
                       <xsl:value-of select="Customer"/><br/>
                       </xsl:for-each>
                   </header>
                   <section></section>
                   <footer></footer>
               </body>
           </html>

</xsl:template>

</xsl:stylesheet>

----------------------------------------------------------------------

Main XML:

<?xml version="1.0" encoding="UTF-8"?>
<rentals>
<rental>
<Customer>cust123</Customer>
<Start_Date>2017-07-17</Start_Date>
<Tool>AC295-69</Tool>
<Weeks>0</Weeks>
<Days>2</Days>
</rental>
<rental>
<Customer>cust779</Customer>
<Start_Date>2017-07-17</Start_Date>
<Tool>AC354-50</Tool>
<Weeks>0</Weeks>
<Days>1</Days>
</rental>
<rental>
<Customer>cust381</Customer>
<Start_Date>2017-07-17</Start_Date>
<Tool>FL743-64</Tool>
<Weeks>0</Weeks>
<Days>1</Days>
</rental>
</rentals>

----------------------------------------------------------------------

Customers.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customers>
   <customer custID="cust123">
       <firstName>Manuel</firstName>
       <lastName>Simmons</lastName>
       <street>272 Wells Street</street>
       <city>Shreveport</city>
       <state>LA</state>
       <ZIP>71104</ZIP>
   </customer>
   <customer custID="cust381">
       <firstName>Donald</firstName>
       <lastName>Havens</lastName>
       <street>983 Oconto Boulevard</street>
       <city>Fort Polk</city>
       <state>LA</state>
       <ZIP>71459</ZIP>
   </customer>
   <customer custID="cust779">
       <firstName>Denna</firstName>
       <lastName>Silva</lastName>
       <street>609 Liano Avenue</street>
       <city>Baton Rouge</city>
       <state>LA</state>
       <ZIP>70807</ZIP>
   </customer>
</customers>

0 0
Add a comment Improve this question Transcribed image text
Answer #1

XSL:

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

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="rentals" select="rentals"/>

<xsl:output method="html"
doctype-system="about:legacy-compat"
encoding="UTF-8"
indent="yes" />

<xsl:template match="/">
<html>
               <head>
                   <title>Current Rentals</title>
               </head>
               <body>
                   <header>
                       <img alt="header" src="tgelogo.png"></img>
                       <h1>Current Rentals</h1>

<table border="3" align="center" >

<tr>

<th>Customer</th>

  <th>Start_Date</th>

<th>Tool</th>

<th>Weeks</th>

<th>Days</th>

<th>firstName</th>

<th>lastName</th>

<th>street</th>

<th>city</th>

<th>state</th>

<th>ZIP</th>

</tr>

                       <xsl:for-each select="rentals/rental">

<tr>
<td> <xsl:value-of select="Customer"/><br/> </td>

<td> <xsl:value-of select="firstName"/><br/> </td>

<td> <xsl:value-of select="lastName"/><br/> </td>

<td> <xsl:value-of select="street"/><br/> </td>

  <td> <xsl:value-of select="city"/><br/> </td>

  <td> <xsl:value-of select="state"/><br/> </td>

  <td> <xsl:value-of select="ZIP"/><br/> </td>


                       </xsl:for-each>

</table>
                   </header>
                   <section></section>
                   <footer></footer>
               </body>
           </html>

</xsl:template>

</xsl:stylesheet>

Add a comment
Know the answer?
Add Answer to:
I need help referencing an XML file that serves as a lookup for another XML file using XSL and ke...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Project 2 (Clothing Rental) Fashion Rental is a rental company located in Manhattan, New York, sp...

    Project 2 (Clothing Rental) Fashion Rental is a rental company located in Manhattan, New York, specializing in rental of high end wome en clothing for the fashion industry. Over the past 12 months, her business has experienced tremendous growth due to a boom in the fashion Industry. The business has kept the daily service records in a workbook format and now needs to expand its reporting capabilities to develop a relatio nal database to effect a more functional structure. Fashion...

  • the is my HTML and CSS code. I didn't attach the image or the CSS file...

    the is my HTML and CSS code. I didn't attach the image or the CSS file because of the space limit. two things I wanted to incorporate on this page are to make "MY TOP 3 MUSIC GENRES" blink using javascript and to make the video links autoplay using javascript both should be using javascript requirement: our professor told us not to use <div> or alert. thank you for your help <!DOCTYPE html> <!-- I used w3school for the formatting...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT