FODT Write Error. The file could not be written.

Dear LibreOffice Community,

I programmatically generate a FODT that opens without any problem and
can be edited.

When saving such FODT document I get "Write Error. The file could not be
written.".

BTW the document is valid XML, is there a method to debug such issue?

I tried -DXSLTransformer.statsfile=/tmp/xslt_debug.txt as a Java startup
parameter but the file is not created and I'm not sure that Java's XSLT
is called when saving a document.

Thanks a lot,
ascii

https://ask.libreoffice.org/en/question/190226/fodt-write-error-the-file-could-not-be-written/

Dear LibreOffice Community,

sorry to bother, do you think there is a better place to ask such
question?

I'm available to rebuild Libreoffice with symbols and debug it with
a little guidance (c++ sources are huge!).

Thanks,
Francesco

Hi Francesco,

Can it be saved to any of the other formats, eg odt or docx?

Can you provide such generated fodt-file?

Do you have compared, that a version without content is the same if saved from LibreOffice as if generated by your application?

Which OS? Correct rights?

Kind regards
Regina

With the info provided - sounds like a permission problem.
Which folder are you writing too?
Right click and see what the permissions are.

Dear LibreOffice Community,

sorry to bother, do you think there is a better place to ask such
question?

I'm available to rebuild Libreoffice with symbols and debug it with
a little guidance (c++ sources are huge!).

You really do /not/ want to go there :-} :-}

Thanks,
Francesco

Dear LibreOffice Community,

I programmatically generate a FODT that opens without any problem and
can be edited.

When saving such FODT document I get "Write Error. The file could not be
written.".

You might get more help if you included information such as your OS and the LO version.

There are a couple of very obvious things to check meanwhile - are the file and directory permissions set to allow you to do the save?

As it's flat xml, try opening it in your choice of ordinary text editor and seeing if you can do the equivalent save operation from there (you don't say why you think it's an LO issue).

Hi Regina, Wade and Mike,

thanks for your time.

The problem is common to multiple workstations (various Ubuntu LTS), on
my system the version is 6.0.7.3 (Build ID: 1:6.0.7-0ubuntu0.18.04.5).

As a side note the document was working till an unspecified update, so
I think it has to do with the XML itself and it's not a permission
error ("strace -ff -e open,openat,fstat,read" does not show anything
related to that).

It does succeed to save in DOCX format but fails in ODT and FODT (that
are the formats we prefer).

When saving in ODT:
  Error saving the document report_233:
  Write Error.
  Error in writing sub-document styles.xml.

When saving in FODT:
  Error saving the document report_233:
  Write Error.
  The file could not be written.

Other times I get a generic I/O error.

The smallest file that gives that error is:

http://paste.arn-fai.net/?2873952

By removing the whole 'FooterTable_Row' it successfully saves an FODT.

By removing 'style:family="table-cell"' it successfully saves an FODT.

How can I debug such issues in the future without going trial and error?

Thanks and have a great day,
Francesco

For a start, there are XML errors in your document:

Line 122:
<style:paragraph-properties fo:margin-top="3.9402in" fo:margin-bottom="0.0799in" style:contextual-spacing="false" fo:break-before="page"/>
  </style:style>

style:contextual-spacing is not an allowed attribute.

Line 133:
  <style:style style:name="FooterTable_Right" style:family="4.1354inn">
   <style:table-column-properties style:column-width="4.425in" style:rel-column-width="6372*"/>
  </style:style>

style:family="4.1354inn" is wrong. It seems the style:family is mixed up with some measurement.

Line 153:
There is a second <office:master-styles> element. There should be only one of these.

Line 162:
<office:body>
</office:body>

The <office:body> element must not be empty. Add an <office:text> element.

Francesco Ongaro <ongaro.f@gmail.com> writes:

By removing the whole 'FooterTable_Row' it successfully saves an FODT.

By removing 'style:family="table-cell"' it successfully saves an FODT.

You should put the table-related styled (style:family="table*") inside the <office:automatic-styles> rather than the <office:styles>.

<office:styles> is meant to be used for named styles that the user can select through the user interface, for example the Styles and Formatting side bar, or the Styles menu. The user interface doesn't have named table column, row or cell styles. On the other hand <office:automatic-styles> is for styles that are directly set in an object.

With these changes (and the corrections to the XML in my previous message), it works.)

Thanks Piet,

your knowledge on the matter is really helpful!

Seeing your advice I can only imagine how many errors my templates
contains.

Just two questions:

- How do you validate your FODT files?

- Do you have a preferred documentation reference for generating FODT
files?

I think that the error UI is not correctly describing what is an XML
error and it should prompt a more specific error message (for example
"Cannot save malformed XML") and maybe a technical detail could be
outputted to in the console.

I submitted the following bug report:

https://bugs.documentfoundation.org/show_bug.cgi?id=125019

Maybe this issue is impacting even other users.

Thanks,
Francesco

Francesco Ongaro <ongaro.f@gmail.com> writes:

Thanks Piet,

your knowledge on the matter is really helpful!

Seeing your advice I can only imagine how many errors my templates
contains.

Just two questions:

- How do you validate your FODT files?

I just loaded the FODT file in Emacs, and it indicated some errors.

- Do you have a preferred documentation reference for generating FODT
files?

You may look at http://opendocumentformat.org/developers/

I did check the file against the OpenDocument documentation.
http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.pdf and related documents.