The join you performed is called an equi-join because the elements are related by equality. More generally, joins can be formed using other relations. For example, consider the query, “Select all combinations of supplier and part information for which the supplier city follows the part city in alphabetical order.”
It would be nice if you could simply write the following stylesheet, but XSLT 1.0 does not define relational operations on string types:
<xsl:template match="/"> <result> <xsl:for-each select="database/suppliers/*"> <xsl:variable name="supplier" select="."/> <!-- This does not work! --> <xsl:for-each select="/database/parts/*[current( )/@city > @city]"> <colocated> <xsl:copy-of select="$supplier"/> <xsl:copy-of select="."/> </colocated> </xsl:for-each> </xsl:for-each> </result> </xsl:template>
Instead, you must create a table usingxsl:sortthat can map city names onto integers that reflect the ordering. Here you rely on Saxon’s ability to treat variables containing result-tree fragments as node sets when the version is set to 1.1. However, you can also use the node-set function of your particular XSLT 1.0 processor or use an XSLT 2.0 processor: