简体   繁体   中英

XML to Word using custom paragraph styles and XSLT

I've got an XML file that contains mostly textual information (list of questions in Moodle XML format ). 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:

  • I was excited to find several tutorials (eg, a ) about how to use XML in Word, but many of them are moot given the result of the i4i patent dispute .

  • I made a prototype with RTF with XSLT, but the RTF styling and Unicode support is complex.

  • I've seen a way to use <p class="myCustomStyle"> 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.

  • I've looked at OpenXML with Office. The <w:blah> 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:

问题组成图

Is there a way to make a single XML-like (not RTF) file that imports styled paragraphs into Word?

I've looked at OpenXML with Office. The 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.

Then you'll want to check out The Flat OPC Format , where the OPC parts are represented in a single XML file rather than multiple files zipped together.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM