Advice on replacing one document's content.xml with another?

Removing the soft-page-breaks from the .odt file made no difference to the .docx file produced, as far as the spurious page breaks.
When I look at the source .odt’s XML, I can’t see any markup that would induce a page break at the spurious points. But if I Save As .docx from the .odt file and look at that .docx in Writer itself, it too shows the spurious page breaks.
And I see it’s Writer that breaks the page styling and messes up the headers and footers.
So I’m thinking I need to file a bug report for Writer’s .docx generation.

I’d like to produce variant versions of my book from a single master version, where the main differences are just in the formatting. The simplest example is creating a 4"x7" edition by just unzipping a 4x7 template .odt and the book’s master 5"x8" edition, copying the 5"x8" edition’s content.xml file into the unzipped template, editing the ISBN and then re-zipping. I use the same name paragraph styles in all variants.

If the differences are simply different formatting, and if you do all your formatting with styles, and if you do in fact use the same named styles, then there is a much easier way to change from your master document to a differently formatted version without having to hack the content.xml file.

  1. Download and install the Template Changer extension.

  2. Create a template for each of the different formats you want, using exactly the same style names in each template.

Now you can use the Template Changer extension to change the template assigned to the document, if you want to change the formatting of the document; or you can make a copy of the document and use Template Changer on the copy if you want a separate document in a different format.

Thanks, I’ll investigate that, it sounds very helpful.

tl;dr - I don't think Writer can do what I need. I'm afraid I've come to the decision it's not really suitable for writing books, at least not if you want to produce multiple formats or layouts.

I've just spent a week learning about Master Documents.

Unfortunately, because the natural (most efficient) way to use Writer is to use direct formatting, I found from my experiment that the body of my document is rife with apparently random stretches of text that's been directly formatted:

