Android Question How to sign an XML in B4A?

hi, the question is very easy, i make a function for build a xml structure so i put it in a file and save it like xml. Easy, the problem is that i have to sign this file for send it to Italian Tax Agency and i have with me only a x509Certificate. On Internet i found that with only that i can sign the document but actually i dont know how.

Here my Complete Test Function:
Generate XML:
Sub GetCertificatoX509 As String
    
    If File.Exists(Comodo.PATHCORRISPETTIVI, "deviceCertificate.x509") Then
        ' Legge il contenuto del file
        Dim fileContent As String = File.ReadString(Comodo.PATHCORRISPETTIVI, "deviceCertificate.x509")
        
        ' Divide il contenuto del file in righe
        Dim lines() As String = Regex.Split(CRLF, fileContent)
        
        ' Verifica che ci siano almeno 3 righe (minimo per avere una seconda riga e una penultima riga)
        If lines.Length > 2 Then
            Dim result As StringBuilder
            result.Initialize
            
            ' Aggiungi le righe dalla seconda alla penultima
            For i = 1 To lines.Length - 2
                result.Append(lines(i)).Append(CRLF)
            Next
            
            ' Rimuove l'ultimo CRLF aggiunto
            If result.Length > 0 Then
                result.Remove(result.Length - CRLF.Length, result.Length)
            End If
            
            ' Ritorna il risultato come stringa
            Return result.ToString
        Else
            ' Se ci sono meno di 3 righe, ritorna una stringa vuota
            Return ""
        End If
    Else
        ' Se il file non esiste, ritorna una stringa vuota
        Return ""
    End If
End Sub


Sub GeneraXMLPeriodico()
    Dim xmlBuilder As  XMLBuilder ' Inizializza un nuovo oggetto XMLBuilder
    Dim props As  Map ' Inizializza una nuova mappa per le proprietà
    

    xmlBuilder = xmlBuilder.create("p:DatiCorrispettivi") _
        .attribute("xmlns:p", "http://ivaservizi.agenziaentrate.gov.it/docs/xsd/corrispettivi/dati/v1.0") _
        .attribute("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#") _
        .attribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") _
        .attribute("versione", "COR10") _
        .element("Trasmissione") _
            .element("Progressivo").text("").up _
            .element("Formato").text("").up _
            .element("Dispositivo") _
                .element("Tipo").text("").up _
                .element("IdDispositivo").text("").up _
                .element("GeoLocalizzazione") _
                    .element("Lat").text("").up _
                    .element("Long").text("").up.up.up.up _
        .element("DataOraRilevazione").text("").up _
        .element("DatiDA") _
            .element("Periodo") _ 'AGGIUNGERE QUI I VALORI PRESI DIRETTAMENTE DALL'AUDIT
                .element("Venduto").text("").up _
                .element("VendutoContante").text("").up _
                .element("VendutoNoContante").text("").up _
                .element("Incassato").text("").up _
                .element("IncassatoRicarica").text("").up _
                .element("IncassatoVendita").text("").up _
                .element("TotaleResoTubiResto").text("").up _
                .element("TotaleCaricatoTubiResto").text("").up _
                .element("TotaleResoManualeTubiResto").text("").up _
                .element("TotaleCaricatoManualeTubiResto").text("").up _
                .element("DataOraPrelievoPrec").text("").up _
                .element("ProgressivoPrelievo").text("").up.up.up.up _
        .element("ds:Signature") _
            .element("ds:SignedInfo") _
                .element("ds:CanonicalizationMethod").attribute("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315").up _
                .element("ds:SignatureMethod").attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256").up _
                .element("ds:Reference").attribute("URI", "") _
                    .element("ds:Transforms") _
                        .element("ds:Transform").attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#enveloped-signature").up.up _
                    .element("ds:DigestMethod").attribute("Algorithm", "http://www.w3.org/2001/04/xmlenc#sha256").up _
                    .element("ds:DigestValue").text("field to fill with sign numer 1").up.up.up _
            .element("ds:SignatureValue").text("field to fill with sign numer 2").up _
            .element("ds:KeyInfo") _
                .element("ds:X509Data") _
                    .element("ds:X509Certificate").text(GetCertificatoX509).up.up.up.up

    props.Initialize
    If (Main.phoneInstance.SdkVersion < 29) Then
        props.Put("{http://xml.apache.org/xslt}indent-amount", "4")
    Else
        props.Put("{http://xml.apache.org/xslt}indent-amount", "14")
    End If
    props.Put("indent", "yes")

    File.WriteString(Comodo.DBDir, "testnewPeriodicoOUT.xml", xmlBuilder.asString2(props))
    Log("File testnewPeriodicoOUT created")
