Original: Jan Egil refsnes
Vi. XSL filtering and query
What should we do if we want to display only XML data that meets certain conditions? Or the above exampleCodeYou only need to add parameters to the select attribute of the XSL: For-each element. For example:
<XSL: For-each select = "catalog/CD [artist = 'Bob dylan']">
The logical options of parameters include:
= (Equal)
=! (Not equal)
& Lt & less
& Gt & greater than or equal
The same as the previous example (cd_catalog_sort.xsl ):
<? XML version = '1. 0'?>
<XSL: stylesheet xmlns: XSL = "http://www.w3.org/TR/WD-xsl">
<XSL: template match = "/">
<HTML>
<Body>
<Table border = "2" bgcolor = "yellow">
<Tr>
<TH> title </Th>
<TH> artist </Th>
</Tr>
<XSL: For-each select = "catalog/CD [artist = 'Bob dylan']">
<Tr>
<TD> <XSL: value-of select = "title"/> </TD>
<TD> <XSL: value-of select = "artist"/> </TD>
</Tr>
</XSL: For-each>
</Table>
</Body>
</Html>
</XSL: Template>
</XSL: stylesheet>
You can test the results by yourself.