Difference between styles and automatic-styles

Hello,
I’m creating an odt document by writing the raw code in content.xml.
I don’t understand what is the difference between defining a new style in the <office:automatic-styles> block and defining a new style in the <office:styles> block ?

Do you have already download the specification? https://www.oasis-open.org/standards#opendocumentv1.2

Here some quotes from section 3.15, part 1.

In 3.15.2 office:styles

The office:styles element contains common styles used in a document. A common style is a style chosen by a user for a document or portion thereof.

In 3.15.3 office:automatic-styles

The office:automatic-styles element contains automatic styles used in a document. An automatic style is one contains formatting properties that are considered to be properties of the object to which the style is assigned.
Note: Common and automatic styles behave differently in OpenDocument editing consumers. Common styles are presented to the user as a named set of formatting properties. The formatting properties of an automatic style are presented to a user as properties of the object to which the style is applied.

In short, office:automatic-styles corresponds to direct formatting of an object and office:styles correspond to the settings via style&formatting window. Although automatic styles “are considered to be properties of the object” it is not forbidden to use the same automatic style for more than one object. You have no UI for doing so, but you can do it in the file itself.

Thank you. Does that mean that office:styles is useless in order to write the raw code ? I can put everything in office:automatic-styles ?

No, it depends on the attribute and element. It is mentioned in the spec, when automatic-style is not possible. Or you look into the Relax-NG schema, to see whether it is allowed or not. Compare element name=“office:styles” (~line 493) to element name=“office:automatic-styles” (~line 550). http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-schema.rng

I really don’t understand. The only styles I define are styles for paragraph, text, tables, pages. What is the best option for such styles ?

@Stla, if you are creating files that will be edited later by humans, not software, the best option is office:styles, as the user will be able to choose the styles inside the document to edit it consistently. office:automatic-styles, which are invisible to the human user, are only used when the (human) user apply the formatting directly to the object (character, paragraph, box etc.).
I think the specs were defined this way to avoid ambiguities between software reading and writing documents.