Extract complete WordprocessingML document from package instance.

Hi,

If I have an instance of a package, is there a way to extract the complete WordprocessingML xml document fromm it in the form of:

- <pkg: package xmlns: pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
+ <pkg: part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg: padding="512">
+ <pkg: part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg: padding="256">
+ <pkg: part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
+ <pkg: part pkg:name="/word/media/image1.jpeg" pkg:contentType="image/jpeg" pkg:compression="store">
+ <pkg: part pkg:name="/word/theme/theme1.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.theme+xml">
+ <pkg: part pkg:name="/word/glossary/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml">
+ <pkg: part pkg:name="/word/glossary/settings.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml">
+ <pkg: part pkg:name="/word/fontTable.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml">
+ <pkg: part pkg:name="/docProps/core.xml" pkg:contentType="application/vnd.openxmlformats-package.core-properties+xml" pkg: padding="256">
</pkg: package>

Thanks,

Rocco M.

[2161 byte] By [RoccoMastrangelo] at [2008-2-28]
# 1

Sorry Rocco, but there isn't except for doing it yourself manually. This would not be to difficult I guess, you can access all the parts using the Package class and with knowledge of the packaging schema create it manually.

Wouter

WoutervanVugt at 2007-10-2 > top of Msdn Tech,Office Live Development,Microsoft SDK for Open XML Formats...
# 2

Really? That would have been great to with Range.InsertXML() from the Word Interop assembly.

Any plans to add this feature on Package class, ToWordOpenXML()?

Scott

scottieGGGG at 2007-10-2 > top of Msdn Tech,Office Live Development,Microsoft SDK for Open XML Formats...
# 3

Yes, that is exactly one of the ways I would have used it, and why I asked the question. I was quite surprized and disappointed to learn the capability doesn't exist. It seems so basic. So, are there plans to add this capability?

-Rocco

RoccoMastrangelo at 2007-10-2 > top of Msdn Tech,Office Live Development,Microsoft SDK for Open XML Formats...
# 4
I don't know Rocco if I really understand you but: are you trying to build a file like a Word 2003 XML file (Only 1 xml file, not a package)?
This implies to codify binbase64 the binaries (like images and so on) and...which is the purpose?
I don't know.
It seems to me like a contradiction with the sense of the package.
Are you trying to build a resume?
MauricioG at 2007-10-2 > top of Msdn Tech,Office Live Development,Microsoft SDK for Open XML Formats...
# 5

I'm not sure about Rocco, but the way I would use this feature would be the InsertXML() method on Range.

When you want to insert formatted text into an active document via the Word Interop, you would use the InsertXML method. However, the "fun-fact" about this method is you must always pass it a "complete document". The Range object would determine where the body text is inserted.

With Word 2003... it wasn't a big issue since the WordML 2003 format was used, the design probably would have templates / Word fragments/ etc in this format. You'd pretty much take your formated texted, but a document and body tag around it and you'd be good to insert. With 2007... there's the Package class. It's great because now all your pieces and parts to construct Word documents are PackageParts and Relationships...etc..etc. Not as messing and a great .Net 3.0 object.

But.. it all comes to a halt when you get to the InsertXML() method. Once again.. it must be a complete document. Since docx files and package classes spread detail information across multiple files, it gets a bit complex. There is the package namespace (as described at top of this thread. known as the "flat" format), and this solves the problem of merging all of the separate xml files into a single document, single XML string value to give to InsertXML.

But it would be great to generate this flat format single XML string for the entire package on the package object.

scottieGGGG at 2007-10-2 > top of Msdn Tech,Office Live Development,Microsoft SDK for Open XML Formats...
# 6
I see the point Scottie and I think that this is the place and the person to talk with: http://blogs.msdn.com/brian_jones/archive/2005/08/19/453716.aspx
MauricioG at 2007-10-2 > top of Msdn Tech,Office Live Development,Microsoft SDK for Open XML Formats...