deepthroat
Erfahrenes Mitglied
Ich glaube vor allem hast du dein Problem übermäßig vereinfacht. Jetzt sehen deine Anforderungen ja ganz anders aus...Ah, ok! Wir haben etwas aneinander vorbei geredet!
Probier's mal damit:
XML:
<xsl:template match="/test/provider">
Orte_Liste:
<xsl:variable name="locations" select="offer/location[not(@id = ../preceding-sibling::offer/location/@id)]" />
<xsl:for-each select="$locations">
<xsl:value-of select="position()" /><xsl:text> </xsl:text>
<xsl:value-of select="@name" /><xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="offer">
Angebot <xsl:value-of select="@name" />:
<xsl:for-each select="location">
<xsl:variable name="loc_id" select="@id" />
<xsl:value-of select="count(
$locations
[not($loc_id = (preceding-sibling::location|../preceding-sibling::offer/location)/@id)])" />
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:for-each>
--------------------
</xsl:template>
Code:
Orte_Liste:
1 def
2 abc
Angebot a:
1, 2
Angebot b:
2
Angebot c:
2, 1
--------------------
Orte_Liste:
1 xyz
2 uvw
3 def
Angebot d:
1, 2
Angebot e:
2, 3
--------------------
Zuletzt bearbeitet von einem Moderator: