Hallo zusammen,
ich sitze bereits seit mehreren Tagen an folgendem Problem:
Die XML - Datei
Nun erstelle ich mir eine Liste mit allen Angeboten, welche durchnummeriert werden:
Als nächstes will ich die einzelnen Angebote zusammen mit der Nummer aus der Liste ausgeben. Also folgendes Ergebnis erhalten:
Wie kann ich dies erreichen?
Danke für Eure Hilfe
Andrea
ich sitze bereits seit mehreren Tagen an folgendem Problem:
Die XML - Datei
Code:
<test> <provider> <offer id="1" name="a"> <location id="67890" name="def" /> <location id="12345" name="abc" /> </offer> <offer id="2" name="b"> <location id="12345" name="abc" /> </offer> <offer id="3" name="c"> <location id="12345" name="abc" /> <location id="67890" name="def" /> </offer> </provider> </test>
Code:
<?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="id" match="location" use="@id" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="provider"> Orte_Liste:<xsl:text> </xsl:text> <xsl:call-template name="List_location" /> <xsl:apply-templates select="offer" /> </xsl:template> <xsl:template match="offer"> Angebot<xsl:value-of select="@name" /><xsl:text>: </xsl:text> <xsl:apply-templates select="location" /> <xsl:text>
</xsl:text> </xsl:template> <xsl:template match="location"> <xsl:text> </xsl:text><xsl:value-of select="@id" /> <xsl:text> </xsl:text><xsl:value-of select="@name" /> <xsl:text> </xsl:text> </xsl:template> <xsl:template name="List_location"> <xsl:for-each select="//location[generate-id() = generate-id(key('id', @id)[1])]"> <xsl:text> </xsl:text> <xsl:value-of select="position()" /> <xsl:text> </xsl:text><xsl:value-of select="@name" /> </xsl:for-each> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet>
Code:
Orte_Liste: 1 def 2 abc Angebot a: 1, 2 Angebot b: 2 Angebot c: 2, 1
Danke für Eure Hilfe
Andrea
Comment