One option is to match just the root node. The template is only activated
once. This simple template can be useful in many situations. In many more
cases this is the basis of a more complex arrangement.
Notice that we have added some structure to our stock node. The items
are now organised into a hierachy which reflects the departmental
structure.
Notice that the price is being pulled in from the XML file.
Change the colour of the price to make it blue instead of red.
Change the price of the burgers to 62
Change the advert so that it is now about item 2 from
department 1 - "Vile Sausages - less than 5% fat free!" You can put
item[2] in place of item to select the appropriate
price.
Change the advert so that it shows the price of the item with
BarCode E6 - "Soggy Crisps: Cheese and Onion".
Question 2: Explicit recursion.
Having matched a node the translator can be made to process
it's children with the <xsl:apply-templates/> instruction.
This allows us to embed generated text in a more flexible way.
The template shown treats each of the three levels (stock,
department and item) differently.
Add the fields BarCode and price to the lowest level
template.
Change the div nodes to table components so that a table
is given for each department. You will be able to ditch
the top level template.