xslt Filter of gpx file gives empty output

Discuss the spreadsheet application

xslt Filter of gpx file gives empty output

Postby jotess » Mon Mar 04, 2019 12:52 am

Hello,
I hope this old thread is going to be read ... but my question is related exactly to these filters:
I have been able to install xml filters from the example in this thread: viewtopic.php?f=45&t=3490, so it should not be a general problem of installing an xsl file correctly.

I can chose gpx as a file format and import a gpx file, just the resulting ods file is empty.
Shortened example:
Code: Select all   Expand viewCollapse view
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<gpx version="1.1" creator="OsmAnd+" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
  <trk>
    <trkseg>
      <trkpt lat="49.8526895" lon="8.6383426">
        <ele>136.86</ele>
        <time>2017-11-15T21:49:00Z</time>
        <hdop>3.0</hdop>
        <extensions>
          <speed>4.916522979736328</speed>
        </extensions>
      </trkpt>
  </trkseg>
  </trk>
</gpx>


Okay, the mismatch between the fields used and maybe even the order in which they appear might matter. Would tags that are not mentioned in the xsl file just be omitted? And would values expected by the template but not found in the gpx file just generate emtpy cells? That's what I expect, but anyway, I reduced the import xsl file to:
Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>
<!--Repris d'un document généré par ooo 3.0 -->
<xsl:stylesheet
    xmlns:defaultns="http://www.topografix.com/GPX/1/1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
    xmlns:math="http://www.w3.org/1998/Math/MathML"
    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
    xmlns:ooo="http://openoffice.org/2004/office"
    xmlns:ooow="http://openoffice.org/2004/writer"
    xmlns:oooc="http://openoffice.org/2004/calc"
    xmlns:dom="http://www.w3.org/2001/xml-events"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:rpt="http://openoffice.org/2005/report"
    xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
    xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#"
    xmlns:field="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:field:1.0"
    xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
    version="1.0">
    <!--output trouvé dans le xsl spreadsheet xml -> ods -->
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

    <!--trouvé dans xls gpx2gp -->
    <xsl:strip-space elements="*"/>

    <!--boucle principale, réalisé une seule fois pour tout le document -->
    <xsl:template match="defaultns:gpx">
              <office:document>
               <office:body>
                <office:spreadsheet>
                 <table:table>
                  <table:table-row>
                <table:table-cell office:value-type="string"><text:p>lat</text:p></table:table-cell>
                <table:table-cell office:value-type="string"><text:p>lon</text:p></table:table-cell>
                <table:table-cell office:value-type="string"><text:p>ele</text:p></table:table-cell>
                <table:table-cell office:value-type="string"><text:p>time</text:p></table:table-cell>
                  </table:table-row>

    <!--appelle le template suivant à cette position car il est interdit de les encastrer -->
                 <xsl:for-each select="defaultns:trk/defaultns:trkseg/defaultns:trkpt">
                  <table:table-row>
                  <table:table-cell><text:p><xsl:value-of select="@lat"/></text:p></table:table-cell>
                 <table:table-cell><text:p><xsl:value-of select="@lon"/></text:p></table:table-cell>
                 <table:table-cell><text:p><xsl:value-of select="defaultns:ele"/></text:p></table:table-cell>
                 <table:table-cell><text:p><xsl:value-of select="defaultns:time"/></text:p></table:table-cell>
                </table:table-row>
                 </xsl:for-each>

                </table:table>
               </office:spreadsheet>
              </office:body>
            </office:document>
           </xsl:template>
</xsl:stylesheet>


and the test gpx file to:
Code: Select all   Expand viewCollapse view
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<gpx version="1.1" creator="OsmAnd+" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
  <trk>
    <trkseg>
      <trkpt lat="49.849837" lon="8.625592">
        <ele>122.86</ele>
        <time>2017-11-15T21:44:47Z</time>
      </trkpt>
    </trkseg>
  </trk>
</gpx>


So these are the very basics and I believe everything matches. But still: The imported ods file is just empty.

Any idea anybody?

Best regards
Joachim

 Edit: Split from xslt Filter - by robleyd 
Libreoffice 6.0.7.3 onWindows 10
jotess
 
Posts: 1
Joined: Sun Mar 03, 2019 11:44 pm

Re: xslt Filter

Postby MrProgrammer » Tue Mar 05, 2019 7:31 am

jotess wrote:I hope this old thread is going to be read ... but my question is related exactly to these filters
Hi, and welcome to the forum. This isn't your topic and just because your question seems similar to you doesn't mean that the problem you're having is the same. You should have opened a new topic and then referenced this one in your topic. I will reply once only to you in this topic.

jotess wrote:
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<gpx version="1.1" creator="OsmAnd+" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
  <trk>
    <trkseg>
      <trkpt lat="49.849837" lon="8.625592">
        <ele>122.86</ele>
        <time>2017-11-15T21:44:47Z</time>
      </trkpt>
    </trkseg>
  </trk>
</gpx>

Any idea anybody?
Windows 10 has Linux, correct? This sed program
1i\
lat,long,ele,time
/^ *<trkpt /!d
N
N
s/[ <>=\/aeiklmnoprt]//g
s/""/,/
s/"//g
y/\n/,/

on my Unix system transforms your input file above into this CSV file:
lat,long,ele,time
49.849837,8.625592,122.86,2017-11-15T21:44:47Z

Or you could use Perl. I realize that XLST is the correct way to perform the transformation but I have sed working and you don't have XSLT working. It only took me about ten minutes to write/test the sed program and I don't use it often enough that I'm an expert.
Mr. Programmer
AOO 4.1.5 Build 9789 on MacOS 10.11.6.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Moderator
 
Posts: 3839
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: xslt Filter of gpx file gives empty output

Postby hol.sten » Thu Mar 07, 2019 8:58 pm

I gave your xslt filter and both gpx example files a quick try on my computer running Linux Mint 19.1 and LibreOffice 6.0.7.3.

I didn't change anything in your above posted files, just installed the xslt filter and could afterwords without any problem successfully import both gpx xml examples. For both files I got a first lines with column names and a second line with the gpx data. So in my opinion something must be wrong with your filter installation.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
hol.sten
Volunteer
 
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany


Return to Calc

Who is online

Users browsing this forum: floris v, Google [Bot] and 37 guests