Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 使用XSLT转换在WordProcessingML中保留换行符和空格_Xml_Xslt_Wordprocessingml - Fatal编程技术网

Xml 使用XSLT转换在WordProcessingML中保留换行符和空格

Xml 使用XSLT转换在WordProcessingML中保留换行符和空格,xml,xslt,wordprocessingml,Xml,Xslt,Wordprocessingml,我正在使用WordprocessingML以编程方式创建word文档,无法找到在文本(w:t)块中保留换行符的方法。有一个答案是通过以下方式解决空间问题: t = new Text() { Text = "your text with spaces ", Space = SpaceProcessingModeValues.Preserve }; 但是,我正在使用一个JavaScript文件,该文件创建docx文件的目录结构,并对源xml文件运行xslt转换,以生成word使用的

我正在使用WordprocessingML以编程方式创建word文档,无法找到在文本(w:t)块中保留换行符的方法。有一个答案是通过以下方式解决空间问题:

t = new Text()
{
    Text = "your text with spaces ",
    Space = SpaceProcessingModeValues.Preserve
};
但是,我正在使用一个JavaScript文件,该文件创建docx文件的目录结构,并对源xml文件运行xslt转换,以生成word使用的主document.xml文件。我不确定是否具有与上述代码对应的实际低级WordprocessingML属性。我试过:

<w:t xml:space="preserve">
     Doesn't work.</w:t>

不起作用。


还有,没有快乐。

是否可以这样做,或者是否需要多个段落(w:p)标签?为了便于使用,我希望源xml文件的编辑器只将所需的空白放在单个文本标记中,而不是让他们手动添加额外的xml标记,如tab或段落。

正确的属性是xml:space=“preserve”,这可以通过检查正确构造的测试docx文件找到,但它不允许换行/更改段落(它将这些列为单个空格)。制表符和空格在w:t块中工作,但遗憾的是,我不得不在源xml中使用显式段落标记。答案是,这是不可能做到的(除非在后台进行不值得的字符串处理)。

如果要在段落内添加换行符,则需要使用
w:br
元素,您需要将其插入run(
w:r
)元素。例如,以下标记显示
Foo
Bar
,它们之间有一条空行

<w:r>
  <w:t>Foo</w:t>
  <w:br/>
  <w:br/>
  <w:t>Bar</w:t>
</w:r>

福
酒吧
<w:r>
  <w:t>Foo</w:t>
  <w:br/>
  <w:br/>
  <w:t>Bar</w:t>
</w:r>