[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] not grouping but nearly the same?!
Subject: [xsl] not grouping but nearly the same?! From: "Stefan Huber" <Huber_Stefan@xxxxxxx> Date: Mon, 26 Jun 2006 17:00:53 +0200 |
hallo list -- these are my first steps in xsl-programming, but it is quite difficult... my problem: i've got a xml like that (only a little part of it): <root> <CITYENTRY CITYNO="1"> <CITYNAME>Aach, Hegau</CITYNAME> <CITYZIP>78267</CITYZIP> <CITYPRICE>7,50</CITYPRICE> <TYPE>3</TYPE> <ALLMEMBERNO> <MEMBERNO>72866-00</MEMBERNO> </ALLMEMBERNO> </CITYENTRY> <CITYENTRY CITYNO="2"> <CITYNAME>Aachen</CITYNAME> <CITYZIP>52062</CITYZIP> <CITYPRICE>5,50</CITYPRICE> <TYPE>3</TYPE> <ALLMEMBERNO> <MEMBERNO>34-00</MEMBERNO> <MEMBERNO>43096-00</MEMBERNO> </ALLMEMBERNO> </CITYENTRY> <CITYENTRY CITYNO="32074"> <CITYNAME>Aach-Linz = Pfullendorf , Baden 88630</CITYNAME> <CITYZIP>88630</CITYZIP> <CITYPRICE>5,50</CITYPRICE> <TYPE>2</TYPE> <ALLMEMBERNO> <MEMBERNO>34-00</MEMBERNO> <MEMBERNO>43096-00</MEMBERNO> </ALLMEMBERNO> </CITYENTRY> <CITYENTRY CITYNO="3"> <CITYNAME>Aachen</CITYNAME> <CITYZIP>52062</CITYZIP> <CITYPRICE>5,50</CITYPRICE> <TYPE>3</TYPE> <ALLMEMBERNO> <MEMBERNO>34-00</MEMBERNO> <MEMBERNO>43096-00</MEMBERNO> </ALLMEMBERNO> </CITYENTRY> <CITYENTRY CITYNO="4"> <CITYNAME>Aachen</CITYNAME> <CITYZIP>52064</CITYZIP> <CITYPRICE>5,50</CITYPRICE> <TYPE>3</TYPE> <ALLMEMBERNO> <MEMBERNO>34-00</MEMBERNO> <MEMBERNO>43096-00</MEMBERNO> </ALLMEMBERNO> </CITYENTRY> <CITYENTRY CITYNO="5"> <CITYNAME>Aachen</CITYNAME> <CITYZIP>52066</CITYZIP> <CITYPRICE>5,50</CITYPRICE> <TYPE>3</TYPE> <ALLMEMBERNO> <MEMBERNO>34-00</MEMBERNO> <MEMBERNO>43096-00</MEMBERNO> </ALLMEMBERNO> </CITYENTRY> </root> -> when ever a CITYENTRY of TYPE = 3 is direct followed by an other CITYENTRY TYPE = 3 with exact the same CITYNAME and ALLMEMBERNO then i want to delete the actual CITYENTRY and put in the followed CITYENTRY the CITYZIP of the actual CITYENTRY in the tag CITYZIPEND. my code works, exept the fact, that i can't fill CITYZIPEND. have anyone an idea? here is my code: <?xml version='1.0' encoding='utf-8'?> <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:output method="xml" version='1.0' encoding='utf-8' indent='no'/> <!-- ............................................. --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- ............................................. --> <xsl:template match="/root"> <root> <xsl:for-each select="CITYENTRY"> <!-- prev ALLMEMBERNO --> <xsl:variable name="prevALLMEMBERNO"> <xsl:value-of select="preceding-sibling::*[1]/ALLMEMBERNO"/> </xsl:variable> <!-- next ALLMEMBERNO --> <xsl:variable name="nextALLMEMBERNO"> <xsl:value-of select="following-sibling::*[1]/ALLMEMBERNO"/> </xsl:variable> <!-- pref CITYNAME --> <xsl:variable name="prevCITYNAME"> <xsl:value-of select="preceding-sibling::*[1]/CITYNAME"/> </xsl:variable> <!-- next CITYNAME --> <xsl:variable name="nextCITYNAME"> <xsl:value-of select="following-sibling::*[1]/CITYNAME"/> </xsl:variable> <!-- pref TYPE --> <xsl:variable name="prevTYPE"> <xsl:value-of select="preceding-sibling::*[1]/TYPE"/> </xsl:variable> <!-- next TYPE --> <xsl:variable name="nextTYPE"> <xsl:value-of select="following-sibling::*[1]/TYPE"/> </xsl:variable> <xsl:choose> <!-- Normale Stadt --> <xsl:when test="TYPE = 3"> <xsl:choose> <!-- ..................................................... --> <xsl:when test="$nextALLMEMBERNO = ALLMEMBERNO and $nextCITYNAME = CITYNAME and $nextTYPE = TYPE" > </xsl:when> <!-- ..................................................... --> <xsl:when test="$nextALLMEMBERNO = ALLMEMBERNO and $prevALLMEMBERNO = ALLMEMBERNO and $prevCITYNAME = CITYNAME and $nextCITYNAME = CITYNAME and $prevTYPE = TYPE and $nextTYPE = TYPE" > </xsl:when> <!-- ..................................................... --> <xsl:when test="$nextALLMEMBERNO != ALLMEMBERNO and $prevALLMEMBERNO = ALLMEMBERNO and $prevCITYNAME = CITYNAME and $nextCITYNAME != CITYNAME and $prevTYPE = TYPE and $nextTYPE != TYPE" > <xsl:copy> <xsl:apply-templates select="@*|node()"/> <xsl:element name = "CITYZIPEND">99999</xsl:element> </xsl:copy> </xsl:when> <!-- ..................................................... --> <xsl:otherwise> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:otherwise> <!-- ..................................................... --> </xsl:choose> </xsl:when> <xsl:when test="TYPE = 1"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> <xsl:element name = "Status">ausgeben</xsl:element> </xsl:copy> </xsl:when> <xsl:when test="TYPE = 2"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> <xsl:element name = "Status">ausgeben</xsl:element> </xsl:copy> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:for-each> </root> </xsl:template> </xsl:stylesheet> thanks for any clues. -- Echte DSL-Flatrate dauerhaft f|r 0,- Euro*! "Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Browsing XML Schema Data , Michael Kay | Thread | [xsl] problem with sum() function, Pankaj Bishnoi |
RE: [xsl] Fwd: Namespace 'http://ex, Michael Kay | Date | RE: [xsl] Browsing XML Schema Data , Michael Kay |
Month |
Keywords