10

I need some help with conversion of DocBook files to Microsoft Word files.

Do I need an XSL file for the transformation?

1

4 Answers 4

6

Yes, you do need an XSL file. You can get XSL files for DocBook from the free DocBook XML distribution. Then, you run a free XSLT transformer such as Saxon. If you run Saxon from a command line, you give it the name of your DocBook file, and the name of one of the stylesheets, and it will transform your file according to the rules in the stylesheet.

What you need to do to transform to Word, is to pick the right stylesheet.

From DocBook XSL: The Complete Guide, here are three possibilities:

  • Convert to XSL-FO and then use the XMLmind to export to Word. See the XMLmind website for more information.
  • Use a limited set of tags and then use one of DocBook XML's included stylesheets to output to WordML.
  • Try to use Jfor to output to RTF, although Jfor no longer appears to be maintained.

And I have one of my own:

  • As above, use one of DocBook XML's included stylesheets to publish to XSL-FO, then run Apache FOP to convert from XSL-FO to RTF. You will lose the structural information, but you will keep a certain amount of the formatting.
2
  • 1
    There is no difference in "our own" and JFor, since JFor code has been donated to fop...which explains why jfor is no longer maintained.
    – malat
    Jun 12, 2013 at 8:29
  • @martin-jakubik Steve Ball's website linked in your answer is reported as a security risk by FireFox due to self-signed server certificate (MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT). It might be better to remove the link.
    – lbo
    Jun 15, 2019 at 13:40
1

I recently implemented same feature for our users. They use Oxygen XML editor that allows for easy transformations via XSL. I was going to do OOXML but settled on WordML. As a starting point I used roundtrip XSL, but I had to rewrite lots of templates because of existing bugs or just missing functionality. In addition, I did other customization to serve a purpose or for our XML file only.

I would not mind contributing back to the project, but don't really know how to get about it.

1
  • 3
    Hi Mike, any chance that you can post the xslt files on github? Regards, Jan
    – Jan
    Apr 11, 2012 at 9:26
1

I know this is an 11 years old question. But now, in 2022 you can use pandoc to convert DocBook to MS Word (docx).

pandoc --from docbook --to docx --output filename.docx filename.docbook
2
  • How can pandoc handle the <xi:include?
    – albert
    Aug 19, 2022 at 11:41
  • @alber Sorry I didn't answer immediatly, but I don't really know much docbook. I guess it can't as I think pandoc parses only the contents of the target file (in the example filename.docbook).
    – zazke
    Nov 15, 2022 at 2:22
0

I am using XQuery to transform DocBook into various formats using XQuery typeswitch library. XQuery uses indexes so I can transform many documents very quickly.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.