Ian's books
| CPU Magazine
XSLT Part 9: XSLT and Namespaces
As described in the September 2003 issue of
CPU - Computer Power User
magazine.
Examples and Bonus Materials
A) Downloadable ZIP File
- Why not download the
whole lot as a ZIP file -- sep03.zip --
and install them on your own machine?
B) The Raw Data
- test.xml -- The simple example XML data
document used in the article -- this contains the raw data that
is transformed into HTML.
A plain text listing is available at:
test.txt. Note that the test.xml file
contains a processing instruction to reference the external
stylesheet transform.xsl (see below). Mozilla and/or
Netscape 7 load this stylesheet and displays the results of
the transformation. Internet Explorer 5 adn greater also load
this external stylesheet, but with unpredictable results.
- test-attrs.xml -- The simple example XML data
document used in the article -- this is equivalent to test.xml
above, but contains a processing instruction referencing a different
external stylesheet transform-attr.xsl (see below). This stylesheet
examines attribute data, while the previous example looks at elements.
A plain text listing is available at:
test-attrs.txt.
C) The XSLT Stylesheets
D) Martin Honnen's Mozilla/Netscape Serialization Viewer
The file show-serialization.txt contains
a single-line JavaScript listing that opens a second browser window and
pastes into that window a serialized listing of the results produced by the
XSLT transform (basically it produces a listing of the underlying markup behind
whatever is displayed in the browser window). This is invoked from a browser
bookmark. To add this functionality to your browser, simply do the following.
Starting from the browser window:
- Select Bookmarks --> Manage Bookmarks
- From the Bookmark manager, select File --> New --> Bookmark. This
produces a "File Bookmark" tool.
- Enter a useful name for the bookmark (e.g. "Show Serialized Results")
into the Name field
- Enter the JavaScript function into the Location window - go to
show-serialization.txt, select and
copy the text, return to the "File Bookmark" tool, and paste the string
into the Location field.
- Select OK. The bookmark is now added to the bottom of the bookmark list.
To use this bookmark, simply load the desired XML data file into the browser.
Then select the "Show Serialized Results" bookmark. The browser will pop
open another window (pushed behind the main window), and will display the
results inside it.
Tutorials, Books, References, and Tools