This is the second part of the Dissecting XPS series, last post generally described the XML Paper Specification. This post in the series will describe the XPS file format internals. This will give you an overview of how the XPS files are built from ground and up, instead of reading the XPS Specification which covers 453 pages.
The XPS file
The XPS file, with the .xps extension, is a ZIP file - called the physical Package, and consists of a number of XML and binary files - called Parts. There are also files describing how the files are organized and connected together - called Relationships.
The parts and relationships is grouped into a Payload, according to the Open Packaging Convention, and an XPS document must contain at least one fixed payload, which represents a "static or fixed-layout representation of a paginated content" . Each fixed payload starts with a FixedDocumentSequence, which describes the sequence of fixed documents.
The FixedDocumentSequence contains references to to the fixed documents in the XPS document. Each XPS Document must contains a specific relationship which identifies the FixedDocumentSequence that is the root of the document, called the XPS Document StartPart, so consumers of the document can find the first document sequence.
The start part relationships is stored in a .rels file in the /_rels folder and contains a reference to the the part containing the FixedDocumentSequence.
The code below shows the start part relationship file, and line 5 shows the relationship to the fixed document sequence.
1: <>xml version="1.0" encoding="UTF-8" standalone="yes"?>
2: Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
3: Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
4: Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" Target="docProps/thumbnail.jpeg"/>
5: Relationship Id="rId1" Type="http://schemas.microsoft.com/xps/2005/06/fixedrepresentation" Target="FixedDocSeq.fdseq"/>
The Type attribute on line 5 has the value of http://schemas.microsoft.com/xps/2005/06/fixedrepresentation, which indicates that this is the StartPart [2: Table I-6]. Note that all targets have a paths that are relative to the parent of the _rels folder.
In the example above (taken from the XPS Specification) there are also two other relationships; line 3 tells us where to find the properties for the XPS document and line 4 shows the reference to the thumbnail image of the document, in this case a JPEG file. I will get back to these Parts later in the series.
This is the content of the FixedDocSeq.fdseq file, referenced above on line 5, in this case the XPS document has two fixed documents.
1: FixedDocumentSequence xmlns="http://schemas.microsoft.com/xps/2005/06">
2: DocumentReference Source="Documents/1/FixedDocument.fdoc" />
3: DocumentReference Source="Documents/2/FixedDocument.fdoc" />
Line 2 and 3 contains document references to the fixed documents, their location is specified using the Source attribute and is relative to the file.
This image shows how the different parts and relationships are located in the ZIP compressed XPS document.
The start part is found in the /_rels/.rels file, and then the document sequence can be found and then the fixed documents which contains the contents. The relationships file also points out where the thumbnail and document properties are stored.
There are also an important file called [Content_Types].xml containing the content types for the different files, located in the root. This file is specified in the Open Packaging Convention standard.
1: <>xml version="1.0" encoding="UTF-8" standalone="yes"?>
2: Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
3: Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
4: Default Extension="fdseq" ContentType="application/vnd.ms-package.xps-fixeddocumentsequence+xml"/>
5: Default Extension="fpage" ContentType="application/vnd.ms-package.xps-fixedpage+xml"/>
6: Default Extension="jpg" ContentType="image/jpeg"/>
7: Default Extension="fdoc" ContentType="application/vnd.ms-package.xps-fixeddocument+xml"/>
If you rename the XPS document to .ZIP you can easily look into the structure of the XPS file and find the parts and relationships.
The FixedDocument Part
The FixedDocument Part is the root for all pages in the document (a set of fixed pages) and we will look into this Part and others in the next part of this Dissecting XPS series.
Further reading and references
I think the XPS initiative is nice from a developer and ISV perspective, since creating and reading XPS documents is easy and supported from various environments. This series of XPS articles will start off with an introduction to the XML Paper Specification and then continue with general support and competitors and then of course some nice introduction on how to use XPS in applications.
As of today the XPS format is not even near the Adobe PDF format in usage, but the recent introduction of Windows Vista, which contains a built-in reader, and Microsoft Office 2007, which can generate XPS documents, will at least close the gap.
What is the XML Paper Specification?
The XML Paper specification is an effort from the software giant Microsoft to make an open, royalty free, cross-platform document format. An XPS document is a "paginated representation of an electronic document". With the XPS format everyone can create XPS document which can be read and printed by anyone who or anything whic has an XPS reader and/or XPS capable printer. XPS documents can also be digitally signed and contain advanced coloring for printing and much more.
Creating XPS documents is easy and royalty-free which means that ISV's and application developers easy can integrate XPS import and/or export into their applications.
Now over to the interesting stuff...
The XPS Document format
XPS is based on the Open Packaging Conventions which essentially is a ZIP compressed set of XML files. This is the same package format that the new Microsoft Office 2007 document formats use (for example .docx and .xlsx). The specificatíon for this "describes an abstract model and physical format...to organize the content and resources of a document within a package" . The abstract model describes Packages which is a logical entity consisting of Parts and their Relationships and the physical model describes basically how the Package is physically stored.
Every Part has a Content Type, which identifies the type of content that is stored in the Part. For example a part can be the document markup, an image or any other embedded content.
The physical file is a standard ZIP file (just rename any .xps or .dotx file to .zip and open it) with the parts and relationships as files. The different parts will be represented as files. For example; the image in the above example will be an actual image file in the ZIP package and the content will be represented by an XML file.
To the right is a screenshot from the content of the XML Paper Specification 1.0 .XPS document. As you can see there are files and folders which represents the Parts.
How can I start creating XPS documents
If you have Microsoft Office 2007 you can start creating XPS documents after downloading an optional update, which adds the Save As XPS to your Office applications. If you have Windows Vista you can use the XPS print driver to print anything to an XPS document. If you have Windows XP or Windows Server 2003 you can download the XML Paper Specification Essentials Pack which includes the Microsoft XPS Document Writer.
If you would like to convert an RSS feed into a document you can go to RSS2XPS.com which allows you to convert a feed into an XPS document.
Next article in this series, which should appear within a week, will focus more on the XPS Parts and Relationships within a XPS document.
Further reading and References
 XPS Specification and License downloads Ecma Office Open XML File Formats Standard XML Paper Specification XPS Viewer for Windows XP or Windows Server 2003 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS Microsoft XML Paper Specification Essentials Pack Version 1.0
