(Q17) Find procedures in which no anesthesia occurs before the first incision.

-- Finds potential lawsuits
FOR $p in //procedure
WHERE empty($p//anesthesia BEFORE ($p//incision)[1])
RETURN $p

XSLT equivalent to (Q17)

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:for-each select="//procedure">
      <xsl:variable name="before" select="(.//incision)[1]/preceding::*"/>
      <xsl:if test="not(.//anesthesia[count(.|$before)=count($before)])">
        <xsl:copy-of select="."/>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:transform>
  • The XSLT solution uses the same approach as in the last query, which is to find the intersection of two node-sets
<<<  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15    >>>