This is the fith part of the Dissecting XPS series and will focus on the Xml Paper Specification, XPS, document properties.
Core Properties
The properties used in an XPS document are stored in the Core Properties Part, specified in the Open Packaging Conventions, OPC [1]. The Part is located by reading the [Content_Types].xml file and finding the content type application/vnd.openxmlformats-package.core-properties+xml. A document should have one Core Properties part, so there is no requirement to have one but having serveral indicates an invalid package. But there should be no reason to leave out the part. There are also no requirements on which elements that should be present in the part.
The Core Properties Part contains information about the title, author, creation time etc which are properties that I think are necessary today, it allows you to locate and find documents faster.
1: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2: <cp:coreProperties
3: xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
4: xmlns:dc="http://purl.org/dc/elements/1.1/"
5: xmlns:dcterms="http://purl.org/dc/terms/"
6: xmlns:dcmitype="http://purl.org/dc/dcmitype/"
7: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
8: <dc:title>Wictor test 1</dc:title>
9: <dc:subject>XPS test 1</dc:subject>
10: <dc:creator>Wictor Wilen</dc:creator>
11: <dcterms:created xsi:type="dcterms:W3CDTF">2007-04-01T00:00:00Z</dcterms:created>
12: <dcterms:modified xsi:type="dcterms:W3CDTF">2007-04-02T00:00:00Z</dcterms:modified>
13: <cp:contentStatus>Reviewed</cp:contentStatus>
14: <cp:category>Test</cp:category>
15: </cp:coreProperties>
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; overflow-x:visible;border:0px} .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
The sample above is an example of a Core Properties Path, all available elements and the subset of Dublin Core [2] elmennts can be found in the OPC specification[1].
Thumbnails
Thumbnails are great for all kind of files and XPS/OPC allows you to provide your own thumbnail instead of relying on the consumer to create one for you. Thumbnails can be used either on the whole XPS Package or on individual fixed pages. If used on one individual page then it should be used on all pages, according to the specification[3]. Thumbnails are images in the format of either JPEG or PNG.
Thumbnails are specified as relationships, in the .rels files, using the type http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail, like below. The Target attribute specifies the actual thumbnail file.
1: <?xml version="1.0" encoding="utf-8"?>
2: <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
3: <Relationship Target="/thumbnail/thumbnail.png" Id="R0"
4: Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"/>
5: </Relationships>
By now we have covered pretty much of the XPS specification and It’s time to look at some code on how to consume and produce XPS files, but that’s for the next post in the series.
Further reading and references
[1] ECMA-376 Part 2, Office Open Xml, Open Packaging Conventions[2] Dublin Core Metadata Initiative - Metadata Terms[3] XPS Specification