(Q19) Find titles of books in which both sailing and windsurfing are mentioned in the same paragraph.

FOR $b IN //book
WHERE SOME $p IN $b//para SATISFIES
   contains($p, "sailing") 
   AND contains($p, "windsurfing")
RETURN $b/title

XSLT equivalent to (Q19)

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:for-each select="//book">
      <xsl:if test=".//para[contains(., 'sailing') and contains(., 'windsurfing')]">
        <xsl:copy-of select="title"/>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:transform>
  • Existential quantification is XPath's normal mode of operation; in the XSLT solution, if the condition is true for any of the nodes, then the node-set will be non-empty and return true.
<<<  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15    >>>