Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2007
    Messaggi
    2

    Utilizzo delle key in XSLT. URGENTE!!!

    Ciao a tutti. Ho appena iniziato a lavorare con XML e XSLT ed ho questo problema.
    Il mio file XML è del tipo
    <?xml version="1.0"?>
    <?xml-stylesheet type='text/xsl' href='ll.xslt'?>
    <DocumentContent>
    <VUSTAG Site="AON" Lat="Right">
    <VASMEAS AG="CCA" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="80" Unit="cm/s"/>
    <VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="88" Unit="cm/s"/>
    <VASMEAS AG="CCA" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="84" Unit="cm/s" DE="Mean"/>
    <VASMEAS AG="CCU" TM="PR" VBr="ME" CP="ES" EP="PP" Name="PSV" NumericValue="80" Unit="cm/s"/>
    <VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="88" Unit="cm/s"/>
    <VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="84" Unit="cm/s" DE="Mean"/>
    </VUSTAG>
    <VUSTAG Site="AON" Lat="Left">
    <VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="80" Unit="cm/s"/>
    <VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="88" Unit="cm/s"/>
    <VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="84" Unit="cm/s" DE="Mean"/>
    <VASMEAS AG="CCA" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="80" Unit="cm/s"/>
    <VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="88" Unit="cm/s"/>
    <VASMEAS AG="CCU" TM="PR" VB="ME" CP="ES" EP="PP" Name="PSV" NumericValue="84" Unit="cm/s" DE="Mean"/>
    </VUSTAG>
    </DocumentContent>

    Ho preparato un foglio di trasformazione siffatto
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xslutput method="html"/>
    <xsl:key name="VASMEASByAG" match="VASMEAS" use="concat(ancestor::Site, ancestor::Lat,@AG)"></xsl:key>
    <xsl:template match="/">
    <html>_
    <xsl:apply-templates select="//VUSTAG"/>__
    </html>_
    </xsl:template>
    <xsl:template match="//VUSTAG">
    <table width = "100%" border="1">
    <colgroup span="2" width ="50%" valign = "top" >
    <tr>
    <xsl:choose>
    <xsl:when test="@Site != ''">
    <td align ="left"><xsl:value-of select="@Site"/></td>
    </xsl:when>
    <xsltherwise>
    <td >&#160;</td>
    </xsltherwise>
    </xsl:choose>
    <xsl:choose>
    <xsl:when test="@Lat != ''">
    <td align ="left"><xsl:value-of select="@Lat"/></td>
    </xsl:when>
    <xsltherwise>
    <td >&#160;</td>
    </xsltherwise>
    </xsl:choose>
    </tr>
    </colgroup>
    </table>
    <xsl:for-each select="VASMEAS[count(. | key('VASMEASByAG', concat(ancestor::Site, ancestor::Lat,@AG))[1]) = 1]">
    <xsl:value-of select="@AG"/>
    <xsl:for-each select="key('VASMEASByAG', concat(ancestor::Site, ancestor::Lat,@AG))">
    <table width = "100%" border = "1">
    <colgroup align ="left" valign = "top">
    <tr>
    <xsl:choose>
    <xsl:when test="@Name != ''">
    <td width ="30%">
    <xsl:value-of select="@Name"/>_
    </td>
    </xsl:when>
    <xsltherwise>
    <td width ="30%">&#160;</td>
    </xsltherwise>
    </xsl:choose>
    <xsl:choose>
    <xsl:when test="@DE != ''">
    <td width ="10%">
    <xsl:value-of select="@DE"/>_
    </td>
    </xsl:when>
    <xsltherwise>
    <td width ="10%">&#160;</td>
    </xsltherwise>
    </xsl:choose>
    <xsl:choose>
    <xsl:when test="@NumericValue != ''">
    <td width = "15%">
    <xsl:value-of select="@NumericValue"/>_
    <xsl:choose>
    <xsl:when test="@Unit != ''"> :
    <xsl:value-of select="@Unit"/>_
    </xsl:when>
    </xsl:choose>
    </td>
    </xsl:when>
    <xsltherwise>
    <td width = "15%">&#160;</td>
    </xsltherwise>
    </xsl:choose>
    </tr>
    </colgroup>
    </table>
    </xsl:for-each>
    </xsl:for-each>
    </xsl:template>


    </xsl:stylesheet>


    ma purtroppo il raggruppamento è sbagliato perché produce tutti i sottorami CAA e CCU sotto la prima coppia AON Right.
    Io vorrei una cosa del tipo:
    AON Right
    CAA
    PR ME ES ...
    PR ME ES ...
    CCU
    PR ME ES ...
    PR ME ES ...


    AON Left
    CAA
    ...............
    .............
    CCU
    .................
    .................

    cioè prima un raggruppamento in base a VUSTAG.Site e VUSTAG.Lat concatenati e in questo ambito un raggruppamento in base a VASMEAS.AG, il tutto senza ripetere l'intestazione. Grazie in anticipo a tutti. Gianni

  2. #2
    titolo non conforme al regolamento: con l'urgenza non si fa nulla. riprova con un titolo più consono.

    chiudo.

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 © 2026 vBulletin Solutions, Inc. All rights reserved.