1 @node SPSS Viewer File Format
2 @chapter SPSS Viewer File Format
4 SPSS Viewer or @file{.spv} files, here called SPV files, are written
5 by SPSS 16 and later to represent the contents of its output editor.
6 This chapter documents the format, based on examination of a corpus of
7 about 500 files from a variety of sources. This description is
8 detailed enough to read SPV files, but probably not enough to write
11 SPSS 15 and earlier versions use a completely different output format
12 based on the Microsoft Compound Document Format. This format is not
15 An SPV file is a Zip archive that can be read with @command{zipinfo}
16 and @command{unzip} and similar programs. The final member in the Zip
17 archive is a file named @file{META-INF/MANIFEST.MF}. This structure
18 makes SPV files resemble Java ``JAR'' files (and ODF files), but
19 whereas a JAR manifest contains a sequence of colon-delimited
20 key/value pairs, an SPV manifest contains the string
21 @samp{allowPivoting=true}, without a new-line. (This string may be
22 the best way to identify an SPV file; it is invariant across the
25 The rest of the members in an SPV file's Zip archive fall into two
26 categories: @dfn{structure} and @dfn{detail} members. Structure
27 member names begin with @file{outputViewer@var{nnnnnnnnnn}}, where
28 each @var{n} is a decimal digit, and end with @file{.xml}, and often
29 include the string @file{_heading} in between. Each of these members
30 represents some kind of output item (a table, a heading, a block of
31 text, etc.) or a group of them. The member whose output goes at the
32 beginning of the document is numbered 0, the next member in the output
33 is numbered 1, and so on.
35 Structure members contain XML. This XML is sometimes self-contained,
36 but it often references detail members in the Zip archive, which named
40 @item @file{@var{prefix}_table.xml} and @file{@var{prefix}_tableData.bin}
41 @itemx @file{@var{prefix}_lightTableData.bin}
42 The structure of a table plus its data. Older SPV files pair a
43 @file{@var{prefix}_table.xml} file that describes the table's
44 structure with a binary @file{@var{prefix}_tableData.bin} file that
45 gives its data. Newer SPV files (the majority of those in the corpus)
46 instead include a single @file{@var{prefix}_lightTableData.bin} file
47 that incorporates both into a single binary format.
49 @item @file{@var{prefix}_warning.xml} and @file{@var{prefix}_warningData.bin}
50 @itemx @file{@var{prefix}_lightWarningData.bin}
51 Same format used for tables, with a different name.
53 @item @file{@var{prefix}_notes.xml} and @file{@var{prefix}_notesData.bin}
54 @itemx @file{@var{prefix}_lightNotesData.bin}
55 Same format used for tables, with a different name.
57 @item @file{@var{prefix}_chartData.bin} and @file{@var{prefix}_chart.xml}
58 The structure of a chart plus its data. Charts do not have a
61 @item @file{@var{prefix}_model.scf}
62 @itemx @file{@var{prefix}_pmml.scf}
63 Not yet investigated. The corpus contains only one example of each.
65 @item @file{@var{prefix}_stats.xml}
66 Not yet investigated. The corpus contains few examples.
69 The @file{@var{prefix}} in the names of the detail members is
70 typically an 11-digit decimal number that increases for each item,
71 tending to skip values. Older SPV files use different naming
72 conventions. Structure member refer to detail members by name, and so
73 their exact names do not matter to readers as long as they are unique.
76 * SPV Structure Member Format::
77 * SPV Light Detail Member Format::
78 * SPV Legacy Detail Member Binary Format::
79 * SPV Legacy Detail Member XML Format::
82 @node SPV Structure Member Format
83 @section Structure Member Format
85 Structure members' XML files claim conformance with a collection of
86 XML Schemas. These schemas are distributed, under a nonfree license,
87 with SPSS binaries. Fortunately, the schemas are not necessary to
88 understand the structure members. To a degree, the schemas can even
89 be deceptive because they document elements and attributes that are
90 not in the corpus and do not document elements and attributes that are
93 Structure members use a different XML namespace for each schema, but
94 these namespaces are not entirely consistent. In some SPV files, for
95 example, the @code{viewer-tree} schema is associated with namespace
96 @indicateurl{http://xml.spss.com/spss/viewer-tree} and in others with
97 @indicateurl{http://xml.spss.com/spss/viewer/viewer-tree} (note the
98 additional @file{viewer/}). Under either name, the schema URIs are
99 not resolvable to obtain the schemas themselves.
101 One may ignore all of the above in interpreting a structure member.
102 The actual XML has a simple and straightforward form that does not
103 require a reader to take schemas or namespaces into account.
105 The elements found in structure members are documented below. For
106 each element, we note the possible parent elements and the element's
107 contents. The contents are specified as pseudo-regular expressions
108 with the following conventions:
121 Grouping multiple elements.
126 @item @var{a} @math{|} @var{b}
127 A choice between @var{a} and @var{b}.
130 Zero or more @var{x}.
134 For a diagram illustrating the hierarchy of elements within an SPV
135 structure member, please refer to a PDF version of the manual.
139 The following diagram shows the hierarchy of elements within an SPV
140 structure member. Edges point from parent to child elements.
141 Unlabeled edges indicate that the child appears exactly once; edges
142 labeled with *, zero or more times; edges labeled with ?, zero or one
144 @center @image{dev/spv-structure, 5in}
148 * SPV heading Element::
149 * SPV label Element::
150 * SPV container Element::
151 * SPV text Element (Inside @code{container})::
153 * SPV table Element::
154 * SPV tableStructure Element::
155 * SPV dataPath Element::
156 * SPV pageSetup Element::
157 * SPV pageHeader and pageFooter Elements::
158 * SPV pageParagraph Element::
159 * SPV @code{text} Element (Inside @code{pageParagraph})::
162 @node SPV heading Element
163 @subsection The @code{heading} Element
165 Parent: Document root or @code{heading} @*
166 Contents: [@code{pageSetup}] @code{label} (@code{container} @math{|} @code{heading})*
168 The root of a structure member is a @code{heading}, which represents a
169 section of output beginning with a title (the @code{label}) and
170 ordinarily followed by content containers or further nested
171 (sub)-sections of output.
173 The document root heading, only, may also contain a @code{pageSetup}
176 The following attributes have been observed on both document root and
177 nested @code{heading} elements.
179 @defvr {Optional} creator-version
180 The version of the software that created this SPV file. A string of
181 the form @code{xxyyzzww} represents software version xx.yy.zz.ww,
182 e.g.@: @code{21000001} is version 21.0.0.1. Trailing pairs of zeros
183 are sometimes omitted, so that @code{21}, @code{210000}, and
184 @code{21000000} are all version 21.0.0.0 (and the corpus contains all
185 three of those forms).
189 The following attributes have been observed on document root
190 @code{heading} elements only:
192 @defvr {Optional} @code{creator}
193 The directory in the file system of the software that created this SPV
197 @defvr {Optional} @code{creation-date-time}
198 The date and time at which the SPV file was written, in a
199 locale-specific format, e.g. @code{Friday, May 16, 2014 6:47:37 PM
200 PDT} or @code{lunedì 17 marzo 2014 3.15.48 CET} or even @code{Friday,
201 December 5, 2014 5:00:19 o'clock PM EST}.
204 @defvr {Optional} @code{lockReader}
205 Whether a reader should be allowed to edit the output. The possible
206 values are @code{true} and @code{false}, but the corpus only contains
210 @defvr {Optional} @code{schemaLocation}
211 This is actually an XML Namespace attribute. A reader may ignore it.
215 The following attributes have been observed only on nested
216 @code{heading} elements:
218 @defvr {Required} @code{commandName}
219 The locale-invariant name of the command that produced the output,
220 e.g.@: @code{Frequencies}, @code{T-Test}, @code{Non Par Corr}.
223 @defvr {Optional} @code{visibility}
224 To what degree the output represented by the element is visible. The
225 only observed value is @code{collapsed}.
228 @defvr {Optional} @code{locale}
229 The locale used for output, in Windows format, which is similar to the
230 format used in Unix with the underscore replaced by a hyphen, e.g.@:
231 @code{en-US}, @code{en-GB}, @code{el-GR}, @code{sr-Cryl-RS}.
234 @defvr {Optional} @code{olang}
235 The output language, e.g.@: @code{en}, @code{it}, @code{es},
236 @code{de}, @code{pt-BR}.
239 @node SPV label Element
240 @subsection The @code{label} Element
242 Parent: @code{heading} or @code{container} @*
245 Every @code{heading} and @code{container} holds a @code{label} as its
246 first child. The root @code{heading} in a structure member always
247 contains the string ``Output''. Otherwise, the text in @code{label}
248 describes what it labels, often by naming the statistical procedure
249 that was executed, e.g.@: ``Frequencies'' or ``T-Test''. Labels are
250 often very generic, especially within a @code{container}, e.g.@:
251 ``Title'' or ``Warnings'' or ``Notes''. Label text is localized
252 according to the output language, e.g.@: in Italian a frequency table
253 procedure is labeled ``Frequenze''.
255 The corpus contains one example of an empty label, one that contains
258 This element has no attributes.
260 @node SPV container Element
261 @subsection The @code{container} Element
263 Parent: @code{heading} @*
264 Contents: @code{label} [@code{table} @math{|} @code{text}]
266 A @code{container} serves to label a @code{table} or a @code{text}
269 This element has the following attributes.
271 @defvr {Required} @code{visibility}
272 Either @code{visible} or @code{hidden}, this indicates whether the
273 container's content is displayed.
276 @defvr {Optional} @code{text-align}
277 Presumably indicates the alignment of text within the container. The
278 only observed value is @code{left}. Observed with nested @code{table}
279 and @code{text} elements.
282 @defvr {Optional} @code{width}
283 The width of the container in the form @code{@var{n}px}, e.g.@:
287 @node SPV text Element (Inside @code{container})
288 @subsection The @code{text} Element (Inside @code{container})
290 Parent: @code{container} @*
291 Contents: @code{html}
293 This @code{text} element is nested inside a @code{container}. There
294 is a different @code{text} element that is nested inside a
295 @code{pageParagraph}.
297 This element has the following attributes.
299 @defvr {Required} @code{type}
300 One of @code{title}, @code{log}, or @code{text}.
303 @defvr {Optional} @code{commandName}
304 As on the @code{heading} element. For output not specific to a
305 command, this is simply @code{log}. The corpus contains one example
306 of where @code{commandName} is present but set to the empty string.
309 @defvr {Optional} @code{creator-version}
310 As on the @code{heading} element.
313 @node SPV html Element
314 @subsection The @code{html} Element
316 Parent: @code{text} @*
319 The CDATA contains an HTML document. In some cases, the document
320 starts with @code{<html>} and ends with @code{</html}; in others the
321 @code{html} element is implied. Generally the HTML includes a
322 @code{head} element with a CSS stylesheet. The HTML body often begins
323 with @code{<BR>}. The actual content ranges from trivial to simple:
324 just discarding the CSS and tags yields readable results.
326 This element has the following attributes.
328 @defvr {Required} @code{lang}
329 This always contains @code{en} in the corpus.
332 @node SPV table Element
333 @subsection The @code{table} Element
335 Parent: @code{container} @*
336 Contents: @code{tableStructure}
338 This element has the following attributes.
340 @defvr {Required} @code{commandName}
341 As on the @code{heading} element.
344 @defvr {Required} @code{type}
345 One of @code{table}, @code{note}, or @code{warning}.
348 @defvr {Required} @code{subType}
349 The locale-invariant name for the particular kind of output that this
350 table represents in the procedure. This can be the same as
351 @code{commandName} e.g.@: @code{Frequencies}, or different, e.g.@:
352 @code{Case Processing Summary}. Generic subtypes @code{Notes} and
353 @code{Warnings} are often used.
356 @defvr {Required} @code{tableId}
357 A number that uniquely identifies the table within the SPV file,
358 typically a large negative number such as @code{-4147135649387905023}.
361 @defvr {Optional} @code{creator-version}
362 As on the @code{heading} element. In the corpus, this is only present
363 for version 21 and up and always includes all 8 digits.
366 @node SPV tableStructure Element
367 @subsection The @code{tableStructure} Element
369 Parent: @code{table} @*
370 Contents: @code{dataPath}
372 This element has no attributes.
374 @node SPV dataPath Element
375 @subsection The @code{dataPath} Element
377 Parent: @code{tableStructure} @*
380 Contains the name of the Zip member that holds the table details,
381 e.g.@: @code{0000000001437_lightTableData.bin}.
383 This element has no attributes.
385 @node SPV pageSetup Element
386 @subsection The @code{pageSetup} Element
388 Parent: @code{heading} @*
389 Contents: @code{pageHeader} @code{pageFooter}
391 This element has the following attributes.
393 @defvr {Required} @code{initial-page-number}
397 @defvr {Optional} @code{chart-size}
398 Always @code{as-is} or a localization (!) of it (e.g.@: @code{dimensione
399 attuale}, @code{Wie vorgegeben}).
402 @defvr {Optional} @code{margin-left}
403 @defvrx {Optional} @code{margin-right}
404 @defvrx {Optional} @code{margin-top}
405 @defvrx {Optional} @code{margin-bottom}
406 Margin sizes in the form @code{@var{size}in}, e.g.@: @code{0.25in}.
409 @defvr {Optional} @code{paper-height}
410 @defvrx {Optional} @code{paper-width}
411 Paper sizes in the form @code{@var{size}in}, e.g.@: @code{8.5in} by
412 @code{11in} for letter paper or @code{8.267in} by @code{11.692in} for
416 @defvr {Optional} @code{reference-orientation}
420 @defvr {Optional} @code{space-after}
424 @node SPV pageHeader and pageFooter Elements
425 @subsection The @code{pageHeader} and @code{pageFooter} Elements
427 Parent: @code{pageSetup} @*
428 Contents: @code{pageParagraph}*
430 This element has no attributes.
432 @node SPV pageParagraph Element
433 @subsection The @code{pageParagraph} Element
435 Parent: @code{pageHeader} or @code{pageFooter} @*
436 Contents: @code{text}
438 Text to go at the top or bottom of a page, respectively.
440 This element has no attributes.
442 @node SPV @code{text} Element (Inside @code{pageParagraph})
443 @subsection The @code{text} Element (Inside @code{pageParagraph})
445 Parent: @code{pageParagraph} @*
448 This @code{text} element is nested inside a @code{pageParagraph}. There
449 is a different @code{text} element that is nested inside a
452 The element is either empty, or contains CDATA that holds almost-XHTML
453 text: in the corpus, either an @code{html} or @code{p} element. It is
454 @emph{almost}-XHTML because the @code{html} element designates the
456 @code{http://xml.spss.com/spss/viewer/viewer-tree} instead of an XHTML
457 namespace, and because the CDATA can contain substitution variables:
458 @code{&[Page]} for the page number and @code{&[PageTitle]} for the
461 Typical contents (indented for clarity):
464 <html xmlns="http://xml.spss.com/spss/viewer/viewer-tree">
467 <p style="text-align:right; margin-top: 0">Page &[Page]</p>
472 This element has the following attributes.
474 @defvr {Required} @code{type}
478 @node SPV Light Detail Member Format
479 @section Light Detail Member Format
481 This section describes the format of ``light'' detail @file{.bin}
482 members. These members have a binary format which we describe here in
483 terms of a context-free grammar using the following conventions:
486 @item NonTerminal @result{} @dots{}
487 Nonterminals have CamelCaps names, and @result{} indicates a
488 production. The right-hand side of a production is often broken
489 across multiple lines. Break points are chosen for aesthetics only
490 and have no semantic significance.
492 @item 00, 01, @dots{}, ff.
493 Bytes with fixed values are written in hexadecimal:
495 @item i0, i1, @dots{}, i9, i10, i11, @dots{}
496 32-bit integers with fixed values are written in decimal, prefixed by
503 An arbitrary 32-bit integer.
506 An arbitrary 64-bit IEEE floating-point number.
509 A 32-bit integer followed by the specified number of bytes of
510 character data. (The encoding is indicated by the Formats
514 @var{x} is optional, e.g.@: 00? is an optional zero byte.
516 @item @var{x}*@var{n}
517 @var{x} is repeated @var{n} times, e.g. byte*10 for ten arbitrary bytes.
519 @item @var{x}[@var{name}]
520 Gives @var{x} the specified @var{name}. Names are used in textual
521 explanations. They are also used, also bracketed, to indicate counts,
522 e.g.@: int[@t{n}] byte*[@t{n}] for a 32-bit integer followed by the
523 specified number of arbitrary bytes.
525 @item @var{a} @math{|} @var{b}
526 Either @var{a} or @var{b}.
529 Parentheses are used for grouping to make precedence clear, especially
530 in the presence of @math{|}, e.g.@: in 00 (01 @math{|} 02 @math{|} 03)
534 A 32-bit integer that indicates the number of bytes in @var{x},
535 followed by @var{x} itself.
538 In a version 1 @file{.bin} member, @var{x}; in version 3, nothing.
539 (The @file{.bin} header indicates the version.)
542 In a version 3 @file{.bin} member, @var{x}; in version 1, nothing.
545 All integer and floating-point values in this format use little-endian
548 A ``light'' detail member @file{.bin} consists of a number of sections
549 concatenated together, terminated by a byte 01:
553 LightMember @result{} Header Title Caption Footnotes Fonts Formats Dimensions Data 01
557 The following sections go into more detail.
560 * SPV Light Member Header::
561 * SPV Light Member Title::
562 * PSV Light Member Caption::
563 * SPV Light Member Footnotes::
564 * SPV Light Member Fonts::
565 * SPV Light Member Formats::
566 * SPV Light Member Dimensions::
567 * SPV Light Member Categories::
568 * SPV Light Member Data::
569 * SPV Light Member Value::
570 * SPV Light Member ValueMod::
573 @node SPV Light Member Header
576 An SPV file begins with an 39-byte header:
582 (i1 @math{|} i3)[@t{version}]
583 01 (00 @math{|} 01) byte*21 00 00
584 int[@t{table-id}] byte*4
588 @code{version} is a version number that affects the interpretation of
589 some of the other data in the member. We will refer to ``version 1''
590 and ``version 3'' later on and use v1(@dots{}) and v3(@dots{}) for
591 version-specific formatting (as described previously).
593 @code{table-id} is a binary version of the @code{tableId} attribute in
594 the structure member that refers to the detail member. For example,
595 if @code{tableId} is @code{-4154297861994971133}, then @code{table-id}
598 The meaning of the other variable parts of the header is not known.
600 @node SPV Light Member Title
606 Value[@t{title1}] 01?
608 Value[@t{title2}] 01? 00? 58
612 The Title, which follows the Header, specifies the pivot table's title
613 twice, as @code{title1} and @code{title2}. In the corpus, they are
616 Whereas the Value in @code{title1} and in @code{title2} are
617 appropriate for presentation, and localized to the user's language,
618 @code{c} is in English, sometimes less specific, and sometimes less
619 well formatted. For example, for a frequency table, @code{title1} and
620 @code{title2} name the variable and @code{c} is simply ``Frequencies''.
622 @node PSV Light Member Caption
627 Caption @result{} 58 @math{|} 31 Value[@t{caption}]
631 The @code{caption}, if presented, is shown below the table.
633 @node SPV Light Member Footnotes
634 @subsection Footnotes
638 Footnotes @result{} int[@t{n}] Footnote*[@t{n}]
639 Footnote @result{} Value[@t{text}] (58 @math{|} 31 Value[@t{marker}]) byte*4
643 Each footnote has @code{text} and an optional customer @code{marker}
646 @node SPV Light Member Fonts
651 Fonts @result{} 00 Font*8
653 byte[@t{index}] 31 string[@t{typeface}] 00 00
654 (10 @math{|} 20 @math{|} 40 @math{|} 50 @math{|} 70 @math{|} 80)[@t{f1}] 41
655 (i0 @math{|} i1 @math{|} i2)[@t{f2}] 00
656 (i0 @math{|} i2 @math{|} i64173)[@t{f3}]
657 (i0 @math{|} i1 @math{|} i2 @math{|} i3)[@t{f4}]
658 string[@t{fgcolor}] string[@t{bgcolor}] i0 i0 00
659 v3(int[@t{f5}] int[@t{f6}] int[@t{f7}] int[@t{f8}]))
663 Each Font represents the font style for a different element, in the
664 following order: title, caption, footnote, row labels, column labels,
665 corner labels, data, and layers.
667 @code{index} is the 1-based index of the Font, i.e. 1 for the first
668 Font, through 8 for the final Font.
670 @code{typeface} is the string name of the font. In the corpus, this
671 is @code{SansSerif} in over 99% of instances and @code{Times New
674 @code{fgcolor} and @code{bgcolor} are the foreground color and
675 background color, respectively. In the corpus, these are always
676 @code{#000000} and @code{#ffffff}, respectively.
678 The meaning of the remaining data is unknown. It seems likely to
679 include font sizes, horizontal and vertical alignment, attributes such
680 as bold or italic, and margins.
682 The table below lists the values observed in the corpus. When a cell
683 contains a single value, then 99@math{+}% of the corpus contains that value.
684 When a cell contains a pair of values, then the first value is seen in
685 about two-thirds of the corpus and the second value in about the
686 remaining one-third. In fonts that include multiple pairs, values are
687 correlated, that is, for font 3, f5 = 24, f6 = 24, f7 = 2 appears
688 about two-thirds of the time, as does the combination of f4 = 0, f6 =
691 @multitable {font} {40} {f2} {64173} {0/1} {24/11} {10/11} {2/3} {f8}
692 @headitem font @tab f1 @tab f2 @tab f3 @tab f4 @tab f5 @tab f6 @tab f7 @tab f8
693 @item 1 @tab 40 @tab 1 @tab 0 @tab 0 @tab 8 @tab 10/11 @tab 1 @tab 8
694 @item 2 @tab 40 @tab 0 @tab 2 @tab 1 @tab 8 @tab 10/11 @tab 1 @tab 1
695 @item 3 @tab 40 @tab 0 @tab 2 @tab 1 @tab 24/11 @tab 24/ 8 @tab 2/3 @tab 4
696 @item 4 @tab 40 @tab 0 @tab 2 @tab 3 @tab 8 @tab 10/11 @tab 1 @tab 1
697 @item 5 @tab 40 @tab 0 @tab 0 @tab 1 @tab 8 @tab 10/11 @tab 1 @tab 4
698 @item 6 @tab 40 @tab 0 @tab 2 @tab 1 @tab 8 @tab 10/11 @tab 1 @tab 4
699 @item 7 @tab 40 @tab 0 @tab 64173 @tab 0/1 @tab 8 @tab 10/11 @tab 1 @tab 1
700 @item 8 @tab 40 @tab 0 @tab 2 @tab 3 @tab 8 @tab 10/11 @tab 1 @tab 4
703 @node SPV Light Member Formats
709 int[@t{n1}] byte*[@t{n1}]
710 int[@t{n2}] byte*[@t{n2}]
711 int[@t{n3}] byte*[@t{n3}]
712 int[@t{n4}] int*[@t{n4}]
714 (i0 @math{|} i-1) (00 @math{|} 01) 00 (00 @math{|} 01)
716 byte[@t{decimal}] byte[@t{grouping}]
717 int[@t{n-ccs}] string*[@t{n-ccs}]
719 v3(count(count(X5) count(X6)))
721 X5 @result{} byte*33 int[@t{n}] int*[@t{n}]
723 01 00 (03 @math{|} 04) 00 00 00
724 string[@t{command}] string[@t{subcommand}]
725 string[@t{language}] string[@t{charset}] string[@t{locale}]
726 (00 @math{|} 01) 00 (00 @math{|} 01) (00 @math{|} 01)
728 byte[@t{decimal}] byte[@t{grouping}]
730 (string[@t{dataset}] string[@t{datafile}] i0 int i0)?
731 int[@t{n-ccs}] string*[@t{n-ccs}]
732 2e (00 @math{|} 01) (i2000000 i0)?
736 In every example in the corpus, @code{n1} is 240. The meaning of the
737 bytes that follow it is unknown.
739 In every example in the corpus, @code{n2} is 18 and the bytes that
740 follow it are @code{00 00 00 01 00 00 00 00 00 00 00 00 00 02 00 00 00
741 00}. The meaning of these bytes is unknown.
743 In every example in the corpus for version 1, @code{n3} is 16 and the
744 bytes that follow it are @code{00 00 00 01 00 00 00 01 00 00 00 00 01
745 01 01 01}. In version 3, observed @code{n3} varies from 117 to 150,
746 and its bytes include a 1-byte count at offset 0x34. When the count
747 is nonzero, a text string of that length at offset 0x35 is the name of
748 a ``TableLook'', e.g. ``Default'' or ``Academic''.
750 Observed values of @code{n4} vary from 0 to 17. Out of 7,060 examples
751 in the corpus, it is nonzero only 36 times.
753 @code{encoding} is a character encoding, usually a Windows code page
754 such as @code{en_US.windows-1252} or @code{it_IT.windows-1252}. The
755 rest of the character strings in the member use this encoding. The
756 encoding string is itself encoded in US-ASCII.
758 @code{decimal} is the decimal point character. The observed values
759 are @samp{.} and @samp{,}.
761 @code{grouping} is the grouping character. Usually, it is @samp{,} if
762 @code{decimal} is @samp{.}, and vice versa. Other observed values are
763 @samp{'} (apostrophe), @samp{ } (space), and zero (presumably
764 indicating that digits should not be grouped).
766 @code{n-ccs} is observed as either 0 or 5. When it is 5, the
767 following strings are CCA through CCE format strings. @xref{Custom
768 Currency Formats,,, pspp, PSPP}. Most commonly these are all
769 @code{-,,,} but other strings occur.
771 @node SPV Light Member Dimensions
772 @subsection Dimensions
774 A pivot table presents multidimensional data. A Dimension identifies
775 the categories associated with each dimension.
779 Dimensions @result{} int[@t{n-dims}] Dimension*[@t{n-dims}]
780 Dimension @result{} Value[@t{name}] DimUnknown int[@t{n-categories}] Category*[@t{n-categories}]
783 (00 @math{|} 01 @math{|} 02)[@t{d2}]
784 (i0 @math{|} i2)[@t{d3}]
785 (00 @math{|} 01)[@t{d4}]
786 (00 @math{|} 01)[@t{d5}]
792 @code{name} is the name of the dimension, e.g. @code{Variables},
793 @code{Statistics}, or a variable name.
795 @code{d1} is usually 0 but many other values have been observed.
797 @code{d3} is 2 over 99% of the time.
799 @code{d5} is 0 over 99% of the time.
801 @code{d6} is either -1 or the 0-based index of the dimension, e.g.@: 0
802 for the first dimension, 1 for the second, and so on. The latter is
803 the case 98% of the time in the corpus.
805 @node SPV Light Member Categories
806 @subsection Categories
808 Categories are arranged in a tree. Only the leaf nodes in the tree
809 are really categories; the others just serve as grouping constructs.
813 Category @result{} Value[@t{name}] (Leaf @math{|} Group)
814 Leaf @result{} 00 00 00 i2 int[@t{index}] i0
816 (00 @math{|} 01)[@t{merge}] 00 01 (i0 @math{|} i2)[@t{data}]
817 i-1 int[@t{n-subcategories}] Category*[@t{n-subcategories}]
821 @code{name} is the name of the category (or group).
823 A Leaf represents a leaf category. The Leaf's @code{index} is a
824 nonnegative integer less than @code{n-categories} in the Dimension in
825 which the Category is nested (directly or indirectly).
827 A Group represents a Group of nested categories. Usually a Group
828 contains at least one Category, so that @code{n-subcategories} is
829 positive, but a few Groups with @code{n-subcategories} 0 has been
832 If a Group's @code{merge} is 00, the most common value, then the group
833 is really a distinct group that should be represented as such in the
834 visual representation and user interface. If @code{merge} is 01, the
835 categories in this group should be shown and treated as if they were
836 direct children of the group's containing group (or if it has no
837 parent group, then direct children of the dimension), and this group's
838 name is irrelevant and should not be displayed. (Merged groups can be
841 A Group's @code{data} appears to be i2 when all of the categories
842 within a group are leaf categories that directly represent data values
843 for a variable (e.g. in a frequency table or crosstabulation, a group
844 of values in a variable being tabulated) and i0 otherwise.
846 @node SPV Light Member Data
849 The final part of an SPV light member contains the actual data.
854 int[@t{layers}] int[@t{rows}] int[@t{columns}] int*[@t{n-dimensions}]
855 int[@t{n-data}] Datum*[@t{n-data}]
856 Datum @result{} int64[@t{index}] v3(00?) Value
860 The values of @code{layers}, @code{rows}, and @code{columns} each
861 specifies the number of dimensions displayed in layers, rows, and
862 columns, respectively. Any of them may be zero. Their values sum to
863 @code{n-dimensions} from Dimensions (@pxref{SPV Light Member
866 The @code{n-dimensions} integers are a permutation of the 0-based
867 dimension numbers. The first @code{layers} integers specify each of
868 the dimensions represented by layers, the next @code{rows} integers
869 specify the dimensions represented by rows, and the final
870 @code{columns} integers specify the dimensions represented by columns.
871 When there is more than one dimension of a given kind, the inner
872 dimensions are given first.
874 The format of a Datum varies slightly from version 1 to version 3: in
875 version 1 it allows for an extra optional 00 byte.
877 A Datum consists of an @code{index} and a Value. Suppose there are
878 @math{d} dimensions and dimension @math{i}, @math{0 \le i < d}, has
879 @math{n_i} categories. Consider the datum at coordinates @math{x_i},
880 @math{0 \le i < d}, and note that @math{0 \le x_i < n_i}. Then the
881 index is calculated by the following algorithm:
885 for each @math{i} from 0 to @math{d - 1}:
886 @i{index} = (@math{n_i \times} @i{index}) @math{+} @math{x_i}
889 For example, suppose there are 3 dimensions with 3, 4, and 5
890 categories, respectively. The datum at coordinates (1, 2, 3) has
891 index @math{5 \times (4 \times (3 \times 0 + 1) + 2) + 3 = 33}.
893 @node SPV Light Member Value
896 Value is used throughout the SPV light member format. It boils down
897 to a number or a string.
901 Value @result{} 00? 00? 00? 00? RawValue
903 01 ValueMod int[@t{format}] double[@t{x}]
904 @math{|} 02 ValueMod int[@t{format}] double[@t{x}]
905 string[@t{varname}] string[@t{vallab}] (01 @math{|} 02 @math{|} 03)
906 @math{|} 03 string[@t{local}] ValueMod string[@t{id}] string[@t{c}] (00 @math{|} 01)[@t{type}]
907 @math{|} 04 ValueMod int[@t{format}] string[@t{vallab}] string[@t{varname}]
908 (01 @math{|} 02 @math{|} 03) string[@t{s}]
909 @math{|} 05 ValueMod string[@t{varname}] string[@t{varlabel}] (01 @math{|} 02 @math{|} 03)
910 @math{|} ValueMod string[@t{format}] int[@t{n-args}] Argument*[@t{n-args}]
913 @math{|} int[@t{x}] i0 Value*[@t{x}@math{+}1] /* @t{x} @math{>} 0 */
917 There are several possible encodings, which one can distinguish by the
918 first nonzero byte in the encoding.
922 The numeric value @code{x}, intended to be presented to the user
923 formatted according to @code{format}, which is in the format described
924 for system files. @xref{System File Output Formats}, for details.
925 Most commonly, @code{format} has width 40 (the maximum).
927 An @code{x} with the maximum negative double value @code{-DBL_MAX}
928 represents the system-missing value SYSMIS. (HIGHEST and LOWEST have
929 not been observed.) @xref{System File Format}, for more about these
933 Similar to @code{01}, with the additional information that @code{x} is
934 a value of variable @code{varname} and has value label @code{vallab}.
935 Both @code{varname} and @code{vallab} can be the empty string, the
936 latter very commonly.
938 The meaning of the final byte is unknown. Possibly it is connected to
939 whether the value or the label should be displayed.
942 A text string, in two forms: @code{c} is in English, and sometimes
943 abbreviated or obscure, and @code{local} is localized to the user's
944 locale. In an English-language locale, the two strings are often the
945 same, and in the cases where they differ, @code{local} is more
946 appropriate for a user interface, e.g.@: @code{c} of ``Not a PxP table
947 for MCN...'' versus @code{local} of ``Computed only for a PxP table,
948 where P must be greater than 1.''
950 @code{c} and @code{local} are always either both empty or both
953 @code{id} is a brief identifying string whose form seems to resemble a
954 programming language identifier, e.g.@: @code{cumulative_percent} or
955 @code{factor_14}. It is not unique.
957 @code{type} is 00 for text taken from user input, such as syntax
958 fragment, expressions, file names, data set names, and 01 for fixed
959 text strings such as names of procedures or statistics. In the former
960 case, @code{id} is always the empty string; in the latter case,
961 @code{id} is still sometimes empty.
964 The string value @code{s}, intended to be presented to the user
965 formatted according to @code{format}. The format for a string is not
966 too interesting, and the corpus contains many clearly invalid formats
967 like A16.39 or A255.127 or A134.1, so readers should probably ignore
970 @code{s} is a value of variable @code{varname} and has value label
971 @code{vallab}. @code{varname} is never empty but @code{vallab} is
974 The meaning of the final byte is unknown.
977 Variable @code{varname}, which is rarely observed as empty in the
978 corpus, with variable label @code{varlabel}, which is often empty.
980 The meaning of the final byte is unknown.
983 (These bytes begin a ValueMod.) A format string, analogous to
984 @code{printf}, followed by one or more Arguments, each of which has
985 one or more values. The format string uses the following syntax:
992 Each of these expands to the character following @samp{\\}, to escape
993 characters that have special meaning in format strings. These are
994 effective inside and outside the @code{[@dots{}]} syntax forms
998 Expands to a new-line, inside or outside the @code{[@dots{}]} forms
1002 Expands to a formatted version of argument @var{i}, which must have
1003 only a single value. For example, @code{^1} expands to the first
1004 argument's @code{value}.
1006 @item [:@var{a}:]@var{i}
1007 Expands @var{a} for each of the values in @var{i}. @var{a}
1008 should contain one or more @code{^@var{j}} conversions, which are
1009 drawn from the values for argument @var{i} in order. Some examples
1014 All of the values for the first argument, concatenated.
1017 Expands to the values for the first argument, each followed by
1021 Expands to @code{@var{x} = @var{y}} where @var{x} is the second
1022 argument's first value and @var{y} is its second value. (This would
1023 be used only if the argument has two values. If there were more
1024 values, the second and third values would be directly concatenated,
1025 which would look funny.)
1028 @item [@var{a}:@var{b}:]@var{i}
1029 This extends the previous form so that the first values are expanded
1030 using @var{a} and later values are expanded using @var{b}. For an
1031 unknown reason, within @var{a} the @code{^@var{j}} conversions are
1032 instead written as @code{%@var{j}}. Some examples from the corpus:
1036 Expands to all of the values for the first argument, separated by
1039 @item [%1 = %2:, ^1 = ^2:]1
1040 Given appropriate values for the first argument, expands to @code{X =
1044 Given appropriate values, expands to @code{1, 2, 3}.
1048 The format string is localized to the user's locale.
1051 @node SPV Light Member ValueMod
1052 @subsection ValueMod
1054 A ValueMod can specify special modifications to a Value.
1059 31 i0 (i0 @math{|} i1 string[@t{subscript}])
1060 v1(00 (i1 @math{|} i2) 00 00 int 00 00)
1061 v3(count(FormatString Style ValueModUnknown))
1062 @math{|} 31 i1 int[@t{footnote-number}] Format
1063 @math{|} 31 i2 (00 @math{|} 01 @math{|} 02) 00 (i1 @math{|} i2 @math{|} i3) Format
1064 @math{|} 31 i3 00 00 01 00 i2 Format
1066 Style @result{} 58 @math{|} 31 01? 00? 00? 00? 01 string[@t{fgcolor}] string[@t{bgcolor}] string[@t{typeface}] byte
1067 Format @result{} 00 00 count(FormatString Style 58)
1068 FormatString @result{} count((i0 (58 @math{|} 31 string))?)
1069 ValueModUnknown @result{} 58 @math{|} 31 i0 i0 i0 i0 01 00 (01 @math{|} 02 @math{|} 08) 00 08 00 0a 00)
1073 The @code{footnote-number}, if present, specifies a footnote that the
1074 Value references. The footnote's marker is shown appended to the main
1075 text of the Value, as a superscript.
1077 The @code{subscript}, if present, specifies a string to append to the
1078 main text of the Value, as a subscript. The subscript text is a brief
1079 indicator, e.g.@: @samp{a} or @samp{a,b}, with its meaning indicated
1080 by the table caption. In this usage, subscripts are similar to
1081 footnotes; one apparent difference is that a Value can only reference
1082 one footnote but a subscript can list more than one letter.
1084 The Format, if present, is a format string for substitutions using the
1085 syntax explained previously. It appears to be an English-language
1086 version of the localized format string in the Value in which the
1089 The Style, if present, changes the style for this individual Value.
1091 @node SPV Legacy Detail Member Binary Format
1092 @section Legacy Detail Member Binary Format
1094 Whereas the light binary format represents everything about a given
1095 pivot table, the legacy binary format conceptually consists of a
1096 number of named sources, each of which consists of a number of named
1097 series, each of which is a 1-dimensional array of numbers or strings
1098 or a mix. Thus, the legacy binary member format is quite simple.
1100 This section uses the same context-free grammar notation as in the
1101 previous section, with the following additions:
1105 In a version 0xaf legacy member, @var{x}; in other versions, nothing.
1106 (The legacy member header indicates the version; see below.)
1109 In a version 0xb0 legacy member, @var{x}; in other versions, nothing.
1112 A legacy detail member @file{.bin} has the following overall format:
1116 LegacyBinary @result{}
1117 00 byte[@t{version}] int16[@t{n-sources}] int[@t{member-size}]
1118 Metadata*[@t{n-sources}] Data*[@t{n-sources}]
1122 @code{version} is a version number that affects the interpretation of
1123 some of the other data in the member. Versions 0xaf and 0xb0 are
1124 known. We will refer to ``version 0xaf'' and ``version 0xb0'' members
1127 A legacy member consists of @code{n-sources} data sources, each of
1128 which has Metadata and Data.
1130 @code{member-size} is the size of the legacy binary member, in bytes.
1132 The following sections go into more detail.
1135 * SPV Legacy Member Metadata::
1136 * SPV Legacy Member Data::
1139 @node SPV Legacy Member Metadata
1140 @subsection Metadata
1145 int[@t{per-series}] int[@t{n-series}] int[@t{offset}]
1146 vAF(byte*32[@t{source-name}])
1147 vB0(byte*64[@t{source-name}] int[@t{x}])
1151 A data source consists of @code{n-series} series of data, with
1152 @code{per-series} data values per series.
1154 @code{source-name} is a 32- or 64-byte string padded on the right with
1155 zero bytes. The names that appear in the corpus are very generic,
1156 usually @code{tableData} or @code{source0}.
1158 A given Metadata's @code{offset} is the offset, in bytes, from the
1159 beginning of the member to the start of the corresponding Data. This
1160 allows programs to skip to the beginning of the data for a particular
1161 source; it is also important to determine whether a source includes
1162 any string data (@pxref{SPV Legacy Member Data}).
1164 The meaning of @code{x} in version 0xb0 is unknown.
1166 @node SPV Legacy Member Data
1171 Data @result{} NumericData StringData?
1172 NumericData @result{} NumericSeries*[@t{n-series}]
1173 NumericSeries @result{} byte*288[@t{series-name}] double*[@t{per-series}]
1177 Data follow the Metadata in the legacy binary format, with sources in
1178 the same order. Each NumericSeries begins with a @code{series-name}
1179 that generally indicates its role in the pivot table, e.g.@: ``cell'',
1180 ``cellFormat'', ``dimension0categories'', ``dimension0group0'',
1181 followed by the numeric data, one double per element in the series. A
1182 double with the maximum negative double @code{-DBL_MAX} represents the
1183 system-missing value SYSMIS.
1187 StringData @result{} i1 string[@t{source-name}] Pairs Labels
1189 Pairs @result{} int[@t{n-string-series}] PairSeries*[@t{n-string-series}]
1190 PairSeries @result{} string[@t{pair-series-name}] int[@t{n-pairs}] Pair*[@t{n-pairs}]
1191 Pair @result{} int[@t{i}] int[@t{j}]
1193 Labels @result{} int[@t{n-labels}] Label*[@t{n-labels}]
1194 Label @result{} int[@t{frequency}] int[@t{s}]
1198 A source may include a mix of numeric and string data values. When a
1199 source includes any string data, the data values that are strings are
1200 set to SYSMIS in the NumericSeries, and StringData follows the
1201 NumericData. A source that contains no string data omits the
1202 StringData. To reliably determine whether a source includes
1203 StringData, the reader should check whether the offset following the
1204 NumericData is the offset of the next series, as indicated by its
1205 Metadata (or the end of the member, in the case of the last source).
1207 StringData repeats the name of the source (from Metadata).
1209 The string data overlays the numeric data. @code{n-string-series} is
1210 the number of series within the source that include string data. More
1211 precisely, it is the 1-based index of the last series in the source
1212 that includes any string data; thus, it would be 4 if there are 5
1213 series and only the fourth one includes string data.
1215 Each PairSeries consists a sequence of 0 or more Pair nonterminals,
1216 each of which maps from a 0-based index within series @code{i} to a
1217 0-based label index @code{j}, e.g.@: pair @code{i} = 2, @code{j} = 3,
1218 means that the third data value (with value SYSMIS) is to be replaced
1219 by the string of the fourth Label.
1221 The labels themselves follow the pairs. The valuable part of each
1222 label is the string @code{s}. Each label also includes a
1223 @code{frequency} that reports the number of pairs that reference it
1224 (although this is not useful).
1226 @node SPV Legacy Detail Member XML Format
1227 @section Legacy Detail Member XML Format
1229 This format is still under investigation.