Part 1: Using an XML Schema You will find an XML Schema for a simple tool catalo
ID: 3815706 • Letter: P
Question
Part 1: Using an XML Schema You will find an XML Schema for a simple tool catalog here: http://weblab.kennesaw.edu/toolschema.xsd Read the schema to find out what XML elements are expected and what they contain. (Hint: The comments are your friend. If you've forgotten what the URLs for the tool pictures look like, they are lab 2.
Write an XML file containing information for at least three types of tools. To get you started, I've done the hard part:
Place your XML file on the server as l6p1.xml. Put a link to your XML file on your index page.
To validate your XML, navigate to this address: https://devutilsonline.com/xml/validate Paste the URL of your XML file in the left-hand box, which is labeled XML URL. Paste a link to the XSD file: http://weblab.kennesaw.edu/toolschema.xsd into the right-hand box, labeled XSD URL. Then click the "Validate XML" button at the bottom left. Correct any errors the validator finds.
Part 2; Validating form data: Make a copy of the order form from lab exercise 4 and name it l6p2.php. Remove the JavaScript code to calculate the total price. If you used anything other than a plain text box for quantities, change the quantity inputs to type="text". (The goal of this part of the assignment is for you to use regular expressions to validate text.)
Add JavaScript code to produce an error message and suppress submission of the form if any quantity field contains non-numeric data. (It's OK for a quantity to be empty, but if it's non-empty, it must have only numbers.) Add an action= attribute to your <form> tag to submit the form to http://weblab.kennesaw.edu/formtest.php. Test that the form is submitted correctly when the quantities are numeric or empty, and that an error message is produced otherwise. (Regular expressions are your friend. Anything that's not a digit is bad. What is the predefined class for non-digits?)
Add to your index page a link to your new order form.
As with the previous assignment, the goal is to learn to validate with JavaScript. The use of an input element with type "number" or anything similar will earn a zero on this part of the assignment. You must use JavaScript for the validation.
Part 3; Using PHP to generate forms: To your order form from Part 2, add input elements for customer name and address if they're not already there. The "state" part of the address must be a select element(also called a "pulldown menu") to allow the person placing the order to choose his or her state. Don't type all fifty states, but supply at least Georgia, Alabama and Florida. Put the names of the states in an PHP array and use PHP code to create the drop-down dynamically. (This will still be named l6p2.php; you're just adding to something you've already tested.)
You will find an example of creating a select element for states in the class slides covering HTML forms. You are going to create the drop-down dynamically, and not by hard-coding it. This part of the assignment is a fair example of something you might do with PHP in "real life." Instead of an array, you would use a database call, so if we suddenly add another state to the U.S. (or your company suddenly adds another state to its service area) a change to the database automatically (and immediately) changes what people see in the form. For this assignment, you're loading states from an array. We'll get them from a database in the next assignment.
Explanation / Answer
XML:
<?xml version="1.0" encoding="utf-8"?>
<toolCatalog xmlns="http://weblab.kennesaw.edu/toolSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://weblab.kennesaw.edu/toolSchema
http://weblab.kennesaw.edu/toolschema.xsd">
<toolPackage>
<!-- put the XML for the first kind of tool package here -->
<type>Spanners</type>
<picLocation>http://weblab.kennesaw.edu/toolSchema/pic1.jpg</picLocation>
<weight>145.6</weight>
<price>50.00</price>
</toolPackage>
<toolPackage>
<!-- put the XML for the first kind of tool package here -->
<type>Hammers</type>
<picLocation>http://weblab.kennesaw.edu/toolSchema/pic2.jpg</picLocation>
<weight>120.8</weight>
<price>60.00</price>
</toolPackage>
<toolPackage>
<!-- put the XML for the first kind of tool package here -->
<type>Nails</type>
<picLocation>http://weblab.kennesaw.edu/toolSchema/pic3.jpg</picLocation>
<weight>12.8</weight>
<price>6.00</price>
</toolPackage>
</toolCatalog>
Share lab exercise 4 for other parts
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.