Ask Your Question
3

Calc: how to export to xml [closed]

asked 2013-06-14 11:01:52 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Is there a way to export a spreadsheet from calc tom xml according to an .xsd scheme?

thanks

EDIT 2013-06-15
(moved the second comment by @vergna to the original question)

xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xsd:include schemaLocation="TypesL190.xsd"/>   
    <xsd:element name="indici">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="metadata">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="titolo" type="xsd:string"/>
                            <xsd:element name="abstract" type="xsd:string"/>
                            <xsd:element name="dataPubblicazioneIndice" type="xsd:date" nillabl
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-11-02 18:40:19.128370

Comments

1

I don't understand your question. Can you please elaborate? ODF is defined by a schema and is in XML. An XML Schema Definition (XSD) as the name suggests is simply any such definition, for example here are some OOXML Strict XSDs used for testing LO. Are you referring to Extensible Stylesheet Language Transformation (XSLT) filters for converting ODS to a different XML schema?

oweng gravatar imageoweng ( 2013-06-14 11:37:21 +0200 )edit

I have a spreadsheet that is to be exported in xml according to a precise pattern

vergna gravatar imagevergna ( 2013-06-14 13:06:12 +0200 )edit

Thanks for the example. Is it possible to post a link to the entire XSD? Surround the link text with square brackets in your comment and follow it immediately with the url in round brackets. The bit shown is only really the header info and does not cover the data. I will provide an answer, but will need to come back and edit it for clarity.

oweng gravatar imageoweng ( 2013-06-14 14:20:19 +0200 )edit

Thanks for providing the entire XSD. I have updated my answer to give an example of how to go about creating an XSLT based on your XSD.

oweng gravatar imageoweng ( 2013-06-18 07:40:28 +0200 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2013-06-14 14:31:34 +0200

oweng gravatar image

updated 2013-06-18 07:38:40 +0200

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 ... (more)

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-06-14 11:01:52 +0200

Seen: 15,006 times

Last updated: Jun 18 '13