End Sub

How you can see there is actually a part of this XML that actually i have to Add with a directly Sign and is this:
Part to Add with Signature:
.element("ds:Signature") _
            .element("ds:SignedInfo") _
                .element("ds:CanonicalizationMethod").attribute("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315").up _
                .element("ds:SignatureMethod").attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256").up _
                .element("ds:Reference").attribute("URI", "") _
                    .element("ds:Transforms") _
                        .element("ds:Transform").attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#enveloped-signature").up.up _
                    .element("ds:DigestMethod").attribute("Algorithm", "http://www.w3.org/2001/04/xmlenc#sha256").up _
                    .element("ds:DigestValue").text("field to fill with sign numer 1").up.up.up _
            .element("ds:SignatureValue").text("field to fill with sign numer 2").up _
            .element("ds:KeyInfo") _
                .element("ds:X509Data") _
                    .element("ds:X509Certificate").text(GetCertificatoX509).up.up.up.up

So my question is actually, i wanna create a function that can Sign an XML and i still dont know how i can, maybe can give me some tips
or i dont know...i can share here a source of wiki about how should be work: https://en.wikipedia.org/wiki/XML_Signature
 
You need to find more information about the exact signature specifications. You can use the encryption library to sign "data". But there are many possible ways to do it.
uhmm understand, can you give me erel a tips? or link reference for start to make something?
 
Upvote 0
I have more information about it, i know that i have to make a POST API call with this specific:
" Send the fees
Description
Transmits an xml file signed with the device signing certificate compliant with the DatiCorrispettivi element of the XSD schema CorrispettiviType_1.3.xsd
"

This is the actual xml that i created:

xml without sign:
<?xml version="1.0" encoding="UTF-8" standalone = "no"?><p:DatiCorrispettivi xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/corrispettivi/dati/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" versione="COR10">
    <Trasmissione>
        <Progressivo>1</Progressivo>
        <Formato>COR10</Formato>
        <Dispositivo>
            <Tipo>DA</Tipo>
            <IdDispositivo>0591687087504</IdDispositivo>
            <GeoLocalizzazione>
                <Lat>37.6000</Lat>
                <Long>14.0154</Long>
            </GeoLocalizzazione>
        </Dispositivo>
    </Trasmissione>
    <DataOraRilevazione>2024-07-04T16:27:56</DataOraRilevazione>
    <DatiDA>
        <Periodo>
            <Venduto>00.00</Venduto>
            <VendutoContante>00.00</VendutoContante>

            <VendutoNoContante>00.00</VendutoNoContante>

            <Incassato>00.00</Incassato>
            <IncassatoRicarica>00.00</IncassatoRicarica>
            <IncassatoVendita>00.00</IncassatoVendita>
            <TotaleResoTubiResto>00.00</TotaleResoTubiResto>
            <TotaleCaricatoTubiResto>00.00</TotaleCaricatoTubiResto>
            <TotaleResoManualeTubiResto>00.00</TotaleResoManualeTubiResto>
            <TotaleCaricatoManualeTubiResto>00.00</TotaleCaricatoManualeTubiResto>
            <DataOraPrelievoPrec>2024-07-04T16:27:56</DataOraPrelievoPrec>
            <ProgressivoPrelievo>2</ProgressivoPrelievo>
        </Periodo>
    </DatiDA>