Numerous times my Windows Vista has been missing icons in the Notification Area (when did Microsoft stop calling it System Tray?). The icons that has been missing is normally Network, Volume and Power.
In Windows Vista you can easily enable these three notification icons, as well as the Clock, in the Taskbar and Start Menu Properties dialog, accessible by right-clicking the Start icon and selecting properties. But the problem is that I can't enable these icons when they disappear after starting Vista - they are disabled.
A reboot solves the problem and the icons are back and I can once again enable or disable them.
Have you noticed this and do you have any idea on how to solve it?
The first beta of Design was a real disappointment for me, since all pixel editing and all Live Effects was removed. Beta 2 is still only vector editing but the Live Effects are there. The focus seems to be the Design/Blend/XAML/WPF integration to start with, which is fine but the technical previews of Design (then called Interactive Designer) really had it wen you could combine vector and pixel layers.
The really nice visual web search engine Quintura has been updated with a better and improved interface. Quintura allows you to enter a search word and then using a visual user interface in which you can navigate a cloud of related search terms and the include or exclude them from your search to refine you result.
Quintura allows you to get an overview of which search terms are releated to your search term and it's fun to use and browse into new areas.
Quintura is a good search place for newbies to the Internet to start, and they even have a Kids version and they will release a Quintura for Women. For now it's only available in english and I would like to see some development in the localization area for Quintura so we can use it in other languages, especially the kids version.
Windows DreamScene is still only released as a preview version, but the big interest for the Vista Ultimate extension made the Ultimate Extras Team to release the content pack ahead of schedule.
DELL, one of the largest PC computer-hardware companies , has really understood how important it is to communicate and interact with customers.
First of all I am a very satisfied DELL user, except for some problems with my Inspiron 9100, and I think that the DELL support has been great. But having good stuff to sell an providing satisfactory support is not everything. To be able to stay on top you have to evolve and get with the trends and listen to your customers/community.
DELL has lost marketshare, to HP, and revenues and the management has changed. To get back on track DELL has launched DELL 2.0.
IdeaStorm is a, web 2.0 stylish, community where you can post your ideas on how DELL should evolve and be better, about 3.000 ideas has been posted so far. You can promote and comment on ideas you think are great and hope for DELL to notice them and hopefully implement them. DELL has already taken some ideas into consideration which can be found here - Ideas in Action.
Do you know of any other similar community approaches?
About a week ago the released Windows Vista Ultimate Extras was updated and re-released on Windows Update with no information on the updates.
The reason for the updates of BitLocker tools and Texas Hold'em game was bug fixes, localization issues and parental control issues.
The information is now available in the Microsoft Knowledge Base, in these articles
If you have the beta of the update (KB929470) then uninstall it before installing the final update.
NVIDIA is continuing thier path to a great driver for Windows Vista. A week ago they released ForceWare 100.65 which is a WHQL certified driver, it does not contain anything revolutionary but is stable (that's pretty good enough right now).
Yesterday NVIDIA took another step forward with a beta of ForceWare 101.41 which is the driver we all have been waiting for since the launch of Vista, four months ago! Performance is better, flat panel scaling is fixed, reduced flickering when using Aero and lots of more stuff. In a few weeks we should expect a non-beta.
Unfortunatley the drivers does not support GeForce Go mobile GPU's yet...
The Visual Studio 2005 SDK 4.0 contains a number of new features and fixes, read more about them here.
One of the interesting new features are the Package Load Analyzer which will help you troubleshoot your package load issues. The DSL tools contains a number of minor bugfixes mostly related to the designer.