|
|
|
|
|
|
| |
XSLT Tutorial
Worksheet 2: XPath - Simple Example
The purpose of this worksheet is to get used to
transforming your XML file using XSLT. Is is also
an introduction into using XPath, working with the count
function.
Here's what to do:
Open up your free 30 day
evaluation MarrowSoft Xselerator XSLT Debugger
- In the XML section, open the books.xml file
- In the XSL section, open the count.xsl file
- Now run the example to produce the output (F5
or the click on the run button)
- The transformed html should now be in vew
This example shows how to use the count function, which has
a predicate to only count books whose review = 4.5.
NOTE: If you are running the msxml3 parser (October
release) and have not run the xmlinst.exe to instruct the parser to run in
replace mode, this count example will not run. For more information
on the msxml parser see MSXML Parsers.
Q: In your Xselerator, how could you change
the code so that the context of
this example changes, so that instead of saying:
<p>Review of 4.5 = <xsl:value-of
select="count(books/book[review=4.5])"/></p>
You could rather say in your expression:
<p>Review of 4.5 = <xsl:value-of
select="count(book[review=4.5])"/></p>
Hint: Look at your xsl:template
A: Solution
|
|
|
|
|
|
|
|
|