</p:DatiCorrispettivi>

and this is the CorrispettiviType_1.3.xsd:
corrispettiviMessageTypes_v1.3.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
    xmlns="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/corrispettivi/v1.0"
    targetNamespace="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/corrispettivi/v1.0"
    version="1.0">
    <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="./xmldsig-core-schema.xsd" />

    <!--
        Il file CorrispettiviMessaggiTypes_v1.3.xsd pubblicato a Luglio 2023,
        il file CorrispettiviMessaggiTypes_v1.2.xsd pubblicato a Maggio 2023 e
        il file CorrispettiviMessaggiTypes_v1.1.xsd pubblicato a Marzo 2023
        
        fanno riferimento allo schema xmlns="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/corrispettivi/v1.0" e alla version="1.0" .
        
        E' stata mantenuta la versione 1.0 all'interno dell'xsd per garantire la retrocompatibilità nei confronti degli apparati già in uso.
     -->

    <!-- =================================================================== -->
    <!-- ELEMENTI PER MESSAGGI DEI DISPOSITIVI                                 -->
    <!-- =================================================================== -->   
    <xs:element name="RichiestaCertificatoDispositivo" type="RichiestaCertificatoDispositivoType">
        <xs:annotation>
            <xs:documentation>Elemento per la richiesta del certificato di un dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="RichiestaAttributoDispositivo" type="RichiestaAttributoDispositivoType">
        <xs:annotation>
            <xs:documentation>Elemento per la richiesta di un attributo del dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EsitoRichiestaCertificatoDispositivo" type="EsitoRichiestaCertificatoDispositivoType">
        <xs:annotation>
            <xs:documentation>Elemento di risposta relativo alla richiesta di certificato del dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="AttivaDispositivo" type="AttivaDispositivoType">
        <xs:annotation>
            <xs:documentation>Elemento per attivare un dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EventoDispositivo" type="EventoDispositivoType">
        <xs:annotation>
            <xs:documentation>Elemento per segnalare un evento dal dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EsitoOperazione" type="EsitoOperazioneType">
        <xs:annotation>
            <xs:documentation>Elemento di esito per l'attivazione di un dispositivo, la trasmissione dei corrispettivi o la segnalzione di un evento</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EsitoOperazioneAttributo" type="EsitoOperazioneAttributoType">
        <xs:annotation>
            <xs:documentation>Elemento di esito per la richiesta di un attributo del dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="TrasmissioneFattura" type="TrasmissioneFatturaType">
        <xs:annotation>
            <xs:documentation>Elemento per inviare una fattura</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EsitoTrasmissioneFattura" type="EsitoTrasmissioneFatturaType">
        <xs:annotation>
            <xs:documentation>Elemento per richiedere l'esito di una fattura inviata</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="RecuperoEsitoFattura" type="RecuperoEsitoFatturaType">
        <xs:annotation>
            <xs:documentation>Elemento per richiedere l'esito di una fattura inviata</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EsitoElaborazioneFattura" type="EsitoElaborazioneFatturaType">
        <xs:annotation>
            <xs:documentation>Elemento di esito per lo stato (esito) della trasmissione fattura</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EventoRichiestaListaMessaggi" type="EventoRichiestaListaMessaggiType">
        <xs:annotation>
            <xs:documentation>Elemento contentente la richiesta per ottenere la lista dei messaggi associati ad un dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EsitoListaMessaggi" type="EsitoListaMessaggiType">
        <xs:annotation>
            <xs:documentation>Elemento contentente la lista dei messaggi associati ad un dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EventoPresenzaMessaggi" type="EventoPresenzaMessaggiType">
        <xs:annotation>
            <xs:documentation>Elemento contentente la richiesta per ottenere il flag che certifica la presenza o meno di messaggi per un dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <xs:element name="EsitoPresenzaMessaggi" type="EsitoPresenzaMessaggiType">
        <xs:annotation>
            <xs:documentation>Elemento contentente il flag della presenza di messaggi relativo ad un dispositivo</xs:documentation>
        </xs:annotation>
    </xs:element>
    
    <!-- =================================================================== -->
    <!-- TIPI                                                                   -->
    <!-- =================================================================== -->
    <xs:complexType name="RichiestaCertificatoDispositivoType">
        <xs:sequence>
            <xs:element name="Csr" type="xs:base64Binary"/>
            <xs:element name="Dispositivo" type="CensimentoDispositivoType" />
            <xs:element name="TecnicoVerificatore" type="TecnicoVerificatoreType" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required" fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="RichiestaAttributoDispositivoType">
        <xs:sequence>
            <xs:element name="Richiesta" type="ParametroAllineamentoType" />
            <xs:element name="TecnicoVerificatore" type="TecnicoVerificatoreType" minOccurs="0" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required" fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="EsitoRichiestaCertificatoDispositivoType">
        <xs:sequence>
            <xs:element name="IdOperazione" type="xs:string" />
            <xs:choice>
                <xs:element name="Certificato" type="xs:base64Binary" />
                <xs:element name="Errori" type="ErroriType" />
            </xs:choice>
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required" fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="EsitoElaborazioneFatturaType">
            <xs:annotation>
            <xs:documentation>Blocco con informazioni sull'esito dell'elaborazione della fattura trasmessa da parte di un RT</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="IdOperazione" type="xs:string" />
            <xs:element name="IdSdi" type="xs:string" />
            <xs:element name="StatoElaborazione" type="StatoElaborazioneFattType" />
            <xs:element name="Descrizione" type="xs:string" />
            <xs:element name="Errori" type="ErroriType" minOccurs="0" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required"                 fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="EventoPresenzaMessaggiType">
        <xs:sequence>
            <xs:element name="DataAcquisizione" type="xs:dateTime" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" fixed="1.0" use="required" />   
    </xs:complexType>
    
    <xs:complexType name="EsitoPresenzaMessaggiType">
        <xs:sequence>
            <xs:element name="DataAcquisizione" type="xs:dateTime" />
            <xs:element name="FlagPresenza" type="xs:boolean"/>
            <xs:element name="DataSistema" type="xs:dateTime" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" fixed="1.0" use="required" />   
    </xs:complexType>
    
    <xs:complexType name="EventoRichiestaListaMessaggiType">
        <xs:sequence>
            <xs:element name="DataAcquisizione" type="xs:dateTime" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" fixed="1.0" use="required" />   
    </xs:complexType>
    
    <xs:complexType name="EsitoListaMessaggiType">
        <xs:sequence>
            <xs:element name="IdOperazione" type="xs:string" />
            <xs:element name="DataAcquisizione" type="xs:dateTime" />
            <xs:element name="Messaggio" type="MessaggioType" maxOccurs="unbounded" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" fixed="1.0" use="required" />   
    </xs:complexType>
    
    <xs:complexType name="MessaggioType">
        <xs:sequence>
            <xs:element name="Codice" type="CodiceType" />
            <xs:element name="Descrizione" type="String500LatinType" />
            <xs:element name="Tipologia" type="TipoMessaggioType" />
            <xs:element name="DataAttuazione" type="xs:dateTime" minOccurs="0" />
        </xs:sequence>
    </xs:complexType>
    
    <xs:simpleType name="TipoMessaggioType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="ANOMALIA">
                <xs:annotation>
                    <xs:documentation>ANOMALIA</xs:documentation>
                </xs:annotation>
            </xs:enumeration>           
            <xs:enumeration value="COMUNICAZIONE">
                <xs:annotation>
                    <xs:documentation>COMUNICAZIONE</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="ANOMALIA BLOCCANTE">
                <xs:annotation>
                    <xs:documentation>ANOMALIA BLOCCANTE</xs:documentation>
                </xs:annotation>
            </xs:enumeration>   
        </xs:restriction>
    </xs:simpleType>
    
    <xs:complexType name="AttivaDispositivoType">
        <xs:sequence>
            <xs:element name="Gestore" type="IdFiscaleType" />
            <xs:element name="TecnicoVerificatore" type="TecnicoVerificatoreType" />
            <xs:element name="GeoLocalizzazione" type="GeoLocType" minOccurs="0" />
            <xs:element name="InformazioniAddizionali" type="InformazioniAddizionaliType" minOccurs="0" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required" fixed="1.0" />
    </xs:complexType>

    <xs:complexType name="EsitoOperazioneType">
        <xs:sequence>
            <xs:element name="IdOperazione" type="xs:string" />
            <xs:element name="Errori" type="ErroriType" minOccurs="0" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required" fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="TrasmissioneFatturaType">
        <xs:annotation>
            <xs:documentation>Blocco con informazioni sulla trasmissione della fattura da parte di un RT</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="NomeFile" type="String100LatinType"  minOccurs="1" />
            <xs:element name="FileFattura" type="xs:base64Binary"         minOccurs="1" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="simulazione" type="xs:string" default="true" />
        <xs:attribute name="versione" type="VersioneType" use="required"    fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="EsitoTrasmissioneFatturaType">
        <xs:annotation>
            <xs:documentation>Blocco con informazioni sull'esito della trasmissione della fattura da parte di un RT</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="IdOperazione" type="xs:string" />
            <xs:element name="IdSdi" type="xs:string" />
            <xs:element name="NomeFile" type="xs:string" />
            <xs:element name="DataOraRicezione" type="xs:dateTime" />
            <xs:element name="Errori" type="ErroriType" minOccurs="0" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required"                 fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="EsitoOperazioneAttributoType">
        <xs:sequence>
            <xs:element name="IdOperazione" type="xs:string" />
            <xs:element name="Richiesta" type="xs:string" />
            <xs:element name="StatoDisp" type="xs:string" />
            <xs:element name="DataStatoDisp" type="xs:dateTime" />
            <xs:element name="Descrizione" type="xs:string" />
            <xs:element name="Errori" type="ErroriType" minOccurs="0" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required" fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="RecuperoEsitoFatturaType">
        <xs:annotation>
            <xs:documentation>Blocco con l'esito della trasmissione della fattura da parte di un RT</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="IdOperazione" type="xs:string" />
            <xs:element name="IdSdi" type="xs:string" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="EventoDispositivoType">
        <xs:sequence>
            <xs:element name="Evento" type="xs:string" />
            <xs:element name="DataOra" type="xs:dateTime" />
            <xs:element name="Dettaglio" type="DettaglioEventoDispositivoType" />
            <xs:element ref="ds:Signature" />
        </xs:sequence>
        <xs:attribute name="versione" type="VersioneType" use="required" fixed="1.0" />
    </xs:complexType>
    
    <xs:complexType name="DettaglioEventoDispositivoType">
        <xs:sequence>
            <xs:element name="Codice" type="CodiceType" />
            <xs:element name="Descrizione" type="xs:string" minOccurs="0" />   
        </xs:sequence>
    </xs:complexType>   
    
    <xs:complexType name="CensimentoDispositivoType">
        <xs:sequence>
            <xs:element name="Tipo" type="TipoDispositivoType" />
            <xs:element name="MarchioFabbricante" type="xs:string" minOccurs="0" />
            <xs:element name="Modello" type="xs:string" minOccurs="0" />
            <xs:element name="RifApprovazioneDispositivo" type="RifApprovazioneType" minOccurs="0" />
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="RifApprovazioneType">
        <xs:annotation>
            <xs:documentation>Blocco da valorizzare se il tipo dispositivo è RT</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="Numero" type="xs:string" />
            <xs:element name="Data" type="xs:date" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="IdFiscaleType">
        <xs:sequence>
            <xs:element name="IdPaese" type="NazioneType" />
            <xs:element name="IdCodice" type="IdCodiceType" />
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="NazioneType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[A-Z]{2}" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="IdCodiceType">
        <xs:restriction base="xs:string">
            <xs:minLength value="1" />
            <xs:maxLength value="28" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="CodiceFiscaleType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[A-Z0-9]{11,16}" />
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="ErroriType">
        <xs:sequence>
            <xs:element name="Errore" type="ErroreType" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
        
    <xs:complexType name="ErroreType">
        <xs:sequence>
            <xs:element name="Codice" type="CodiceType" />
            <xs:element name="Descrizione" type="String500LatinType" />
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="StatoElaborazioneFattType">
        <xs:restriction base="xs:string">
            <xs:length value="2" />
            <xs:enumeration value="EL">
                <xs:annotation>
                    <xs:documentation>EL = Elaborazione in Corso</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            
            <xs:enumeration value="IR">
                <xs:annotation>
                    <xs:documentation>IR = Ricevuta di impossibilita' di recapito</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
    
            <xs:enumeration value="RC">
                <xs:annotation>
                    <xs:documentation>RC = Ricevuta di consegna</xs:documentation>
                </xs:annotation>
            </xs:enumeration>

            <xs:enumeration value="RS">
                <xs:annotation>
                    <xs:documentation>RS = Ricevuta di scarto</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="TipoDispositivoType">
        <xs:restriction base="xs:string">
            <xs:length value="2" />
            <xs:enumeration value="RT">
                <xs:annotation>
                    <xs:documentation>RT = Registratore Telematico</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            
            <xs:enumeration value="DA">
                <xs:annotation>
                    <xs:documentation>DA = Distributore Automatico</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
    
            <xs:enumeration value="MC">
                <xs:annotation>
                    <xs:documentation>MC = Multi Cassa</xs:documentation>
                </xs:annotation>
            </xs:enumeration>

            <xs:enumeration value="DM">
                <xs:annotation>
                    <xs:documentation>DM = Dispositivo Mobile</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="ParametroAllineamentoType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="STATO">
                <xs:annotation>
                    <xs:documentation>STATO</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="GeoLocType">
        <xs:sequence>
            <xs:element name="Lat" type="Amount9DecimalType" />
            <xs:element name="Long" type="Amount9DecimalType" />
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="CodiceType">
        <xs:restriction base="xs:string">
            <xs:minLength value="5" />
            <xs:maxLength value="5" />
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="TecnicoVerificatoreType">
        <xs:sequence>
            <xs:element name="CodiceFiscale" type="CodiceFiscaleType" />
            <xs:element name="PIvaSocieta" type="IdFiscaleType" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="InformazioniAddizionaliType">
        <xs:sequence>
            <xs:choice>
                <xs:element name="DA" type="InformazioniAddizionaliDAType" />
                <xs:element name="RT" type="InformazioniAddizionaliRTType" />
            </xs:choice>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="InformazioniAddizionaliDAType">
        <xs:sequence>
            <xs:element name="ProtocolloComunicazione" type="xs:string" />
            <xs:element name="TipoDistributore" type="xs:string" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="InformazioniAddizionaliRTType">
        <xs:sequence>
            <xs:element name="MatricolaRegistratoreDiCassa" type="xs:string" minOccurs="0" />
            <xs:element name="DataMessaInServizio" type="xs:date" minOccurs="0" />
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="String100LatinType">
        <xs:restriction base="xs:normalizedString">
            <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,100}" />
        </xs:restriction>
     </xs:simpleType>
    
    <xs:simpleType name="String500LatinType">
        <xs:restriction base="xs:normalizedString">
            <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,500}" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="Amount2DecimalType">
        <xs:restriction base="xs:decimal">
            <xs:pattern value="[\-]?[0-9]{1,11}\.[0-9]{2}" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="Amount9DecimalType">
        <xs:restriction base="xs:decimal">
            <xs:pattern value="[0-9]{1,2}\.[0-9]{2,9}" />
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="VersioneType">
        <xs:restriction base="xs:string">
            <xs:maxLength value="5" />
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
 
Upvote 0
Top