Hi I am a xslt beginner and I am working on a stylesheet to output a dept. Can someone help me in writing a stylesheet that outputs all the dept names with Lee AND Ray as managers given the simple xml below?
(so for this example, it would output help desk). Thanks a lot.
<?xml version="1.0" ?>
Help Desk
Lee
Ray
QA
Lee
Hoods
Finance
Ray
In XSLT you can use XPath expressions to select nodes to be processed. The example shown below will select only ‘dept’ nodes where the managers names are “Ray” and “Lee”.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates select="departments/dept[manager/name='Ray' and manager/name='Lee']"/>
</xsl:template>
<xsl:template match="dept">
The department is <xsl:value-of select="name"/>
</xsl:template>
</xsl:stylesheet>
Hope this helps.
Stuart Fyffe-Collins
Software AG (UK) Ltd.