(Q4) List the names of the second-level managers of all employees whose rating is "Poor".
/emp[rating = "Poor"]/@mgr->emp/@mgr->emp/name
XPath equivalent to (Q4)
id(id(/emp[rating = "Poor"]/@mgr)[self::emp]/@mgr)[self::emp]/name
Or, for better readability, use this:
id($poorEmpManagers/@mgr)[self::emp]/name
...in conjunction with a variable binding, shown here in XSLT:
<xsl:variable name="poorEmpManagers" select="id(/emp[rating = 'Poor']/@mgr)[self::emp]"/>
- In practice, using
->* would be pretty common, since a valid document may only have one element with a given ID, regardless of that element's name,
so I'm not sure how much value the implicit name test really adds beyond the id() function's current capabilities.
|