Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [X-Path] grouping di risultati da db

    ciao a tutti, sto impazzendo a causa della complessità di X-Path.
    dovrei rendere questo risultato xml in vista gerarchica. intanto eccovi il codice:
    codice:
    <?xml version="1.0"?>
    <xml xmlns:z="#RowsetSchema">
    	<rs:data xmlns:rs="urn:schemas-microsoft-com:rowset">
    		<z:row xmlns:z="#RowsetSchema" COD_ABI="05188" ID_ESITO="6" ESITO="Apertura ticket di segnalazione."/>
    		<z:row xmlns:z="#RowsetSchema" COD_ABI="05188" ID_ESITO="1" ESITO="Chiamata effettuata con successo."/>
    		<z:row xmlns:z="#RowsetSchema" COD_ABI="05188" ID_ESITO="2" ESITO="Numero di telefono mancante o errato."/>
    		<z:row xmlns:z="#RowsetSchema" COD_ABI="05188" ID_ESITO="2" ESITO="Numero di telefono mancante o errato."/>
    		<z:row xmlns:z="#RowsetSchema" COD_ABI="05188" ID_ESITO="0" ESITO="Da Effettuare"/>
    		<z:row xmlns:z="#RowsetSchema" COD_ABI="03336" ID_ESITO="0" ESITO="Da Effettuare"/>
    		<z:row xmlns:z="#RowsetSchema" COD_ABI="03336" ID_ESITO="1" ESITO="Chiamata effettuata con successo."/>
    		<num_rec>7</num_rec>
    	</rs:data>
    </xml>
    avrei bisogno di raggruppare PRIMA DI TUTTO PER ABI, in seguito per id_esito e gli esiti devono essere "contati", quindi la trasformazione deve essere produrre del genere:


    ABI 05188
    Esiti chiamate
    Apertura ticket di segnalazione. tot.1
    Numero di telefono mancante o errato. tot. 2


    ABI 03336
    Esiti chiamate
    Da Effettuare tot.1

    grazie a chi mi saprà aiutare :master:
    "0 è tutto finito. 1 è solo l'inizio"
    HO IL CERTIFICATO DI RESISTENZA.

  2. #2

    ce l'ho fatta!

    posto il codice per coloro che hanno o avranno lo stesso problema.
    esso permette di gerarchizzare i dati provenienti dal db nel classico formato xml a righe e trasformarlo in un albero.

    codice:
    <xsl:template match="rs:data">
    	<xsl:for-each select="//rs:data/z:row[not(@COD_ABI = preceding-sibling::z:row/@COD_ABI)]/@COD_ABI">
    		<xsl:variable name="curr_abi" select="current()"/>
    		<tr>
    			<td class="Costanti" align="center" valign="top">
    			
    
    			<xsl:value-of select="current()"/>
    			</td>
    			<td colspan="2" valign="top">
    			
    
    			<xsl:for-each select="//rs:data/z:row[not(@ID_ESITO = preceding-sibling::z:row[@COD_ABI = $curr_abi]/@ID_ESITO) and (@COD_ABI = $curr_abi)]/@ID_ESITO">
    				<xsl:variable name="classeRiga">
    					<xsl:choose>
    						<xsl:when test="position() mod 2 = 1">odd</xsl:when>
    					<xsl:otherwise>even</xsl:otherwise>
    					</xsl:choose>
    				</xsl:variable>
    				<table width="100%" cellspacing="0">
    					<tr class="{$classeRiga}">
    						<td class="Costanti">
    							<xsl:value-of select="../@ESITO"/>&#160;
    						</td>
    						<td class="Costanti" align="center" width="50">
    							<span style="color: red;font-weight:bold;"><xsl:value-of select="count(/xml/rs:data/z:row[@ID_ESITO = current() and @COD_ABI = $curr_abi])"/></span>
    						</td>
    					</tr>
    				</table>
    			</xsl:for-each>
    			</td>
    		</tr>
    	</xsl:for-each>
    </xsl:template>
    "0 è tutto finito. 1 è solo l'inizio"
    HO IL CERTIFICATO DI RESISTENZA.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.