XSL for-each and LEFT JOIN

I need some XSLT statement that gives me something like a "LEFT JOIN": if the selected node do exist, return all such nodes, otherwise loop just once.This is different from the xsl:for-each loop, because when there is not such node the for-each loop returns ZERO lines.Here is a pratical example.XML file:\[code\]<root> <sec1> <x1/> ... <x1/> </sec1> <sec2> <x2/> ... <x2/> </sec2> ... <sec10> <x10/> ... <x10/> </sec10></root>\[/code\]Now, I don't know how many "x1", "x2", .. "x10" do I have, and I want to print out all the possible combinations. A easy and wrong solution:\[code\]<xsl:for-each select="/root/sec1/x1"> <xsl:for-each select="/root/sec2/x2"> ... <xsl:for-each select="/root/sec10/x10"> ...print x1 and x2... and x10 </xsl:for-each> ... </xsl:for-each></xsl:for-each>\[/code\]This solution is wrong because, if there is no "x3" it returns 0 lines (just like a FULL JOIN) while I would like to see all the other values (like a LEFT or RIGHT JOIN).I can use a combination of xsl:choose, xls:when, xsl:foreach and xsl:eek:therwise, but this is very long.I have tried to build my own xsl template, but it doesn't work:\[code\]<xsl:template name="left-join"> <xsl:param name="select"/> <xsl:param name="template"/> <xsl:choose> <xsl:when test="$select"> <xsl:for-each select="$select"> <xsl:call-template name="$templatename"> <!--WRONG --> <xsl:with-param name="one-parameter" select="$select"/> </xsl:call-template> </xsl:for-each> </xsl:when> <xsl:eek:therwise> <xsl:call-template name="$templatename"> <xsl:with-param name="one-parameter" select="$select"/> </xsl:call-template> </xsl:eek:therwise> </xsl:choose></xsl:template>\[/code\]
 
Top