帮助改变由word 2007生成的XML [英] Help with altering XML generated by word 2007

查看:79
本文介绍了帮助改变由word 2007生成的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Heya

我有一项任务。

这是一个单词docx模板。改变其中的"变量"并根据需要剪切和粘贴页面。

That is to take a word docx template. Alter 'variables' within it and cut and paste pages as needed.

现在使用的是PHP,但xml dom和xpath是使用的语言。

Now the tect im using is PHP however xml dom and xpath are the languages used.

无论如何,我已经到了获取某些文本节点(唯一名称,例如我将在docx中搜索user_name文本节点,然后用$ user_name替换nodeValue)并用php变量替换它们。到目前为止,生成的docx
非常好用。

Anyway i got to the point of taking certain text nodes (unique names, eg i would search for user_name text node then replace nodeValue with $user_name) within the docx and replacing them with php variables. So far so good as the resulting docx works a treat.

但真正困难的部分是能够根据用户的需要删除不必要的页面。

But the real hard part was the ability to remove unneccesary pages as needed by the user.

我试过的一首曲目是拿原始文件并单独保存每一页。然后,我将获取完整的文档(所有页面)擦除body元素中的所有数据,然后添加来自任何或所有其他单个页面的内容。

One track i tried was taking the original document and saving each page individually. I would then take the complete document (all the pages) wipe all data within the body element then add content from any or all the other individual pages.

这是一种享受......除了图片停止工作。为什么?

That worked a treat... except pictures stopped working. Why?

因为rel id已经在各个页面中重置,因此与完整文档相比,嵌入式pics将使用错误的ID。

because the rel id's got reset within the individual pages so embedded pics would be using the wrong id as compared to the complete document.

 

有没有人有任何建议/提示/解决方案允许我使用docx作为模板,可以交换'变量'和还删除了不必要的页面?

推荐答案

Hello Belrick,

Hello Belrick,

下面的文本基于与Open Office XML SDK相关联的MSDN内容。

The text below is based on the MSDN content associated with the Open Office XML SDK.

以下URL将带您到MSDN的内容索引。 在"搜索"框中输入一个参数,例如"open office xml sdk"和"replace pages""特别是,请查看Office开发人员提供的部分内容。他们在使用SDK时发布了大量博客
内容。
  http://social.msdn.microsoft.com/Search/en-US?query=open%20office%20xml %20sdk%20和%20'replace%20pages'& beta = 0& ac = 8

The following URL will take you to the MSDN index of content.  In the Search box enter an argument such as "open office xml sdk and 'replace pages' " Especially, look for some of the content by Office Developers. They have a posted a lot of blog content on using the SDK
 http://social.msdn.microsoft.com/Search/en-US?query=open%20office%20xml%20sdk%20and%20'replace%20pages'&beta=0&ac=8

部分相关内容包括

" ;如何将图片插入Word处理文档"

http:// msdn.microsoft.com/en-us/library/bb497430.aspx

如何更换包中的文档部分

http://msdn.microsoft.com/en-us/library/bb508298.aspx

How to Replace a Document Part in a Package
http://msdn.microsoft.com/en-us/library/bb508298.aspx

您可以在搜索框中将搜索细化为不同的参数集,以查看指向"open office xml sdk"主题的数千次点击的链接。谨慎或者你会整天待在那里。

You can refine your search to a different set of arguments in the Search box to see links to thousands of hits for the subject of "open office xml sdk" Be discreet or you'll be there all day.

关于图像和_rels值之间的refid关系的扰乱,.NET已经与处理关系的方法有关。



OpenXmlPartContainer.AddExternalRelationship()创建指向外部部件的关系;

Concerning the scrambling of the refid relationships between the images and the _rels values .NET has clases with methods to work with relationships.

OpenXmlPartContainer.AddExternalRelationship() creates a relationship pointing to an external part;

对于内部部件,方法OpenXmlPartContainer.AddPart< T>旨在创建指向"T"类型的现有部分的关系;和OpenXmlPartContainer.AddNewPart< T>设计用于创建"T"类型的新部分和新创建部分的新关系

For an internal part, method OpenXmlPartContainer.AddPart<T> is designed to create a relationship pointing to an existing part of type 'T'; and OpenXmlPartContainer.AddNewPart<T> is designed to create a new part of type 'T' and a new relationship to the newly create part.

单个强类型零件类的AddxxxPart()类似到AddNewPart< T> ;;只有方法被限制为要添加的部分的类型。

The AddxxxPart() on the individual strong typed part class is similiar to AddNewPart<T>; only the method is restricted to the type of the part to be added.

如果你没有找到帮助,那么也许b 由于其复杂性,您的问题属于付费支持类别,需要更深入的$ b $级别b支持。  请访问以下链接,查看可以更好地满足您需求的各种付费支持选项。
http://support.microsoft.com/default.aspx ?id = fh; zh-CN; offerprophone

If you don't find help then perhaps because of its complexity your question falls into the paid support category which requires a more in-depth level of support.  Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

 


这篇关于帮助改变由word 2007生成的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