XPS markup is a subset of the XAML used by Windows Presentation Foundation, in the
namespace http://schemas.microsoft.com/xps/2005/06. Lengths are in
device-independent units of 1/96 inch, with the origin at the top left of the page and
y increasing downwards. Element and attribute names are case-sensitive.
FixedDocumentSequence and FixedDocument
| Element | Attributes | Content |
|---|---|---|
FixedDocumentSequence | One or more DocumentReference. | |
DocumentReference | Source (required): the fixed document part | Empty. |
FixedDocument | One or more PageContent, in page order. | |
PageContent | Source (required): the page part; Width, Height: hints of the page size | Optional PageContent.LinkTargets. |
PageContent.LinkTargets | LinkTarget elements. | |
LinkTarget | Name: a Name on the page that hyperlinks can point to | Empty. Lets a reader find a link’s page without opening every page. |
FixedPage
| Attribute | Meaning |
|---|---|
Width, Height | Required: the page size, such as 816 × 1056 for US Letter and 793.7 × 1122.5 for A4. |
ContentBox | x,y,width,height: the area with content, inside margins. |
BleedBox | The area including bleed, which may extend beyond the page. |
xml:lang | Required: the language of the page’s text, or und. |
Name | A name for the page as a link target. |
Children: an optional FixedPage.Resources holding one
ResourceDictionary, then any number of Path,
Glyphs and Canvas elements, drawn in order.
Attributes shared by Canvas, Path and Glyphs
| Attribute | Meaning |
|---|---|
RenderTransform | A matrix m11,m12,m21,m22,dx,dy applied to the element (or a .RenderTransform child with a MatrixTransform). |
Clip | A geometry clipping the element: abbreviated syntax or a resource reference. |
Opacity | 0.0 to 1.0, default 1. |
OpacityMask | A brush whose alpha masks the element. |
Name | An identifier, a link target. |
FixedPage.NavigateUri | Makes the element a hyperlink: an absolute URI, or a relative one to a part with #name. |
xml:lang | Language of contained text. |
x:Key | Only inside resource dictionaries: the resource’s key. |
Each attribute that takes a complex value can instead be written as a child
property element, such as <Path.Fill> or
<Canvas.Clip>.
Canvas
Groups elements so that a transform, clip, opacity or link applies to all of them.
Extra attributes: RenderOptions.EdgeMode (Aliased turns off
anti-aliasing), AutomationProperties.Name and
AutomationProperties.HelpText (accessibility text). Children:
Canvas.Resources, then Path, Glyphs and
Canvas.
Path
| Attribute | Meaning |
|---|---|
Data | The geometry: abbreviated syntax or a PathGeometry resource. |
Fill | A brush or colour to fill the interior. |
Stroke | A brush or colour for the outline. |
StrokeThickness | Line width, default 1. |
StrokeDashArray | Dash and gap lengths, as multiples of the thickness. |
StrokeDashOffset | Where the dash pattern starts. |
StrokeDashCap | Flat (default), Round, Square, Triangle. |
StrokeStartLineCap, StrokeEndLineCap | Same values: the caps at the ends of open figures. |
StrokeLineJoin | Miter (default), Bevel, Round. |
StrokeMiterLimit | Default 10, at least 1. |
SnapsToDevicePixels | true or false: a rendering hint. |
AutomationProperties.Name, .HelpText | Accessibility text, for images especially. |
Glyphs
A run of text in one font and size. See text,
fonts and images for Indices and the other text attributes:
FontUri, FontRenderingEmSize, OriginX,
OriginY, UnicodeString, Indices,
BidiLevel, IsSideways, CaretStops,
DeviceFontName, StyleSimulations, Fill.
Resource dictionaries
A ResourceDictionary holds brushes, geometries, transforms and
Canvas elements, each with an x:Key. Its Source
attribute may instead point to a remote dictionary part. Elements refer to a
resource by {StaticResource key} in an attribute, looked up in the
enclosing elements’ dictionaries and then the page’s. Resources must be defined
before use and cannot refer forward.
Document structure
Optional parts describe the reading structure (namespace
http://schemas.microsoft.com/xps/2005/06/documentstructure):
| Element | Meaning |
|---|---|
DocumentStructure | Root of the document structure part; holds DocumentStructure.Outline and Story elements. |
DocumentOutline, OutlineEntry | The outline (bookmarks): each entry has OutlineLevel, OutlineTarget (a URI with #name), Description and xml:lang. |
Story, StoryFragmentReference | A story (an article flowing across pages) and the fragments on each page (Page attribute). |
StoryFragments, StoryFragment | Root of a page’s story fragments part; each fragment has StoryName, FragmentName, FragmentType (Content, Header, Footer). |
SectionStructure, ParagraphStructure, TableStructure, TableRowGroupStructure, TableRowStructure, TableCellStructure, ListStructure, ListItemStructure, FigureStructure | The logical structure, with NamedElement children pointing (NameReference) at named page elements. |
Example
<FixedPage xmlns="http://schemas.microsoft.com/xps/2005/06"
Width="816" Height="1056" xml:lang="en-GB">
<Path Data="M 96,96 L 720,96 L 720,200 L 96,200 Z" Fill="#FFEEEEEE"
Stroke="#FF000000" StrokeThickness="2"/>
<Glyphs FontUri="/Resources/Fonts/arial.ttf" FontRenderingEmSize="24"
OriginX="120" OriginY="160" UnicodeString="Hello, page one"
Fill="#FF000000"/>
</FixedPage>
Sources
- ECMA-388 – Open XML Paper Specification, first edition (2009): §9.3 markup model and
xml:lang, §10 documents and fixed pages, §11 thePathelement and stroke attributes, §14 opacity, resources and their scoping, clipping, §16 document structure and hyperlinks, §19 element reference - Library of Congress: XPS – the Microsoft namespace
http://schemas.microsoft.com/xps/2005/06used by XPS 1.0 files