简体   繁体   English

使用xml数据的Word Docx mailmerge和使用xslt OPENXML合并

[英]Word Docx mailmerge using xml data and merging using xslt OPENXML

I have been searching the net all day to find an answer with no luck; 我整天都在网上搜索,找不到运气的答案。 maybe someone has a simple answer for me? 也许有人对我有一个简单的答案?

I have created a Word Docx from which I have extracted the word/document.xml to create an xslt file. 我创建了一个Word Docx,从中提取了word / document.xml来创建xslt文件。

I have literally no experience so this is a very steep learning curve so I have been following various examples which I have found and have produced a working 'mailmerge' or transformation using data which is generated from SQLServer as XML. 我实际上没有经验,因此这是一个非常陡峭的学习曲线,因此我一直在跟踪各种示例,这些示例已经发现并使用从SQLServer作为XML生成的数据进行了有效的“邮件合并”或转换。

I now need to do the usual 'mailmerge' stuff like ignoring any blank lines in the address which is printed at the top of the page but I have no idea how I can do this using my xslt file, or any other method for that matter. 现在,我需要执行通常的“邮件合并”操作,例如忽略页面顶部打印的地址中的任何空白行,但是我不知道如何使用xslt文件或任何其他方法来执行此操作。

Looking at the xslt file, one example of a 'paragraph' which should be ignored is: 查看xslt文件,应忽略“段落”的一个示例:

          <w:p w:rsidR="0067165E" w:rsidRPr="00F841C2" w:rsidRDefault="0067165E">
        <w:pPr>
          <w:rPr>
            <w:sz w:val="20"/>
            <w:lang w:val="en-GB"/>
          </w:rPr>
        </w:pPr>
        <w:r w:rsidRPr="00F841C2">
          <w:rPr>
            <w:sz w:val="20"/>
            <w:lang w:val="en-GB"/>
          </w:rPr>
          <w:t>
            <xsl:value-of select="Address2"/>
          </w:t>
        </w:r>
      </w:p>

as I don't want to print a blank line if Address2 is not populated. 因为如果Address2未填充,我不想打印空白行。

From what I have read and the little that I understand (and probably misunderstood), I need to set up functionality to ignore nodes which contain no data (Have I got that much right?) 从我已读过的内容和所了解的一点点(可能是被误解)中,我需要设置功能以忽略不包含数据的节点(我说得对吗?)

Can I use this? 我可以用这个吗?

<xsl:template match="*[not(child::node())]"/>

and how does that interact with the 以及如何与

  <xsl:template match="/">

which I have already put at the top of my xslt file? 我已经放在xslt文件顶部的文件了吗?

If anyone can help me out on this, it would really help to move me along. 如果有人可以在这方面帮助我,那将真的有助于我前进。 Sorry if it is so simple that I should be able to do it with my eyes closed but I've got to start somewhere! 很抱歉,如果它是如此简单,我应该可以闭上眼睛去做,但是我必须从某个地方开始!

Thanks 谢谢

Well, it seems that I was probably trying to see the most difficult way to do something really simple. 好吧,看来我可能正在尝试寻找最简单的方法来完成最简单的事情。 I have had another look at this and answered my own question by simply using on the element and enclosing the whole section. 我对此有另一种看法,并通过简单地在元素上使用并封闭整个部分来回答了自己的问题。

Thanks to anyone who might have taken the time to look at this, sorry to have asked such a dumb question! 感谢任何可能花时间去看这个的人,很抱歉提出这样一个愚蠢的问题!

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

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