简体   繁体   English

使用自定义段落样式和 XSLT 从 XML 到 Word

[英]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 ).我有一个 XML 文件,其中主要包含文本信息( Moodle XML 格式的问题列表)。 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.我想将其转换为可以由 MS Word 打开的文档,但我想维护上下文(使用段落样式),以便我可以将其转换回 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 .我很高兴找到几个关于如何在 Word 中使用 XML 的教程(例如, a ),但鉴于i4i 专利纠纷结果,其中许多教程都没有实际意义。

  • I made a prototype with RTF with XSLT, but the RTF styling and Unicode support is complex.我用 XSLT 用 RTF 制作了一个原型,但 RTF 样式和 Unicode 支持很复杂。

  • I've seen a way to use <p class="myCustomStyle"> with HTML documents which can be opened in Word.我已经看到了一种将<p class="myCustomStyle">用于 HTML 文档的方法,这些文档可以在 Word 中打开。 But HTML style sheets and mapping them to Word styles seems limited.但是 HTML 样式表并将它们映射到 Word 样式似乎是有限的。 I need styles that are "based on" (inherit from) other styles and it's not clear how this works using HTML classes and CSS.我需要“基于”(继承自)其他样式的样式,目前尚不清楚使用 HTML 类和 CSS 是如何工作的。

  • I've looked at OpenXML with Office.我看过带有 Office 的 OpenXML。 The <w:blah> tags are pretty easy to use, but I don't like the whole ZIP archive solution. <w:blah>标签非常易于使用,但我不喜欢整个 ZIP 存档解决方案。 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).这意味着样式在一个 XML 文件中,内容在另一个文件中,等等。我猜我需要 XSLT 之外的另一个步骤(某种脚本来执行多个转换)。 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?有没有办法制作一个类似 XML(不是 RTF)的文件,将带样式的段落导入到 Word 中?

I've looked at OpenXML with Office.我看过带有 Office 的 OpenXML。 The tags are pretty easy to use, but I don't like the whole ZIP archive solution.标签非常易于使用,但我不喜欢整个 ZIP 存档解决方案。 This means styles go in one XML file, content in another, etc.这意味着样式在一个 XML 文件中,内容在另一个文件中,等等。

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 Flat OPC Format ,其中OPC部件以单个 XML 文件而不是多个压缩在一起的文件表示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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