Generazione di un XML di output con XSL ed un altro XML

Tips sui fogli di stile

Generazione di un XML di output con XSL ed un altro XML

Messaggioda alesslud » mar giu 24, 2008 1:16 pm

Generazione di un XML di output con XSL ed un altro XML


Il file xsl: questo files ha contiene moltissimi esempi;

<xsl:decimal-format decimal-separator="," grouping-separator="." name="euro" /> crea una funzione per la creazione del formato in euro;

<xsl:attribute name="value" >
<xsl:value-of select="format-number(sum(//Gruppi/Gruppo[@tipo='C']/@credito), '###.###,00', 'euro')"/>

</xsl:attribute>
effettua una somma di tutti gli attributi con nome credito del nodo gruppo che abbiano l'attributo tipo uguale a c formattandolo in valuta euro

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>
<xsl:decimal-format decimal-separator="," grouping-separator="." name="euro" />
<xsl:template match="/root">
<Worksheets>
<Worksheet name="Comuni">
<row>
<string-cell width="7000" index="0">
<xsl:attribute name="value" >Oggi</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="1">
<xsl:attribute name="value" >DataCreazione</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="2">
<xsl:attribute name="value" >Anno</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="3">
<xsl:attribute name="value" >Mese</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
</row>
<row>
<string-cell width="7000" index="0">
<xsl:attribute name="value" >
<xsl:value-of select="Oggi"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="1">
<xsl:attribute name="value" >
<xsl:value-of select="DataCreazione" />
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="2">
<xsl:attribute name="value" >
<xsl:value-of select="Anno"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="3">
<xsl:attribute name="value" >
<xsl:value-of select="Mese"/>
</xsl:attribute>
</string-cell>
</row>
<row>
<string-cell width="7000" index="0">
<xsl:attribute name="value" >Denominazione comune</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="1">
<xsl:attribute name="value" >Codice comune</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="2">
<xsl:attribute name="value" >Codice tributo</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="3">
<xsl:attribute name="value" >Mese di riferimento</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="4">
<xsl:attribute name="value" >Anno di riferimento</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="5">
<xsl:attribute name="value" >Debito</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="6">
<xsl:attribute name="value" >Credito</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
</row>
<xsl:for-each select="Gruppi">
<xsl:choose>
<xsl:when test="Gruppo/@tipo = 'C' ">
<xsl:apply-templates select="Gruppo/DenominazioneComune" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
<row>
<string-cell width="7000" index="0">

</string-cell>
<string-cell width="7000" index="1">

</string-cell>
<string-cell width="7000" index="2">

</string-cell>
<string-cell width="7000" index="3">

</string-cell>
<string-cell width="7000" index="4">
<xsl:attribute name="value" >Totale</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<double-cell width="7000" index="5">
<xsl:attribute name="value" >
<xsl:value-of select="format-number(sum(//Gruppi/Gruppo[@tipo='C']/@debito), '###.###,00', 'euro')"/>
</xsl:attribute>
</double-cell>
<double-cell width="7000" index="6">
<xsl:attribute name="value" >
0,00
</xsl:attribute>
<xsl:attribute name="value" >
<xsl:value-of select="format-number(sum(//Gruppi/Gruppo[@tipo='C']/@credito), '###.###,00', 'euro')"/>
</xsl:attribute>
</double-cell>
</row>
</Worksheet>
<Worksheet name="Regioni">
<row>
<string-cell width="7000" index="0">
<xsl:attribute name="value" >Oggi</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="1">
<xsl:attribute name="value" >DataCreazione</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="2">
<xsl:attribute name="value" >Anno</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="3">
<xsl:attribute name="value" >Mese</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
</row>
<row>
<string-cell width="7000" index="0">
<xsl:attribute name="value" >
<xsl:value-of select="Oggi"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="1">
<xsl:attribute name="value" >
<xsl:value-of select="DataCreazione" />
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="2">
<xsl:attribute name="value" >
<xsl:value-of select="Anno"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="3">
<xsl:attribute name="value" >
<xsl:value-of select="Mese"/>
</xsl:attribute>
</string-cell>
</row>
<row>
<string-cell width="7000" index="0">
<xsl:attribute name="value" >Denominazione regione</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="1">
<xsl:attribute name="value" >Codice regione</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="2">
<xsl:attribute name="value" >Codice tributo</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="3">
<xsl:attribute name="value" >Mese di riferimento</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="4">
<xsl:attribute name="value" >Anno di riferimento</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="5">
<xsl:attribute name="value" >Debito</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<string-cell width="7000" index="6">
<xsl:attribute name="value" >Credito</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
</row>
<xsl:for-each select="Gruppi">
<xsl:choose>
<xsl:when test="Gruppo/@tipo = 'R' ">
<xsl:apply-templates select="Gruppo/DenominazioneRegione" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
<row>
<string-cell width="7000" index="0">

