Java 如何在使用Docx4J将内容控件与XML合并时创建新行?

Java 如何在使用Docx4J将内容控件与XML合并时创建新行?,java,xml,docx4j,Java,Xml,Docx4j,有没有一种方法可以在生成的docx文件中创建一个新行,当我们使用Docx4J将docx模板与xml合并时,会得到该文件,如图所示 考虑到我希望在一个docx文件中有多行,但我通过XML元素将这些行传递给将要与docx文件合并的XML文件,当XML元素与docx模板合并时,如何为XML元素中存在的特定单词集创建新行 供参考-->示例XML数据 <?xml version="1.0" encoding="UtF-8" standalone="yes" ?> <ChargesInv

有没有一种方法可以在生成的docx文件中创建一个新行,当我们使用Docx4J将docx模板与xml合并时,会得到该文件,如图所示

考虑到我希望在一个docx文件中有多行,但我通过XML元素将这些行传递给将要与docx文件合并的XML文件,当XML元素与docx模板合并时,如何为XML元素中存在的特定单词集创建新行

供参考-->示例XML数据

<?xml version="1.0" encoding="UtF-8" standalone="yes"  ?>
<ChargesInvoice>
    <invoicedate>05/01/2016</invoicedate>
    <vatnumber>GB 123456789</vatnumber>
    <dealercode>123456789</dealercode>
    <intenralcontact>956532456987321</intenralcontact>
    <invoicenumber>qwertyuiop</invoicenumber>

    <invoicedetails>
        <invoice>
            <Description>Lorem Ipsum is simply dummy text of the
            Lorem Ipsum is simply dummy text of the Lorem Ipsum is simply dummy text of the
            Lorem Ipsum is simply dummy text of the Ipsum is simply dummy text of the
            Lorem Ipsum is simply dummy text of the Lorem Ipsum is simply dummy text of the
            Lorem Ipsum is simply dummy text of the Lorem Ipsum is simply dummy text of the
            Lorem Ipsum is simply dummy text of the Lorem Ipsum is simply dummy text of the
            Lorem Ipsum is simply dummy text of the Lorem Ipsum is simply dummy text of the
            </Description>
            <NettAmount>300</NettAmount>
            <VATRate>30%</VATRate>
            <VATAmount>30</VATAmount>
            <GrossAmount>310</GrossAmount>
        </invoice>
        <invoice>
            <Description>apak</Description>
            <NettAmount>220</NettAmount>
            <VATRate>12%</VATRate>
            <VATAmount>24.4</VATAmount>
            <GrossAmount>234.4</GrossAmount>
        </invoice>
    </invoicedetails>
</ChargesInvoice>

05/01/2016
GB 123456789
123456789
956532456987321
qwertyuiop
Lorem Ipsum只是
Lorem Ipsum只是Lorem Ipsum的虚拟文本,Lorem Ipsum只是
Lorem Ipsum只是Ipsum的虚拟文本,Ipsum只是
Lorem Ipsum只是Lorem Ipsum的虚拟文本,Lorem Ipsum只是
Lorem Ipsum只是Lorem Ipsum的虚拟文本,Lorem Ipsum只是
Lorem Ipsum只是Lorem Ipsum的虚拟文本,Lorem Ipsum只是
Lorem Ipsum只是Lorem Ipsum的虚拟文本,Lorem Ipsum只是
300
30%
30
310
阿帕克
220
12%
24.4
234.4

正如我们在上面看到的,invoice元素中有更多的数据,我想在新行中显示其中的一部分。如何做到这一点?

BindingTraverserXSLT应该插入br元素来代替以下标记:

    // tokenize on the newline character, the carriage-return character, 
    // and the form-feed character
    StringTokenizer st = new StringTokenizer(r, "\n\r\f"); 
或者,它可以转换转义平面OPC XML或XHTML,尽管需要一些设置