How check ODF version

There are several ODF format version available in LO:
(as you can see in the screenshot below)

My question is: I have an ODF file, let’s say spr.ods. How can I retrieve which format version spr.ods use?

I checked “Properties” dialog under File, with no luck

NB: this applies both to .ods file and .odt, …

1 Like

There’s the office:version attribute for several XML streams of the document’s zip container. For ODF 1.3 it has the value 1.3. See 19.390 office:version of the ODF standard part 3. Whether extensions are stored can be determined by expecting the declared XML namespaces.

A quick check can be done by inspecting the document zip’s META-INF/manifest.xml stream (see also 4.16.14 manifest:version of ODF part 2), there is for example

<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.3" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0">

where

manifest:version="1.3"
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"

denote ODF 1.3 extended (with xmlns:loext, LibreOffice extensions).

Theoretically dDifferent streams can be in different versions, so content.xml or styles.xml might actually have different office:version attribute values than the overall <manifest:manifest manifest:version="1.3">, but for LibreOffice in practice that doesn’t happen (AFAIK)(did not know enough).

You may have to check for different xmlns extension namespaces for different streams though if you need details; the LibreOffice extensions are xmlns:loext but other creators/generators may have other extension namespaces.

1 Like

See also: tdf#134447

It does. We do write 1.2 left and right for some streams when using 1.3; I don’t have a reference at hand, but I see those things regularly :slight_smile:

1 Like

Hm yeah, might happen if a module or part doesn’t need any newer feature and explicitly sets the version, I thought it was set at a global level.

@mikekaganski thanks for pointing out to the bug/feature request, since I was just looking there in the bugtracker

Let’s try with a macro.

' Returns LO version of document.
' - filePath Path To document (URL or OS native).
Function GetOfficeVersion(ByVal filePath As String) As String
  Dim oZip, oDom
  GetOfficeVersion=""
  On Error GoTo ErrLabel
  oZip=com.sun.star.packages.zip.ZipFileAccess.createWithURL(ConvertToUrl(filePath)) 
  oDom=createUnoService("com.sun.star.xml.dom.DocumentBuilder").parse(oZip.getByName("meta.xml"))
  GetOfficeVersion=oDom.FirstChild.getAttribute("version")
ErrLabel:  
End Function

Sub TestGetOfficeVersion
  Msgbox GetOfficeVersion("C:\temp\Example2.ods")
End Sub
1 Like

thanks @sokol92 it works easily
I mark your answer as solution but I hope in the future release, something will be implemented in the UI

There is and ODF validator provided by The Document Foundation (LibreOffice)
https://odfvalidator.org/
It shows the ODF file version.

2 Likes

Thanks, it worked. I initially selected “Auto-Detect” in ODF Version. But later, I entered each version by trial and error, and for the said file, It passed the tests for ODF 1.2 (extended conforming).

Regards
Ishaan Khaperde