</string-cell>
<string-cell width="7000" index="1">

</string-cell>
<string-cell width="7000" index="2">

</string-cell>
<string-cell width="7000" index="3">

</string-cell>
<string-cell width="7000" index="4">
<xsl:attribute name="value" >Totali</xsl:attribute>
<font size="10" italic="false" bold="true" allignment="left"></font>
</string-cell>
<double-cell width="7000" index="5">
<xsl:attribute name="value" >
<xsl:value-of select="format-number(sum(//Gruppi/Gruppo[@tipo='R']/@debito), '###.###,00', 'euro')"/>
</xsl:attribute>
</double-cell>
<double-cell width="7000" index="6">
<xsl:attribute name="value" >
<xsl:value-of select="format-number(sum(//Gruppi/Gruppo[@tipo='R']/@credito), '###.###,00', 'euro')"/>
</xsl:attribute>
</double-cell>
</row>
</Worksheet>
</Worksheets>
</xsl:template>

<xsl:template match="Gruppo/DenominazioneComune" name="comuni">
<row>
<string-cell width="7000" index="0">
<xsl:attribute name="value" >
<xsl:value-of select="../DenominazioneComune"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="1">
<xsl:attribute name="value" >
<xsl:value-of select="../CodiceComuneCatastale"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="2">
<xsl:attribute name="value" >
<xsl:value-of select="../CodiceTributo"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="3">
<xsl:attribute name="value" >
<xsl:value-of select="../MeseRiferimentoDelega" />
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="4">
<xsl:attribute name="value" >
<xsl:value-of select="../AnnoRiferimentoDelega"/>
</xsl:attribute>
</string-cell>
<double-cell width="7000" index="5">
<xsl:attribute name="value" >
<xsl:value-of select="../Debito"/>
</xsl:attribute>
</double-cell>
<double-cell width="7000" index="6">
<xsl:attribute name="value" >
<xsl:value-of select="../Credito"/>
</xsl:attribute>
</double-cell>
</row>
</xsl:template>

<xsl:template match="Gruppo/DenominazioneRegione" name="regioni">
<row>
<string-cell width="7000" index="0">
<xsl:attribute name="value" >
<xsl:value-of select="../DenominazioneRegione"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="1">
<xsl:attribute name="value" >
<xsl:value-of select="../CodiceRegione"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="2">
<xsl:attribute name="value" >
<xsl:value-of select="../CodiceTributo"/>
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="3">
<xsl:attribute name="value" >
<xsl:value-of select="../MeseRiferimentoDelega" />
</xsl:attribute>
</string-cell>
<string-cell width="7000" index="4">
<xsl:attribute name="value" >
<xsl:value-of select="../AnnoRiferimentoDelega"/>
</xsl:attribute>
</string-cell>
<double-cell width="7000" index="5">
<xsl:attribute name="value" >
<xsl:value-of select="../Debito"/>
</xsl:attribute>
</double-cell>
<double-cell width="7000" index="6">
<xsl:attribute name="value" >
<xsl:value-of select="../Credito"/>
</xsl:attribute>
</double-cell>
</row>
</xsl:template>
</xsl:stylesheet>
Ultima modifica di alesslud il mar giu 24, 2008 1:34 pm, modificato 5 volte in totale.
alesslud
Site Admin
 