![image description](upload://aMdTRL3wj6CKwTQXF5yLX98n75Z.png)

I wrote all this, yet I can't imagine why *any* of the text that appears as 10.5pt inside the 9pt text was directly formatted.

Sadly, the amount of work needed to correct that would be absurd. Far higher than I'm ever likely to save from having a single file in which to make corrections, rather than making the same corrections to four separate copies. I can't even see a semi-automatic way to remove the direct formatting. Just finding it is difficult - though I could now use a master document to see the DF text by manual inspection.

Now, given that I use only three character styles, Writer's design decision to create a new unnamed character style whenever DF is used, is exactly the reverse of what I want.

I can't see a way to remove all direct formatting, since I need a function which would remove it all without changing the visual appearance: in other words, a way to map the DF text to an existing 'base style' (regular or emphasis). Without that, I'd be looking at I think hundreds of hours of mind numbing, error prone manual work.

I think the design of the direct formatting feature of Writer ("assume the most complex interpretation is what the user desired, rather than the simplest"), is going to be the issue which finally pushes me to find some other word processor, after using Writer for approximately 15,000 hours. I find that sad.

because the natural (most efficient) way to use Writer is to use direct formatting

This is the initial flaw in your use of Writer. It is neither “natural” (only inspired by ubiquitous M$ Word workflow) nor “efficient” (and this is an understatement: from the app point of view, zillions of DF formatted sequences is a waste of resources; form the author point of view, you end up with of loss of information).

You can have the same “typing economy” with styles once they are defined (e.g. Ctrl+B can be reassigned to Strong Emphasis character style, etc.). Don’t confuse UI (the gestures to activate features) with semantics (the significance of sequences). They live in different levels of the workflow.

Of course, once a large document is fully DF, it is next to impossible to restyle it in a reasonable amount of time. And as such, you are deprived of the automatic reformatting outlined in question 262553.

Link to question 262553

Contrary to your statement, Writer is perfectly fit to write books even in multiple formats. For that, you can’t just “TLDR” (too long, don’t read) and start to type blindly. Every tool is specific and you must learn how to use it. Your goal (single source, multiple formats with different constraints) is a complex one and must be addressed from the start. Otherwise, you end up with what you experience: without provision for the key points, you are compelled to re-layout manually every version.

You said you’ve used Writer for ~15k hours. You should then be an expert provided you explored the features. Have you spent some time, let’s say a comfortable 50 hours, to read the manual before starting? What are 50 hours compared to 15k? Have also thought about the semantic organisation of your book? How much of your author creative job is seeded in the doc struct?

As you say, if I had known just how big the problem of DF was, and had assigned Ctrl-I to set Emphasis character style, I might be in good shape.

I say "might", not "would", because I can't believe that all the DF text is due to changes to or from italics or bold. I suspect there's some other common operation which makes text DF.

Yes, I've thought about the semantic organisation of my books. They're pretty good - each time I find an issue with paragraph or page styles I try to fix it through styles. What I didn't expect was the DF character style mess caused by using default editing features of Writer.

I'll do a few experiments to see if I can work out what causes DF text, since it's hard for me to believe it's all stemming from toggling between italics and regular.

Of the 15k hrs, most of it was *using* it, not explicitly learning it. I've probably spent 100-200 hrs studying Writer itself. DF is not documented anywhere: your explanation above is the best I've seen.

DF is not documented anywhere

I agree that there’s not much mentioning of it in the help - but still there are; like here.

because I can’t believe that all the DF text is due to changes to or from italics or bold

I strongly suspect that coming from e.g. copying text with formats from other sources, like other documents of web pages. Such text should better be inserted without formatting, to not bring its problems along with its text. When you pasted a text with size 15, color Black, background pale-yellow, … into your document, then copied something from this place to another, you started to proliferate the places that enjoy that set of unknown formatting nightmare that had landed when you pasted it from Web for the first time…

  • I don’t think Writer can do what I need. I’m afraid I’ve come to the decision it’s not really suitable for writing books, at least not if you want to produce multiple formats or layouts. *

That is unbelievably easy to do and is precisely what LO is designed to do.

It is unfortunately your “incorrect use of LO for writing a book when you want multiple versions” which is causing the problem. It is not a problem with LO and all other word processors will do the same. Your method of Direct Formatting is excellent for “single-use, short documents” but terrible for “a book when you want multiple versions”.

It is done using styles where you designate things to be paragraphs, chapter headings, quotes etc; and where you choose Page Styles for the various pages (Title Page, First Page of chapter, ToC, Front matter etc). Read Writer for Students which is very good and explains all you need to know. See also the Writer Guide chapters on using Styles.

All you now have to do is to change the Page Styles and change the other Styles and Bingo! You have your new book to a completely new format.

Unfortunately you have used Direct Formatting which overrides the underlying Style and defeats the whole object of using Styles.

In your situation I would first (working on a copy) remove all the Direct Formatting by Edit > Select All > Ctrl+M. You now have a file of Default plain text with no formatting - it is just like a Notepad file. You now apply the Styles to this vanilla text.

You now define the Page Styles, and Paragraph Style, Chapter Heading Style and Quotes Style, etc, you want for your first book. You now apply those Styles to the plain text. You now have your first book. It would take me about an hour for a 300 page book.

Starting with your plain text file, you now define the second book Page Styles, and Paragraph Style, Chapter Heading Style and Quotes Style, etc, and apply them. You now have your second book. Again, it should take about an hour for a 300 page book.

Trust me. It will be far quicker and far easier to remove all the Direct Formatting you have used and apply the Styles to the plain text than to try to apply Styles to formatted text.

If you have completed your document as a single file there seems little point in converting it to a Master Document with sub-documents.

NB Don’t even think of messing about with content.xml as therein lies a recipe for a complete disaster. Do it properly using Styles. A “text:soft-page-break/” is inserted into content.xml by LO to force a Page Break on your screen according to the Page Style currently in use. If you change the Page size, LO will move these tags to different places to give the new page breaks on screen.

Also remember how LO works - LO always uses Styles but users often override them.

When you create a new document and start typing what you type is in the Style of Default text. If you then want a Chapter Heading you have two choices:

Choice 1 - Direct Formatting. Highlight the text and apply Bold, font size, font etc until it looks how you want

Choice 2 - Use Styles. Highlight the text and select the Chapter Heading Style for it.

Note how in Choice 2 every Chapter Heading will be identical because you did not have to remember what font, font size etc you want to use. Choice 1 is very error prone.

If you use Choice 2 and you want to change the Chapter Heading format all you need to do is edit the Chapter Heading Style. Every Chapter Heading now takes the new Style. With Direct Formatting you have to edit each one separately which is time consuming and error prone.

See my (long) answer to question 258664/in-book-publishing-how-best-to-change-the-page-size-for-a-new-edition/#258683 where I explain how to avoid the one-hour style change when you want a new edition (assuming the new edition is not a replacement but coexists with the first).

You need one master document per edition (optionally based on the same template to inherit common shared styles) which include the novel text as a sub-document. Covers may be different and they are formatted directly in the masters. The masters will also show a unique ISBN.