N342 Home Work 4 - Project  Databases/XML/XSL

Modified

Note

The solution is to require IE to check for new versions on every visit to a page. In IE: Tools | Internet Options | Temporary Internet Files | Settings | Every Visit to Page

The following error may occur when accessing XML files downloaded from one computer to another such as the ZIP files for the assignment. Vista (and perhaps XP) blocks access to files, presumably attempting to protect you from using files you have copied to your computer.

Unblock access to individual files by the following:

  1. Open in Windows Explorer the directory containing the file, either the XML file or one referenced by the XML.
  2. Right click on the file and open Properties.
  3. Click Unblock.

The XML page cannot be displayed

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


Access is denied. Error processing resource 'file:///W:/N341/Project/TraderSummaryContent.htm'.

 

Unblock access to all files in a directory by the following:

  1. Download Streams, copy Streams.exe to Windows directory if possible.
  2. To unblock all the files in directory c:\temp and any subdirectories enter:

    Streams –d –s c:\temp

 

Overview 

Homework 4 is a continuation of Homework 3.

 

BuyStock.asp

Places stocks to buy in the Cart. When completed redirects to CartSummary.asp to display the shopping cart contents, no need to write a BuyStockContent.htm style sheet.

The stocks are input on the URL address line from the browser. To buy 10 shares of IBM and 15 shares of Microsoft (symbol is MSFT), the address line would be:

http://www.ius.edu/username/N342/Project/BuyStock.asp?IBM=10&MSFT=15

The stocks and number of shares are placed on the URL line from a form using a GET method. Because we do not know beforehand the number or names of the variables, the Request(variable name) cannot be used. Instead, we can collect stock symbols and shares with the Request.QueryString object.

The following prints out each parameter key and item value. It should be in the Project directory as BuyStock.asp, try executing from the browser with the address line above.

<%@ Language=JScript%>
<%
   var n = Request.QueryString.Count;
   for (i=1; i<=n; i++)
       Response.Write(Request.QueryString.Key(i)+"="+Request.QueryString.Item(i)+"<br>");
%>

The Cart table has fields for: ID, SYMBOL, SHARES, PRICE and BUY.

Each stock in the address line must be placed in the Cart with the ID of the trader, the stock SYMBOL, number of SHARES, PRICE, and BUY=true since the trader is buying.

The fundamental points are:

  1. The key value is a SYMBOL from the Stock table (e.g. Request.QueryString.Key(2)='MSFT').
  2. Each SYMBOL must be SELECTed from the Stock table to determine the PRICE of the stock.
  3. ID, SYMBOL, SHARES, PRICE and BUY fields must be INSERTed into the Cart table. The value of the fields are:
  4. When completed redirect to CartSummary.asp.

Testing - When integrated into the stock trading system, the BuyStock.asp script is executed from a HTML form with method="GET". The URL will include ALL named form inputs, not just those that a significant. Your script should verify, at a minimum, that inputs are non-blank and non-zero before adding to the cart.

For example, the following URL has UAL= and GMC=0; only IBM and MFST stocks should be added to the cart:

Test for empty string in JavaScript by:

Note that no check is made at this time that the trader has sufficient funds to buy stock, checking is performed at cart checkout.

 

SellList.asp and SellListContent.htm

List all the stocks in the Portfolio table for the trader ID and the value of each stock. The script is very similar to Portfolio.asp and testing style sheet can be very similar to TraderSummaryContent.htm file.

To write the SellListContent.htm style sheet, modify the TraderSummaryContent.htm file with the names of the SYMBOL, NAME, SHARES, PRICE, and STOCKVALUE.

The information needed is in two tables so a JOIN is required. Portfolio table holds the trader stock SYMBOL and number of SHARES, Stock table holds the SYMBOL and PRICE. Compute STOCKVALUE as SHARES*PRICE.

The challenge is to write the SQL to SELECT from the two tables based on the common SYMBOL field. Fortunately, what is needed is nearly the same as used in Portfolio.asp. Consult ASP-ADO-XML-XSL discussion on how to Join Database Tables.

 

SellStock.asp

Places stocks to sell in the Cart. The address line only contains SYMBOLs of stocks owned by the trader from the Portfolio table and the number to sell. When completed redirects to CartSummary.asp to display the shopping cart contents, no need to write a SellStockContent.htm style sheet in XSL.

The script is very similar to the BuyStock.asp with the exceptions:

Note that no check is made at this time that the trader has the stock to sell but is performed at cart checkout.

 

Hints

Assignment

Complete:

  1. Buy stocks from those available (BuyStock.asp) and place in shopping cart.
  2. List stocks owned to sell (SellList.asp).
  3. Sell stocks from those owned (SellStock.asp) and place in shopping cart.

Turn in - Due before class on the date listed in the syllabus.

  1. OnCourse Drop Box
    1. Compress the Project folder containing the homework files.
      • In Windows Explorer, right-click on the Project folder.
      • Click Send to then click Compressed (zipped) Folder.
      • Project.zip will be created.
    2. Upload Project.zip to your CSCI N342 OnCourse Drop Box using the Display Name of HW4.
  2. IUS server
    1. Copy to W: drive or FTP to webftp.ius.edu
      • In browser address enter: ftp://webftp.ius.edu
      • Login using your IUS ADS\username and password.
      • Copy the contents of the Project directory onto ftp page.
    2. Test in IE. The Welcome.xml is a default page.
      • In browser address enter: http://www.ius.edu/username/N342/Project/Welcome.xml
  3. Email notification to rwisman@ius.edu with subject: YOUR NAME - N342 HW4 - username