示例XML
<xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"> <w:styles> <w:style w:type="paragraph" w:styleId="booktitle1"> <w:name w:val="Book Title1" /> <w:rPr> <w:b/> </w:rPr> </w:style> </w:styles> <w:body> <w:p> <w:pPr><w:pStyle w:val="booktitle1"/></w:pPr> <w:r> <w:rPr> <w:rStyle w:val="booktitle1"/> </w:rPr> <w:t>Book title</w:t> </w:r> <w:r wsp:rsidRPr="00C358DC"> <w:rPr> <w:rStyle w:val="booktitle1"/> <w:b w:val="off"/> </w:rPr> <w:t> Author</w:t> </w:r> </w:p> </w:body> </w:wordDocument>在此示例xml中,para文本格式信息(即粗体)在style属性中定义。 因此,样式将对整个para文本应用粗体格式。 但是,“作者”一词的运行属性会覆盖特定文本的粗体。 因此,这些字符在para文本中没有粗体。 所以,我需要使用xslt的下面提到的输出xml。
输出xml:
<p class=”Book Title1”><b val=”on”>Book title</b><b val=”off”> Author</b></p> or <p class=”Book Title1”><b>Book title</b> Author</p>有谁知道如何做到这一点? 任何想法或意见都非常感谢。
Sample XML
<xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"> <w:styles> <w:style w:type="paragraph" w:styleId="booktitle1"> <w:name w:val="Book Title1" /> <w:rPr> <w:b/> </w:rPr> </w:style> </w:styles> <w:body> <w:p> <w:pPr><w:pStyle w:val="booktitle1"/></w:pPr> <w:r> <w:rPr> <w:rStyle w:val="booktitle1"/> </w:rPr> <w:t>Book title</w:t> </w:r> <w:r wsp:rsidRPr="00C358DC"> <w:rPr> <w:rStyle w:val="booktitle1"/> <w:b w:val="off"/> </w:rPr> <w:t> Author</w:t> </w:r> </w:p> </w:body> </w:wordDocument>In this sample xml, the para text formatting information (i.e. bold) defines within the style property. So, the style will apply the bold formatting for whole para text. But, the word “ Author” run-on property override the bold for the particular text. So, those characters are present without bold with in the para text. So, I need the below mentioned output xml using xslt.
Output xml:
<p class=”Book Title1”><b val=”on”>Book title</b><b val=”off”> Author</b></p> or <p class=”Book Title1”><b>Book title</b> Author</p>Does anyone have any idea how to do this? Any ideas or comments are greatly appreciated.
最满意答案
RenderX有一组处理WordML的样式表,当然包括在WordML中通过存储在文件中备用位置的等效样式来导航。 我建议作为一个答案,你要检查他们是如何做到这些并适应你的命名空间/等。 如果他们不匹配。
它们位于http://www.renderx.com/tools/word2fo.html
而且我也会告诉你,它并不像你想象的那么简单。 WordML中的样式可以有链接样式(反过来可以有其他链接样式......等等),你也必须知道何时将默认样式应用于某些元素(w:p)而不是(当aw:p时)在aw:tc或aw:r里面是一个列表)。 并且您必须通过整个链接样式链编程,以正确的顺序应用它们以实现与Word中的样式匹配。
虽然您可能认为这不是您问题的“答案”,但事实确实如此。
您提出了一个您认为很容易回答的问题,但我可以从经验中告诉您,RenderX花了很多人时间从WordML开发这些转换来解释样式。
RenderX has a set of stylesheets that process WordML which of course include navigating named styles in WordML through their equivalents stored in alternate places in the file. I would suggest as an answer that you examine how they did them and adapt to your namespaces/etc. if they do not match.
They are at http://www.renderx.com/tools/word2fo.html
And I will also tell you that it is not as simple as you think. Styles in WordML can have linked styles (which in turn can have other linked styles ... and so on) and also you have to know when to apply the default style to some elements (w:p) and not (when a w:p is inside a w:tc or a w:r that is a list). And you must program through the whole chain of linked styles applying them in the right order to achieve matching the style in Word.
While you may think this is not an "answer" to your question, it is.
You asked a question that you think is easy to answer, but I can tell you from experience that RenderX spent many man-years developing those conversions from WordML to interpret the styles.
更多推荐
<w,para,p>,电脑培训,计算机培训,IT培训"/> <meta name="description&
发布评论