Ich habe es nun doch selber lösen können.
Hier das XSLT-Skript:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<VERZEICHNIS>
<xsl:apply-templates select="//object[attribute::level=1]" mode="NEXT">
<!-- This selects ALL elements <object level="1"> -->
<xsl:with-param name="LIMES" select="number(1)"/>
<!-- start-value of the parameter $LIMES is 1 -->
</xsl:apply-templates>
</VERZEICHNIS>
</xsl:template>
<xsl:template match="object" mode="NEXT">
<xsl:param name="LIMES"/>
<xsl:if test="@level = $LIMES">
<!-- These are the searched elements -->
<xsl:element name="DING">
<xsl:attribute name="EBENE">
<xsl:value-of select="./@level"/>
</xsl:attribute>
<xsl:if test="$LIMES + 1 = following-sibling::object[1]/@level">
<!-- Is the next object-element one level higher? -->
<xsl:apply-templates select="following-sibling::object[1]" mode="NEXT">
<!-- recursion, search on -->
<xsl:with-param name="LIMES" select="$LIMES + 1"/>
<!-- In XSL, the variables are only valid inside their frame, C++ like! -->
</xsl:apply-templates>
</xsl:if>
</xsl:element>
</xsl:if>
<xsl:if test="$LIMES <= following-sibling::object[1]/@level">
<!-- Is the next object-element on the same level? -->
<xsl:apply-templates select="following-sibling::object[1]" mode="NEXT">
<!-- recursion, search on -->
<xsl:with-param name="LIMES" select="$LIMES"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
</xsl:stylesheet>