I have a list of customer Information and Sales in Filemaker. I want to export it using XSL. The outcome should be something like this:

Customer "1"
_Information_
Order "1" (current ordernr) (Order Nr 1)
_Information_
order position "1" (Item 1)
_Information_
order position "2" (Item 2)
_Information_

Order "2" (current ordernr) (Order Nr 2)
_Information_
order position "1" (Item 3)
_Information_
order position "2" (Item 4)
_Information_

and so on...
I have the coding I could attach it somehow but everything works fine until the order position, it simply does not want to display the sale position in that order that i want. I have tried with position() too. Under the order i have the following code:

`<xsl:for-each select="fm:KundenNr/fm: DATA"><xsl:variable name="pos" select="position()"/>
<xsl:variable name="var_KundenNr" select="../../fm:KundenNr/fm: DATA[$pos]"/>
<xsl:if test= "$var_KundenNr !=''">
<bestellung>(Order)
<xsl:attribute name="LaufendeBestellungsnummer"><xsl:value-of select="$pos"/> </xsl:attribute>`

That works fine but below i tried a similar approach and I simply cannot get it in line and i have the following code:

`<positionen>
<xsl:for-each select="../../fm:BestellNr/fm: DATA">
<xsl:variable name="Bestell_pos" select="position()"/>
<xsl:variable name="var_BestellNr" select="../../fm:BestellNr /fm: DATA[$Bestell_pos]"/><xsl:if test= "$var_BestellNr = $Bestell_Nr">`
<bestellungsposition>
<xsl:attribute name="LaufendePositionsnummer"><xsl:value-of select="$pos"(What do I input in here?)/></xsl:attribute>`

I need help. I am so stuck with it...