Messaggi: 779
Iscritto il: mer nov 08, 2006 8:09 am

XML da trasformare

Messaggioda alesslud » mar giu 24, 2008 1:19 pm

<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<Oggi>24/06/2008</Oggi>
<DataCreazione>24/06/2008</DataCreazione>
<Anno>2008</Anno>
<Mese>5</Mese>
<Gruppi>
<Gruppo tipo="C" debito="83.13" credito="0">
<AnnoRiferimentoDelega>2007</AnnoRiferimentoDelega>
<MeseRiferimentoDelega>5</MeseRiferimentoDelega>
<CodiceComuneCatastale>A028</CodiceComuneCatastale>
<DenominazioneComune>ACIREALE</DenominazioneComune>
<CodiceTributo>3848</CodiceTributo>
<Debito>83,13</Debito>
<Credito>0,00</Credito>
</Gruppo>
<Gruppo tipo="C" debito="22.62" credito="0">
<AnnoRiferimentoDelega>2007</AnnoRiferimentoDelega>
<MeseRiferimentoDelega>5</MeseRiferimentoDelega>
<CodiceComuneCatastale>A048</CodiceComuneCatastale>
<DenominazioneComune>ACQUAVIVA DELLE FONTI</DenominazioneComune>
<CodiceTributo>3848</CodiceTributo>
<Debito>22,62</Debito>
<Credito>0,00</Credito>
</Gruppo>
<Gruppo tipo="C" debito="26.68" credito="0">
<AnnoRiferimentoDelega>2007</AnnoRiferimentoDelega>
<MeseRiferimentoDelega>5</MeseRiferimentoDelega>
<CodiceComuneCatastale>A052</CodiceComuneCatastale>
<DenominazioneComune>ACQUI TERME</DenominazioneComune>
<CodiceTributo>3848</CodiceTributo>
<Debito>26,68</Debito>
<Credito>0,00</Credito>
</Gruppo>
<Gruppo tipo="C" debito="129.61" credito="0">
<AnnoRiferimentoDelega>2007</AnnoRiferimentoDelega>
<MeseRiferimentoDelega>5</MeseRiferimentoDelega>
<CodiceComuneCatastale>A059</CodiceComuneCatastale>
<DenominazioneComune>ADRIA</DenominazioneComune>
<CodiceTributo>3848</CodiceTributo>
<Debito>129,61</Debito>
<Credito>0,00</Credito>
</Gruppo>
<Gruppo tipo="C" debito="8.79" credito="0">
<AnnoRiferimentoDelega>2007</AnnoRiferimentoDelega>
<MeseRiferimentoDelega>5</MeseRiferimentoDelega>
<CodiceComuneCatastale>A064</CodiceComuneCatastale>
<DenominazioneComune>AFRAGOLA</DenominazioneComune>
<CodiceTributo>3848</CodiceTributo>
<Debito>8,79</Debito>
<Credito>0,00</Credito>
</Gruppo>
</Gruppi>
</root>
alesslud
Site Admin
 
Messaggi: 779
Iscritto il: mer nov 08, 2006 8:09 am

Risultato

Messaggioda alesslud » mar giu 24, 2008 1:20 pm

