Generally the way to get data into and out of LibreOffice in the manner you are indicating is via an Extensible Stylesheet Language Transformation (XSLT) filter. While this requires an understanding of the XML Schema Definition (XSD) of the sending and receiving formats, it does not explicitly reference the XSD. This OO Forum thread gives a decent example of the type of import and export XSLT filter that is required to convert data in a foreign XML structure to and from Calc XML.
The Tools > XML Filter Settings… menu is where these types of filters are designed and recorded. Help page is here.
I am going to expand my original answer to give a very basic outline of what it is you require. You have a Calc spreadsheet, which stores data (e.g., A1=123abc) in XML (the content.xml
file) like this:
<office:spreadsheet>
<table:table table:name="Sheet1" table:style-name="ta1">
<table:table-column table:style-name="co1" table:default-cell-style-name="Default"/>
<table:table-row table:style-name="ro1">
<table:table-cell office:value-type="string">
<text:p>123abc</text:p>
</table:table-cell>
</table:table-row>
</table:table>
<table:named-expressions/>
</office:spreadsheet>
You need to take this data structure (and the data within it) and turn it into your particular XML data structure, which is defined by an XSD (datasetAppaltiL190.xsd). This XSD has a data
element, which is likely where the data from the ODS needs to be mapped to, defined as:
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="lotto" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="cig" type="legge190:CigType" nillable="false"/>
<xsd:element name="strutturaProponente" nillable="false">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="codiceFiscaleProp" type="legge190:codiceFiscaleType" nillable="false"/>
<xsd:element name="denominazione" type="legge190:denominazioneType" nillable="false"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="oggetto" type="legge190:oggettoType" nillable="false"/>
<xsd:element name="sceltaContraente" type="legge190:sceltaContraenteType" nillable="false"/>
<xsd:element name="partecipanti">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="raggruppamento" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="membro" type="legge190:aggregatoType" minOccurs="2" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="partecipante" type="legge190:singoloType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
... etc ...
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
That is not the actual data, but rather a definition of how the data should be structured. The actual data in the resultant XML, based on the above definition, will look something like:
<data>
<lotto>
<cig></cig>
<strutturaProponente>
<codiceFiscaleProp></codiceFiscaleProp>
<denominazione></denominazione>
</strutturaProponente>
<oggetto></oggetto>
<sceltaContraente>
<codiceFiscaleProp></codiceFiscaleProp>
<denominazione></denominazione>
<partecipanti>
<raggruppamento>
<membro></membro>
<membro></membro>
... etc ...
</raggruppamento>
<partecipante></partecipante>
<partecipante></partecipante>
... etc ...
<raggruppamento>
... etc ...
</raggruppamento>
</partecipanti>
</sceltaContraente>
</lotto>
<lotto>
... etc ...
</lotto>
</data>
Furthermore, the data type for each XML element (e.g., <cig>
) is defined in a separate XSD (TypesL190.xsd) that is referenced by the main XSD. In this secondary XSD, the CigType
data type for the <cig>
element is defined as:
<xsd:simpleType name="CigType">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
… in other words a string of up to 10 characters. In order to map the data in cell A1 of the ODS to the <cig>
element in the output XML you will need to write an XSLT that includes code something like:
<xsl:template match="table:table">
<xsl:for-each select="table:table-row">
<xsl:if test="position()=1">
<data>
<lotto>
<!-- Process the lotto data -->
<xsl:for-each select="table:table-cell">
<xsl:choose>
<xsl:when test="position()=1">
<cig><xsl:value-of select="text:p"/></cig>
</xsl:when>
<xsl:when test="position()=2">
<strutturaProponente>
<!-- Process the strutturaProponente data -->
Note that this is a very basic (and possibly not perfectly accurate) example based on what was demonstrated in the OO Forum link I provided above. You will need to determine the valid structure according to the XSD definitions. The logic to build valid output XML will need to be carefully written into the XSLT. There are probably XML tools that can assist in this process, but I cannot recommend any as I have not used any.