XML/XSL 2-phase example: using JavaScript to extract lists ...



XML/XSL 2-phase example: using JavaScript to extract lists from an xml file and then allow selection from the lists

The example consists of the following files

chooselist.html

books.xml

preparelists4fix.xsl

display.js

displayitemsbycat.xsl

The books.xml is an xml file of book elements, each containing 1 or more author elements, a title element, a publisher element and a year element. The first file: chooselist.html presents the list of child elements, that is author, title, publisher, year.

The user clicks on one of these. The javascript uses the choice to transform the books.xml file using the preparelists4fix.xsl file, with one parameter passed to the xsl file. The parameter is one of 'author', 'title', 'publisher', or 'year'. This transformation creates an html file that references display.js as an external script. The javascript in display.js is the familiar code for setting up a transformation of xml by xsl, this time with two parameters. The xml file is books.xml (again) and the xsl file is displayitemsbycat.xsl. Examples of the two parameters would be 'author' and 'Meyer' or 'publisher' and 'Allyn and Bacon'.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download