Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Today I have accidentally found out that the .docx is the same .zip (or there is no big difference between them). When you change the .docx to the .zip and open with WinRAR you see a bunch of XML files in the folders. In that XML file it is stored the text, fonts, owner, last modified and so on. In a word all the information is being stored as an XML data.

But the same is not right for .doc extension files. It is impossible to open them as .zip op as .rar.

So question: What is the advantage of storing .docx’s data in XML that Microsoft has changed the way of storing data? Indeed I want to know not the advantage of XML format but why Microsoft is using multiple XML files to store the .docx data. It turnes that .docx is not new format in the root.

share|improve this question

migrated from stackoverflow.com Oct 9 '09 at 10:08

This question came from our site for professional and enthusiast programmers.

    
Within 1 Minute.. 5 almost same answers. The Power of SO. –  Mahin Oct 9 '09 at 10:02
1  
Having data in XML format doesn't mean that it is not new format. You can't feed that XML into OpenOffice and make it render correctly. You must clearly define what will be XML structure, what attributes, what elements etc. –  Janis Veinbergs Oct 9 '09 at 10:03
1  
Consider changing the title to something more informative. –  Carl Bergquist Oct 9 '09 at 10:06
2  
Of course it's a new format. Come on now. –  Kyle Rozendo Oct 9 '09 at 10:07
    
Dear Janis Veinbergs and Kyle Rozendo I have worked with XML and XSD a lot of times and I know how it works!!! Be attentive I said "in the root". You can't agree that it is the XML format just used, not a new format!!!! –  Narek Oct 9 '09 at 10:25

5 Answers 5

up vote 10 down vote accepted

A .docx file can store embedded resources, like image files, not just XML files. Instead of encoding stuff in base64 or something and storing it within an XML file or inventing yet another binary serialization format, they decided to go with the standard ZIP format.

Beside that, XML is a very verbose file format containing lots of redundant patterns. You can get a high compression ratio for XML files.

By the way, I don't really get the "tricking us" part. Is it better to invent a new cryptic file format from scratch or use a standard, known format?

share|improve this answer
    
The main benefit I see is that there are Open APIs for actually creating these files, so creating .docx files from scratch is possible without spending lots on proprietary SDKs. The Microsoft SDK even supplies a document reflector that will generate C# code to generate a pre-made document from scratch. –  Will Eddins Oct 9 '09 at 18:45
    
@Guard: Yeah. My answer addresses the original version of the question. The question has changed significantly since then ;) The original title was "Microsoft is tricking?" –  LeakyCode Oct 10 '09 at 8:52
    
xml in itself does not make a format "known", .docx being one of the best examples. –  artistoex Jan 16 '12 at 8:06

The Wikipedia article sums it up pretty nicely:

"Microsoft came under increasing pressure to adopt an open file format, in particular several nations adopted rules that official documents should be in an open format."

Edit: And zipping it up makes a lot of sense, as the XML is very verbose, and naturally compresses really well.

share|improve this answer
3  
"Open" does not mean "can be unzipped". –  Greg Hewgill Oct 9 '09 at 10:01
3  
Zipping has other advantages besides compression. It acts also as a container for multiple files. –  Joey Oct 9 '09 at 10:08

Using a renamed .zip file is a pretty common practice - for example Quake III .pak files are really .zip files. There's no point inventing your own compressed file format when perfectly good ones exist already.

share|improve this answer
1  
More examples of using ZIP archives: Java .jar, Winamp .wsz/.wal (skins), Firefox .xpi (XPInstaller - themes, addons). (tar archives are also popular.) –  grawity Oct 9 '09 at 13:02

It's not only Office Open XML which uses zipped XML. Open Office's OpenDocument does the same behind the scenes.

There are a few advantages listed on the Wikipedia page on the Open Packaging Conventions:

Indirection

Take the example of a catalog where a logo is repeated 1,000 times. Using an indirection mechanism, if we want to change the logo we only need to change one entry in one file, with no searching involved because we know where to look. This increases maintainability substantially. If you want to change the layout of, say, the ZIP directories where your files are stored, it becomes a trivial matter, because you don't need to know every element that can point to file, they are all in one spot.

Chunking

It encourages documents to be split into small chunks. This is better for reducing the effect of file corruption. And better for data access: for example, all the style information in one XML part, each separate worksheet or table in their own different parts. This allows faster access and less object creation for clients, and makes it easier for multiple processes to be working on the same document.

Chunking also benefits programmers. Replacing one stylesheet with another becomes a ZIP file operation, not an XML operation. And it reduces the amount of things that a programmer needs to understand, because they can approach the chunks assuming that all the information on a topic is in that chunk: they are spared the mental toil of having to search through a big file with lots of extraneous elements.

Relative indirection

In the Open Packaging Conventions each file that has reference has its own _rels file with the indirection lists. This makes it easier to cut and paste some information with all its associated resources in some cases, provides name scoping to remove the chance of name clashing between files, and so on.

share|improve this answer

The biggest benefit is that you can get to your data by unzipping the file and copying the text from the xml files. This can be done with a zip utility & a text editor, even if you don't have a copy of Word 2007.

This is what makes the format more open that the older binary formats.

share|improve this answer

protected by Diago Nov 24 '10 at 12:22

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.