Xslt export to custom xml format does not select any table rows

I imported data from a .csv file, added some columns with computed values and wanted to export the data from each row to a custom xml format.

I created a xslt file, added it to the filters and ran the test.
It produces a xml file but with empty data where the table:table-row data is supposed to be.

I appended a test xslt file that I used that also doesn’t get any table rows.
I know that that’s html, but it’s just for testing and produces the same non-results as my other .xslt file.
So I assume that some setting with my Calc has to be wrong.

Any ideas?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  exclude-result-prefixes="table text"
>

  <xsl:output
    method="xml"
    indent="yes"
    encoding="UTF-8"
    omit-xml-declaration="no"
  />

  <xsl:template match="/">

    <html>
      <body>

      <table>
        <xsl:for-each select="//table:table-row">

          <xsl:if test="position() > 1">

            <tr>
              <td>
                First Column Value
              </td>
              <td>
                <xsl:value-of select="table:table-cell[1]/text:p" />
              </td>
            </tr>

          </xsl:if>

        </xsl:for-each>
      </table>
      </body>
    </html>

  </xsl:template>

</xsl:stylesheet>

The output I get:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <body>
    <table/>
  </body>
</html>

I still couldn’t figure out what I may be doing wrong.

Are there any other ways or places I could ask for help, maybe even payed support?

I actually do exports to a custom xml quite often, but checking my options some years ago I decided to write the xml directly by a SQL-query and use a quite simple report to generate this as text. (A macro now calls the report, which gets its data from the query, then the redult is SavedAs Text-with-charset-selection:utf and extension .xml
.
If I’m remembering right I have only seen one xslt-import (to get data from a fitness-tracker from xml-export into Calc), so I cant point to examples for working xml-export via xslt-filter.
.
If you need details of my solution, just tell. I’m using Base, but as Calc-Files are possible as datasource the method should be adaptable without bigger problems.

Crosspost at

Thanks for your ideas!

Your solution sounds like I would go for that if really nothing else works. I want to try again with the inbuilt xslt-filters, because I want to use what’s actually intended to use.

I checked the existing xslt-export filter files that work with Calc and export to other formats, they do a bunch of things with setting global variables and defining reusable templates.

My basic example doesn’t produce any errors and does produce a xml file. Like many other xslt-export-filter examples I found that are similarly basic to mine.

But for some reason I can’t get any data to iterate over in the for-each select statement although I checked with other tools that the path and everything is correct.

Maybe your working xml-export examples do something I haven’t tried yet, so I’d be open to and appreciate it if you could point me to them:)

I don’t know what was different back then, but I have since managed to get it to work. I tested the exact xslt file I posted above and it’s working without any issues.
Maybe it was something that was fixed with a new libreoffice release, I don’t know, really.

Output:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <body>
    <table>
      <tr>
        <td>
                First Column Value
              </td>
        <td>2</td>
      </tr>
      <tr>
        <td>
                First Column Value
              </td>
        <td>3</td>
      </tr>
      <tr>
        <td>
                First Column Value
              </td>
        <td>10</td>
      </tr>
      <tr>
        <td>
                First Column Value
              </td>
        <td>11</td>
      </tr>
      <tr>
        <td>
                First Column Value
              </td>
        <td>23</td>
      </tr>
      <tr>
        <td>
                First Column Value
              </td>
        <td>27</td>
      </tr>
      
      [...]
      
    </table>
  </body>
</html>