<?xml version="1.0" encoding="ISO-8859-1"?>
<Worksheets>
<Worksheet name="Comuni">
<row>
<string-cell width="7000" index="0" value="Oggi">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="1" value="DataCreazione">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="2" value="Anno">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="3" value="Mese">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
</row>
<row>
<string-cell width="7000" index="0" value="24/06/2008"/>
<string-cell width="7000" index="1" value="24/06/2008"/>
<string-cell width="7000" index="2" value="2008"/>
<string-cell width="7000" index="3" value="5"/>
</row>
<row>
<string-cell width="7000" index="0" value="Denominazione comune">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="1" value="Codice comune">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="2" value="Codice tributo">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="3" value="Mese di riferimento">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="4" value="Anno di riferimento">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="5" value="Debito">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="6" value="Credito">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
</row>
<row>
<string-cell width="7000" index="0" value="ACIREALE"/>
<string-cell width="7000" index="1" value="A028"/>
<string-cell width="7000" index="2" value="3848"/>
<string-cell width="7000" index="3" value="5"/>
<string-cell width="7000" index="4" value="2007"/>
<double-cell width="7000" index="5" value="83,13"/>
<double-cell width="7000" index="6" value="0,00"/>
</row>
<row>
<string-cell width="7000" index="0" value="ACQUAVIVA DELLE FONTI"/>
<string-cell width="7000" index="1" value="A048"/>
<string-cell width="7000" index="2" value="3848"/>
<string-cell width="7000" index="3" value="5"/>
<string-cell width="7000" index="4" value="2007"/>
<double-cell width="7000" index="5" value="22,62"/>
<double-cell width="7000" index="6" value="0,00"/>
</row>
<row>
<string-cell width="7000" index="0" value="ACQUI TERME"/>
<string-cell width="7000" index="1" value="A052"/>
<string-cell width="7000" index="2" value="3848"/>
<string-cell width="7000" index="3" value="5"/>
<string-cell width="7000" index="4" value="2007"/>
<double-cell width="7000" index="5" value="26,68"/>
<double-cell width="7000" index="6" value="0,00"/>
</row>
<row>
<string-cell width="7000" index="0" value="ADRIA"/>
<string-cell width="7000" index="1" value="A059"/>
<string-cell width="7000" index="2" value="3848"/>
<string-cell width="7000" index="3" value="5"/>
<string-cell width="7000" index="4" value="2007"/>
<double-cell width="7000" index="5" value="129,61"/>
<double-cell width="7000" index="6" value="0,00"/>
</row>
<row>
<string-cell width="7000" index="0" value="AFRAGOLA"/>
<string-cell width="7000" index="1" value="A064"/>
<string-cell width="7000" index="2" value="3848"/>
<string-cell width="7000" index="3" value="5"/>
<string-cell width="7000" index="4" value="2007"/>
<double-cell width="7000" index="5" value="8,79"/>
<double-cell width="7000" index="6" value="0,00"/>
</row>
<row>
<string-cell width="7000" index="0">

</string-cell>
<string-cell width="7000" index="1">

</string-cell>
<string-cell width="7000" index="2">

</string-cell>
<string-cell width="7000" index="3">

</string-cell>
<string-cell width="7000" index="4" value="Totale">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<double-cell width="7000" index="5" value="270,83"/>
<double-cell width="7000" index="6" value=",00"/>
</row>
</Worksheet>
<Worksheet name="Regioni">
<row>
<string-cell width="7000" index="0" value="Oggi">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="1" value="DataCreazione">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="2" value="Anno">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="3" value="Mese">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
</row>
<row>
<string-cell width="7000" index="0" value="24/06/2008"/>
<string-cell width="7000" index="1" value="24/06/2008"/>
<string-cell width="7000" index="2" value="2008"/>
<string-cell width="7000" index="3" value="5"/>
</row>
<row>
<string-cell width="7000" index="0" value="Denominazione regione">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="1" value="Codice regione">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="2" value="Codice tributo">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="3" value="Mese di riferimento">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="4" value="Anno di riferimento">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="5" value="Debito">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<string-cell width="7000" index="6" value="Credito">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
</row>
<row>
<string-cell width="7000" index="0">

</string-cell>
<string-cell width="7000" index="1">

</string-cell>
<string-cell width="7000" index="2">

</string-cell>
<string-cell width="7000" index="3">

</string-cell>
<string-cell width="7000" index="4" value="Totali">
<font size="10" italic="false" bold="true" allignment="left"/>
</string-cell>
<double-cell width="7000" index="5" value=",00"/>
<double-cell width="7000" index="6" value=",00"/>
</row>
</Worksheet>
</Worksheets>
alesslud
Site Admin
 
Messaggi: 779
Iscritto il: mer nov 08, 2006 8:09 am


Torna a CSS e XSL

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite

cron