Figures 9.5 and 9.6 illustrate the difference between the two DTDs. Figure
9.5 is the structure created so far—it is a complex structure with several
levels of nesting. Figure 9.6, on the other hand, has a flat structure.
Writing with Flexibility in Mind
Figure 9.5: The default structure Figure 9.6: The new structure
Figures 9.7 and 9.8 show the difference when selecting one or the other out-
put format in the browser.
Figure 9.7: Default output format Figure 9.8: New output format
Calling XSLT
The major difference between this application and the previous one is the
exportProduct() function. exportProduct() calls makeXML() to generate the
XML document. Depending on the user choice, it may apply an XSLT style
sheet to the result.
function exportProduct(form,xml,xslt)
var selected = form.format.selectedIndex,
format = form.format.options[selected].value;
if(format == “default”)
form.output.value = makeXML();

Get XML by Example now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.