O'Reilly logo

XML and Java™ from scratch by Nicholas Chase

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Shopping Cart—AddToOrder.java

We can take each of these items individually, because that's how they'll be experienced by the user. In this chapter, we'll add an item to the user's shopping cart. To do that, we need him or her to click a link that includes the product_id, so we know which product to add. (We'll take care of the rest of the order process in Chapter 6, “Adjusting Inventory: Using Namespaces and More About DOM.”) Let's add an “Add To Order” link to the product page, as in Listing 5.1.

Listing 5.1. productpage.xsl: The Add To Order Link
...
38:  <br />
39:  <xsl:if test="inventory[@location='showroom']">
40:    <p>Also available in our stores!</p>
41:  </xsl:if>
42:  <hr />
43:  <xsl:element name="a">
					44: <xsl:attribute name="href">AddToOrder?addProduct_id=<xsl: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required