title: XML to Word using custom paragraph styles and XSLT
body: <p>I've got an XML file that contains mostly textual information (list of questions in <a href="https://docs.moodle.org/29/en/Moodle_XML_format" rel="nofollow noreferrer">Moodle XML format</a>). I'd like to convert it to a document that can be opened by MS Word, but I'd like to maintain context (using paragraph styles) so I can convert it back to Moodle XML. Here's what I tried so far:</p>
  
  <ul>
  <li><p>I was excited to find several tutorials (e.g., <a href="http://www.techrepublic.com/blog/10-things/10-plus-tips-for-using-word-as-an-xml-editor/" rel="nofollow noreferrer">a</a>) about how to use XML in Word, but many of them are moot given the <a href="http://www.i4i.com/x4w.htm" rel="nofollow noreferrer">result of the i4i patent dispute</a>. </p></li>
  <li><p>I made a prototype with RTF with XSLT, but the RTF styling and Unicode support is complex. </p></li>
  <li><p>I've seen a way to use <code>&lt;p class="myCustomStyle"&gt;</code> with HTML documents which can be opened in Word. But HTML style sheets and mapping them to Word styles seems limited. I need styles that are "based on" (inherit from) other styles and it's not clear how this works using HTML classes and CSS.</p></li>
  <li><p>I've looked at OpenXML with Office. The <code>&lt;w:blah&gt;</code> tags are pretty easy to use, but I don't like the whole ZIP archive solution. This means styles go in one XML file, content in another, etc. I'm guessing I'll need another step beyond XSLT (some kind of script to do multiple transforms). I'm trying to keep it simple:</p></li>
  </ul>
  
  <p><img src="https://www.plantuml.com/plantuml/img/LOr12y8m38Nl_HLXdaV-WKTFssc2mlGGvfp5hYrDnlJVcvR1y93mtYDv7x-jZvHe1fQl6tKdEyWoEqD9x9C6WMlR035y_hAkEPUGdPXUtNrp-qc5UBBQk5fv8Tuyuh2mX1aoRaeKjxHm6R7A3P7X41BvQJHzsy4bf4TfNetYeQwFXP6fiEiizT7eg5hD3m00" alt="Component diagram of problem"></p>
  
  <p>Is there a way to make a single XML-like (not RTF) file that imports styled paragraphs into Word?</p>