In this assignment, we define a
color specification as either a single
<color>
element
(for those items that come in only one color), or
a <color-list>
(for items that come in multiple colors),
or an <sku>
element
(for items that have no color).
The reason that we have this strange setup for colors, color-lists, and SKUs is that every item in the catalog must have an SKU (which stands for Stock Keeping Unit, and is an inventory code). Here are the cases that these elements cover:
An item doesn't have a color (e.g., "Diet Soda 12-pack") In that case,
it needs an <sku>
element to keep track of inventory.
An item comes in only one color (e.g., a whiteboard). It will have
one <color>
element, and that element has a required
sku
attribute to keep track of the inventory for that
item. The hex
attribute is optional, and is used only if
its color happens to be representable as a color code like you find in
HTML (#ffca03, etc.)
An item comes in many colors (for example,
ballpoint pens). You now need a
<color-list>
which has individual
<color>
elements. Each of them has a different
sku
attribute, so that we can keep track of how many blue
pens we've sold vs. black pens vs. red pens. Each one also has an
optional hex
attribute in case its color happens to be
representable as an HTML color code.