Minor improvements.
[pspp] / spv-file-format.texi
1 @node SPSS Viewer File Format
2 @chapter SPSS Viewer File Format
3
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
9 them.
10
11 SPSS 15 and earlier versions use a completely different output format
12 based on the Microsoft Compound Document Format.  This format is not
13 documented here.
14
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
23 corpus.)
24
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.
34
35 Structure members contain XML.  This XML is sometimes self-contained,
36 but it often references detail members in the Zip archive, which are
37 named as follows:
38
39 @table @asis
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.
48
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.
52
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.
56
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
59 ``light'' format.
60
61 @item @file{@var{prefix}_pmml.scf}
62 @itemx @file{@var{prefix}_stats.scf}
63 @item @file{@var{prefix}_model.xml}
64 Not yet investigated.  The corpus contains few examples.
65 @end table
66
67 The @file{@var{prefix}} in the names of the detail members is
68 typically an 11-digit decimal number that increases for each item,
69 tending to skip values.  Older SPV files use different naming
70 conventions.  Structure member refer to detail members by name, and so
71 their exact names do not matter to readers as long as they are unique.
72
73 @menu
74 * SPV Structure Member Format::
75 * SPV Light Detail Member Format::
76 * SPV Legacy Detail Member Binary Format::
77 * SPV Legacy Detail Member XML Format::
78 @end menu
79
80 @node SPV Structure Member Format
81 @section Structure Member Format
82
83 Structure members' XML files claim conformance with a collection of
84 XML Schemas.  These schemas are distributed, under a nonfree license,
85 with SPSS binaries.  Fortunately, the schemas are not necessary to
86 understand the structure members.  To a degree, the schemas can even
87 be deceptive because they document elements and attributes that are
88 not in the corpus and do not document elements and attributes that are
89 commonly found there.
90
91 Structure members use a different XML namespace for each schema, but
92 these namespaces are not entirely consistent.  In some SPV files, for
93 example, the @code{viewer-tree} schema is associated with namespace
94 @indicateurl{http://xml.spss.com/spss/viewer-tree} and in others with
95 @indicateurl{http://xml.spss.com/spss/viewer/viewer-tree} (note the
96 additional @file{viewer/}).  Under either name, the schema URIs are
97 not resolvable to obtain the schemas themselves.
98
99 One may ignore all of the above in interpreting a structure member.
100 The actual XML has a simple and straightforward form that does not
101 require a reader to take schemas or namespaces into account.
102
103 The elements found in structure members are documented below.  For
104 each element, we note the possible parent elements and the element's
105 contents.  The contents are specified as pseudo-regular expressions
106 with the following conventions:
107
108 @table @asis
109 @item text
110 XML text content.
111
112 @item CDATA
113 XML CDATA content.
114
115 @item @code{element}
116 The named element.
117
118 @item (@dots{})
119 Grouping multiple elements.
120
121 @item [@var{x}]
122 An optional @var{x}.
123
124 @item @var{a} @math{|} @var{b}
125 A choice between @var{a} and @var{b}.
126
127 @item @var{x}*
128 Zero or more @var{x}.
129 @end table
130
131 @ifnottex
132 For a diagram illustrating the hierarchy of elements within an SPV
133 structure member, please refer to a PDF version of the manual.
134 @end ifnottex
135
136 @iftex
137 The following diagram shows the hierarchy of elements within an SPV
138 structure member.  Edges point from parent to child elements.
139 Unlabeled edges indicate that the child appears exactly once; edges
140 labeled with *, zero or more times; edges labeled with ?, zero or one
141 times.
142 @center @image{dev/spv-structure, 5in}
143 @end iftex
144
145 @menu
146 * SPV Structure heading Element::
147 * SPV Structure label Element::
148 * SPV Structure container Element::
149 * SPV Structure text Element (Inside @code{container})::
150 * SPV Structure html Element::
151 * SPV Structure table Element::
152 * SPV Structure tableStructure Element::
153 * SPV Structure dataPath Element::
154 * SPV Structure pageSetup Element::
155 * SPV Structure pageHeader and pageFooter Elements::
156 * SPV Structure pageParagraph Element::
157 * SPV Structure @code{text} Element (Inside @code{pageParagraph})::
158 @end menu
159
160 @node SPV Structure heading Element
161 @subsection The @code{heading} Element
162
163 Parent: Document root or @code{heading} @*
164 Contents: @code{pageSetup}? @code{label} (@code{container} @math{|} @code{heading})*
165
166 The root of a structure member is a @code{heading}, which represents a
167 section of output beginning with a title (the @code{label}) and
168 ordinarily followed by content containers or further nested
169 (sub)-sections of output.
170
171 The document root heading, only, may also contain a @code{pageSetup}
172 element.
173
174 The following attributes have been observed on both document root and
175 nested @code{heading} elements.
176
177 @defvr {Optional} creator-version
178 The version of the software that created this SPV file.  A string of
179 the form @code{xxyyzzww} represents software version xx.yy.zz.ww,
180 e.g.@: @code{21000001} is version 21.0.0.1.  Trailing pairs of zeros
181 are sometimes omitted, so that @code{21}, @code{210000}, and
182 @code{21000000} are all version 21.0.0.0 (and the corpus contains all
183 three of those forms).
184 @end defvr
185
186 @noindent
187 The following attributes have been observed on document root
188 @code{heading} elements only:
189
190 @defvr {Optional} @code{creator}
191 The directory in the file system of the software that created this SPV
192 file.
193 @end defvr
194
195 @defvr {Optional} @code{creation-date-time}
196 The date and time at which the SPV file was written, in a
197 locale-specific format, e.g.@: @code{Friday, May 16, 2014 6:47:37 PM
198 PDT} or @code{lunedì 17 marzo 2014 3.15.48 CET} or even @code{Friday,
199 December 5, 2014 5:00:19 o'clock PM EST}.
200 @end defvr
201
202 @defvr {Optional} @code{lockReader}
203 Whether a reader should be allowed to edit the output.  The possible
204 values are @code{true} and @code{false}, but the corpus only contains
205 @code{false}.
206 @end defvr
207
208 @defvr {Optional} @code{schemaLocation}
209 This is actually an XML Namespace attribute.  A reader may ignore it.
210 @end defvr
211
212 @noindent
213 The following attributes have been observed only on nested
214 @code{heading} elements:
215
216 @defvr {Required} @code{commandName}
217 The locale-invariant name of the command that produced the output,
218 e.g.@: @code{Frequencies}, @code{T-Test}, @code{Non Par Corr}.
219 @end defvr
220
221 @defvr {Optional} @code{visibility}
222 To what degree the output represented by the element is visible.  The
223 only observed value is @code{collapsed}.
224 @end defvr
225
226 @defvr {Optional} @code{locale}
227 The locale used for output, in Windows format, which is similar to the
228 format used in Unix with the underscore replaced by a hyphen, e.g.@:
229 @code{en-US}, @code{en-GB}, @code{el-GR}, @code{sr-Cryl-RS}.
230 @end defvr
231
232 @defvr {Optional} @code{olang}
233 The output language, e.g.@: @code{en}, @code{it}, @code{es},
234 @code{de}, @code{pt-BR}.
235 @end defvr
236
237 @node SPV Structure label Element
238 @subsection The @code{label} Element
239
240 Parent: @code{heading} or @code{container} @*
241 Contents: text
242
243 Every @code{heading} and @code{container} holds a @code{label} as its
244 first child.  The root @code{heading} in a structure member always
245 contains the string ``Output''.  Otherwise, the text in @code{label}
246 describes what it labels, often by naming the statistical procedure
247 that was executed, e.g.@: ``Frequencies'' or ``T-Test''.  Labels are
248 often very generic, especially within a @code{container}, e.g.@:
249 ``Title'' or ``Warnings'' or ``Notes''.  Label text is localized
250 according to the output language, e.g.@: in Italian a frequency table
251 procedure is labeled ``Frequenze''.
252
253 The corpus contains one example of an empty label, one that contains
254 no text.
255
256 This element has no attributes.
257
258 @node SPV Structure container Element
259 @subsection The @code{container} Element
260
261 Parent: @code{heading} @*
262 Contents: @code{label} (@code{table} @math{|} @code{text})?
263
264 A @code{container} serves to label a @code{table} or a @code{text}
265 item.
266
267 This element has the following attributes.
268
269 @defvr {Required} @code{visibility}
270 Either @code{visible} or @code{hidden}, this indicates whether the
271 container's content is displayed.
272 @end defvr
273
274 @defvr {Optional} @code{text-align}
275 Presumably indicates the alignment of text within the container.  The
276 only observed value is @code{left}.  Observed with nested @code{table}
277 and @code{text} elements.
278 @end defvr
279
280 @defvr {Optional} @code{width}
281 The width of the container in the form @code{@var{n}px}, e.g.@:
282 @code{1097px}.
283 @end defvr
284
285 @node SPV Structure text Element (Inside @code{container})
286 @subsection The @code{text} Element (Inside @code{container})
287
288 Parent: @code{container} @*
289 Contents: @code{html}
290
291 This @code{text} element is nested inside a @code{container}.  There
292 is a different @code{text} element that is nested inside a
293 @code{pageParagraph}.
294
295 This element has the following attributes.
296
297 @defvr {Required} @code{type}
298 One of @code{title}, @code{log}, or @code{text}.
299 @end defvr
300
301 @defvr {Optional} @code{commandName}
302 As on the @code{heading} element.  For output not specific to a
303 command, this is simply @code{log}.  The corpus contains one example
304 of where @code{commandName} is present but set to the empty string.
305 @end defvr
306
307 @defvr {Optional} @code{creator-version}
308 As on the @code{heading} element.
309 @end defvr
310
311 @node SPV Structure html Element
312 @subsection The @code{html} Element
313
314 Parent: @code{text} @*
315 Contents: CDATA
316
317 The CDATA contains an HTML document.  In some cases, the document
318 starts with @code{<html>} and ends with @code{</html}; in others the
319 @code{html} element is implied.  Generally the HTML includes a
320 @code{head} element with a CSS stylesheet.  The HTML body often begins
321 with @code{<BR>}.  The actual content ranges from trivial to simple:
322 just discarding the CSS and tags yields readable results.
323
324 This element has the following attributes.
325
326 @defvr {Required} @code{lang}
327 This always contains @code{en} in the corpus.
328 @end defvr
329
330 @node SPV Structure table Element
331 @subsection The @code{table} Element
332
333 Parent: @code{container} @*
334 Contents: @code{tableStructure}
335
336 This element has the following attributes.
337
338 @defvr {Required} @code{commandName}
339 As on the @code{heading} element.
340 @end defvr
341
342 @defvr {Required} @code{type}
343 One of @code{table}, @code{note}, or @code{warning}.
344 @end defvr
345
346 @defvr {Required} @code{subType}
347 The locale-invariant name for the particular kind of output that this
348 table represents in the procedure.  This can be the same as
349 @code{commandName} e.g.@: @code{Frequencies}, or different, e.g.@:
350 @code{Case Processing Summary}.  Generic subtypes @code{Notes} and
351 @code{Warnings} are often used.
352 @end defvr
353
354 @defvr {Required} @code{tableId}
355 A number that uniquely identifies the table within the SPV file,
356 typically a large negative number such as @code{-4147135649387905023}.
357 @end defvr
358
359 @defvr {Optional} @code{creator-version}
360 As on the @code{heading} element.  In the corpus, this is only present
361 for version 21 and up and always includes all 8 digits.
362 @end defvr
363
364 @node SPV Structure tableStructure Element
365 @subsection The @code{tableStructure} Element
366
367 Parent: @code{table} @*
368 Contents: @code{dataPath}
369
370 This element has no attributes.
371
372 @node SPV Structure dataPath Element
373 @subsection The @code{dataPath} Element
374
375 Parent: @code{tableStructure} @*
376 Contents: text
377
378 Contains the name of the Zip member that holds the table details,
379 e.g.@: @code{0000000001437_lightTableData.bin}.
380
381 This element has no attributes.
382
383 @node SPV Structure pageSetup Element
384 @subsection The @code{pageSetup} Element
385
386 Parent: @code{heading} @*
387 Contents: @code{pageHeader} @code{pageFooter}
388
389 This element has the following attributes.
390
391 @defvr {Required} @code{initial-page-number}
392 Always @code{1}.
393 @end defvr
394
395 @defvr {Optional} @code{chart-size}
396 Always @code{as-is} or a localization (!) of it (e.g.@: @code{dimensione
397 attuale}, @code{Wie vorgegeben}).
398 @end defvr
399
400 @defvr {Optional} @code{margin-left}
401 @defvrx {Optional} @code{margin-right}
402 @defvrx {Optional} @code{margin-top}
403 @defvrx {Optional} @code{margin-bottom}
404 Margin sizes in the form @code{@var{size}in}, e.g.@: @code{0.25in}.
405 @end defvr
406
407 @defvr {Optional} @code{paper-height}
408 @defvrx {Optional} @code{paper-width}
409 Paper sizes in the form @code{@var{size}in}, e.g.@: @code{8.5in} by
410 @code{11in} for letter paper or @code{8.267in} by @code{11.692in} for
411 A4 paper.
412 @end defvr
413
414 @defvr {Optional} @code{reference-orientation}
415 Always @code{0deg}.
416 @end defvr
417
418 @defvr {Optional} @code{space-after}
419 Always @code{12pt}.
420 @end defvr
421
422 @node SPV Structure pageHeader and pageFooter Elements
423 @subsection The @code{pageHeader} and @code{pageFooter} Elements
424
425 Parent: @code{pageSetup} @*
426 Contents: @code{pageParagraph}*
427
428 This element has no attributes.
429
430 @node SPV Structure pageParagraph Element
431 @subsection The @code{pageParagraph} Element
432
433 Parent: @code{pageHeader} or @code{pageFooter} @*
434 Contents: @code{text}
435
436 Text to go at the top or bottom of a page, respectively.
437
438 This element has no attributes.
439
440 @node SPV Structure @code{text} Element (Inside @code{pageParagraph})
441 @subsection The @code{text} Element (Inside @code{pageParagraph})
442
443 Parent: @code{pageParagraph}
444 Contents: CDATA?
445
446 This @code{text} element is nested inside a @code{pageParagraph}.  There
447 is a different @code{text} element that is nested inside a
448 @code{container}.
449
450 The element is either empty, or contains CDATA that holds almost-XHTML
451 text: in the corpus, either an @code{html} or @code{p} element.  It is
452 @emph{almost}-XHTML because the @code{html} element designates the
453 default namespace as
454 @code{http://xml.spss.com/spss/viewer/viewer-tree} instead of an XHTML
455 namespace, and because the CDATA can contain substitution variables:
456 @code{&[Page]} for the page number and @code{&[PageTitle]} for the
457 page title.
458
459 Typical contents (indented for clarity):
460
461 @example
462 <html xmlns="http://xml.spss.com/spss/viewer/viewer-tree">
463     <head></head>
464     <body>
465         <p style="text-align:right; margin-top: 0">Page &[Page]</p>
466     </body>
467 </html>
468 @end example
469
470 This element has the following attributes.
471
472 @defvr {Required} @code{type}
473 Always @code{text}.
474 @end defvr
475
476 @node SPV Light Detail Member Format
477 @section Light Detail Member Format
478
479 This section describes the format of ``light'' detail @file{.bin}
480 members.  These members have a binary format which we describe here in
481 terms of a context-free grammar using the following conventions:
482
483 @table @asis
484 @item NonTerminal @result{} @dots{}
485 Nonterminals have CamelCaps names, and @result{} indicates a
486 production.  The right-hand side of a production is often broken
487 across multiple lines.  Break points are chosen for aesthetics only
488 and have no semantic significance.
489
490 @item 00, 01, @dots{}, ff.
491 A bytes with a fixed value, written as a pair of hexadecimal digits.
492
493 @item i0, i1, @dots{}, i9, i10, i11, @dots{}
494 @itemx b0, b1, @dots{}, b9, b10, b11, @dots{}
495 A 32-bit integer in little-endian or big-endian byte order,
496 respectively, with a fixed value, written in decimal, prefixed by
497 @samp{i}.
498
499 @item byte
500 A byte.
501
502 @item bool
503 A byte with value 0 or 1.
504
505 @item int16
506 @itemx be16
507 A 16-bit integer in little-endian or big-endian byte order,
508 respectively.
509
510 @item int
511 @itemx be32
512 A 32-bit integer in little-endian or big-endian byte order,
513 respectively.
514
515 @item int64
516 @itemx be64
517 A 64-bit integer in little-endian or big-endian byte order,
518 respectively.
519
520 @item double
521 A 64-bit IEEE floating-point number.
522
523 @item float
524 A 32-bit IEEE floating-point number.
525
526 @item string
527 @itemx bestring
528 A 32-bit integer, in little-endian or big-endian byte order,
529 respectively, followed by the specified number of bytes of character
530 data.  (The encoding is indicated by the Formats nonterminal.)
531
532 @item @var{x}?
533 @var{x} is optional, e.g.@: 00? is an optional zero byte.
534
535 @item @var{x}*@var{n}
536 @var{x} is repeated @var{n} times, e.g. byte*10 for ten arbitrary bytes.
537
538 @item @var{x}[@var{name}]
539 Gives @var{x} the specified @var{name}.  Names are used in textual
540 explanations.  They are also used, also bracketed, to indicate counts,
541 e.g.@: int[@t{n}] byte*[@t{n}] for a 32-bit integer followed by the
542 specified number of arbitrary bytes.
543
544 @item @var{a} @math{|} @var{b}
545 Either @var{a} or @var{b}.
546
547 @item (@var{x})
548 Parentheses are used for grouping to make precedence clear, especially
549 in the presence of @math{|}, e.g.@: in 00 (01 @math{|} 02 @math{|} 03)
550 00.
551
552 @item count(@var{x})
553 A 32-bit integer that indicates the number of bytes in @var{x},
554 followed by @var{x} itself.
555
556 @item v1(@var{x})
557 In a version 1 @file{.bin} member, @var{x}; in version 3, nothing.
558 (The @file{.bin} header indicates the version.)
559
560 @item v3(@var{x})
561 In a version 3 @file{.bin} member, @var{x}; in version 1, nothing.
562 @end table
563
564 Little-endian byte order is far more common in this format, but a few
565 pieces of the format use big-endian byte order.
566
567 A ``light'' detail member @file{.bin} consists of a number of sections
568 concatenated together, terminated by a byte 01:
569
570 @cartouche
571 @format
572 LightMember @result{}
573     Header Title
574     Caption Footnotes
575     Fonts Borders PrintSettings TableSettings Formats
576     Dimensions Data
577     01
578 @end format
579 @end cartouche
580
581 The following sections go into more detail.
582
583 @menu
584 * SPV Light Member Header::
585 * SPV Light Member Title::
586 * SPV Light Member Caption::
587 * SPV Light Member Footnotes::
588 * SPV Light Member Fonts::
589 * SPV Light Member Borders::
590 * SPV Light Member Print Settings::
591 * SPV Light Member Table Settings::
592 * SPV Light Member Formats::
593 * SPV Light Member Dimensions::
594 * SPV Light Member Categories::
595 * SPV Light Member Data::
596 * SPV Light Member Value::
597 * SPV Light Member ValueMod::
598 @end menu
599
600 @node SPV Light Member Header
601 @subsection Header
602
603 An SPV light member begins with a 39-byte header:
604
605 @cartouche
606 @format
607 Header @result{}
608     01 00
609     (i1 @math{|} i3)[@t{version}]
610     01 bool*4 int
611     int[@t{min-column-width}] int[@t{max-column-width}]
612     int[@t{min-row-width}] int[@t{max-row-width}]
613     int64[@t{table-id}]
614 @end format
615 @end cartouche
616
617 @code{version} is a version number that affects the interpretation of
618 some of the other data in the member.  We will refer to ``version 1''
619 and ``version 3'' later on and use v1(@dots{}) and v3(@dots{}) for
620 version-specific formatting (as described previously).
621
622 @code{table-id} is a binary version of the @code{tableId} attribute in
623 the structure member that refers to the detail member.  For example,
624 if @code{tableId} is @code{-4122591256483201023}, then @code{table-id}
625 would be 0xc6c99d183b300001.
626
627 @code{min-column-width} is the minimum width that a column will be
628 assigned automatically.  @code{max-column-width} is the maximum width
629 that a column will be assigned to accommodate a long column label.
630 @code{min-row-width} and @code{max-row-width} are a similar range for
631 the width of row labels.  All of these measurements are in 1/96 inch
632 units.
633
634 The meaning of the other variable parts of the header is not known.
635
636 @node SPV Light Member Title
637 @subsection Title
638
639 @cartouche
640 @format
641 Title @result{}
642     Value[@t{title1}] 01?
643     Value[@t{c}] 01? 31
644     Value[@t{title2}] 01?
645 @end format
646 @end cartouche
647
648 The Title, which follows the Header, specifies the pivot table's title
649 twice, as @code{title1} and @code{title2}.  In the corpus, they are
650 always the same.
651
652 Whereas the Value in @code{title1} and in @code{title2} are
653 appropriate for presentation, and localized to the user's language,
654 @code{c} is in English, sometimes less specific, and sometimes less
655 well formatted.  For example, for a frequency table, @code{title1} and
656 @code{title2} name the variable and @code{c} is simply ``Frequencies''.
657
658 @node SPV Light Member Caption
659 @subsection Caption
660
661 @cartouche
662 @format
663 Caption @result{} Caption1 Caption2
664 Caption1 @result{} 31 Value @math{|} 58
665 Caption2 @result{} 31 Value @math{|} 58
666 @end format
667 @end cartouche
668
669 The Caption, if present, is shown below the table.  Caption2 is
670 normally present.  Caption1 is only rarely nonempty; it might reflect
671 user editing of the caption.
672
673 @node SPV Light Member Footnotes
674 @subsection Footnotes
675
676 @cartouche
677 @format
678 Footnotes @result{} int[@t{n}] Footnote*[@t{n}]
679 Footnote @result{} Value[@t{text}] (58 @math{|} 31 Value[@t{marker}]) byte*4
680 @end format
681 @end cartouche
682
683 Each footnote has @code{text} and an optional customer @code{marker}
684 (such as @samp{*}).
685
686 @node SPV Light Member Fonts
687 @subsection Fonts
688
689 @cartouche
690 @format
691 Fonts @result{} 00 Font*8
692 Font @result{}
693     byte[@t{index}] 31
694     string[@t{typeface}] float[@t{size}] int[@t{style}] bool[@t{underline}]
695     int[@t{halign}] int[@t{valign}]
696     string[@t{fgcolor}] string[@t{bgcolor}]
697     byte[@t{alternate}] string[@t{altfg}] string[@t{altbg}]
698     v3(int[@t{left-margin}] int[@t{right-margin}] int[@t{top-margin}] int[@t{bottom-margin}])
699 @end format
700 @end cartouche
701
702 Each Font represents the font style for a different element, in the
703 following order: title, caption, footer, corner, column
704 labels, row labels, data, and layers.
705
706 @code{index} is the 1-based index of the Font, i.e. 1 for the first
707 Font, through 8 for the final Font.
708
709 @code{typeface} is the string name of the font.  In the corpus, this
710 is @code{SansSerif} in over 99% of instances and @code{Times New
711 Roman} in the rest.
712
713 @code{size} is the size of the font, in points.  The most common size
714 in the corpus is 12 points.
715
716 @code{style} is a bit mask.  Bit 0 (with value 1) is set for bold, bit
717 1 (with value 2) is set for italic.
718
719 @code{underline} is 1 if the font is underlined, 0 otherwise.
720
721 @code{halign} specifies horizontal alignment: 0 for center, 2 for
722 left, 4 for right, 61453 for decimal, 64173 for mixed.  Mixed
723 alignment varies according to type: string data is left-justified,
724 numbers and most other formats are right-justified.
725
726 @code{valign} specifies vertical alignment: 0 for center, 1 for top, 3
727 for bottom.
728
729 @code{fgcolor} and @code{bgcolor} are the foreground color and
730 background color, respectively.  In the corpus, these are always
731 @code{#000000} and @code{#ffffff}, respectively.
732
733 @code{alternate} is 01 if rows should alternate colors, 00 if all rows
734 should be the same color.  When @code{alternate} is 01, @code{altfg}
735 and @code{altbg} specify the colors for the alternate rows.
736
737 @code{left-margin}, @code{right-margin}, @code{top-margin}, and
738 @code{bottom-margin} are measured in multiples of 1/96 inch.
739
740 @node SPV Light Member Borders
741 @subsection Borders
742
743 @cartouche
744 @format
745 Borders @result{}
746     b1[@t{endian}]
747     be32[@t{n-borders}] Border*[@t{n-borders}]
748     bool[@t{show-grid-lines}]
749     00 00 00
750
751 Border @result{}
752     be32[@t{border-type}]
753     be32[@t{stroke-type}]
754     be32[@t{color}]
755 @end format
756 @end cartouche
757
758 The Borders reflect how borders between regions are drawn.
759
760 The fixed value of @code{endian} can be used to validate the
761 endianness.
762
763 @code{show-grid-lines} is 1 to draw grid lines, otherwise 0.
764
765 Each Border describes one kind of border.  @code{n-borders} seems to
766 always be 19.  Each @code{border-type} appears once (although in an
767 unpredictable order) and correspond to the following borders:
768
769 @table @asis
770 @item 0
771 Title.
772 @item 1@dots{}4
773 Left, top, right, and bottom outer frame.
774 @item 5@dots{}8
775 Left, top, right, and bottom inner frame.
776 @item 9, 10
777 Left and top of data area.
778 @item 11, 12
779 Horizontal and vertical dimension rows.
780 @item 13, 14
781 Horizontal and vertical dimension columns.
782 @item 15, 16
783 Horizontal and vertical category rows.
784 @item 17, 18
785 Horizontal and vertical category columns.
786 @end table
787
788 @code{stroke-type} describes how a border is drawn, as one of:
789
790 @table @asis
791 @item 0
792 No line.
793 @item 1
794 Solid line.
795 @item 2
796 Dashed line.
797 @item 3
798 Thick line.
799 @item 4
800 Thin line.
801 @item 5
802 Double line.
803 @end table
804
805 @code{color} is an RGB color.  Bits 24--31 are alpha, bits 16--23 are
806 red, 8--15 are green, 0--7 are blue.  An alpha of 255 indicates an
807 opaque color, therefore opaque black is 0xff000000.
808
809 @node SPV Light Member Print Settings
810 @subsection Print Settings
811
812 @cartouche
813 @format
814 PrintSettings @result{}
815     b1[@t{endian}]
816     bool[@t{all-layers}]
817     bool[@t{paginate-layers}]
818     bool[@t{fit-width}]
819     bool[@t{fit-length}]
820     bool[@t{top-continuation}]
821     bool[@t{bottom-continuation}]
822     be32[@t{n-orphan-lines}]
823     bestring[@t{continuation-string}]
824 @end format
825 @end cartouche
826
827 The PrintSettings reflect settings for printing.  The fixed value of
828 @code{endian} can be used to validate the endianness.
829
830 @code{all-layers} is 1 to print all layers, 0 to print only the
831 visible layers.
832
833 @code{paginate-layers} is 1 to print each layer at the start of a new
834 page, 0 otherwise.  (This setting is honored only @code{all-layers} is
835 1, since otherwise only one layer is printed.)
836
837 @code{fit-width} and @code{fit-length} control whether the table is
838 shrunk to fit within a page's width or length, respectively.
839
840 @code{n-orphan-lines} is the minimum number of rows or columns to put
841 in one part of a table that is broken across pages.
842
843 If @code{top-continuation} is 1, then @code{continuation-string} is
844 printed at the top of a page when a table is broken across pages for
845 printing; similarly for @code{bottom-continuation} and the bottom of a
846 page.  Usually, @code{continuation-string} is empty.
847
848 @node SPV Light Member Table Settings
849 @subsection Table Settings
850
851 @cartouche
852 @format
853 TableSettings @result{}
854     be32[@t{endian}]
855     be32
856     be32[@t{current-layer}]
857     bool[@t{omit-empty}]
858     bool[@t{show-row-labels-in-corner}]
859     bool[@t{show-alphabetic-markers}]
860     bool[@t{footnote-marker-position}]
861     v3(
862       byte
863       be32[@t{n}] byte*[@t{n}]
864       bestring[@t{notes}]
865       bestring[@t{table-look}]
866       00...
867     )
868 @end format
869 @end cartouche
870
871 The TableSettings reflect display settings.  The fixed value of
872 @code{endian} can be used to validate the endianness.
873
874 @code{current-layer} is the displayed layer.
875
876 If @code{omit-empty} is 1, empty rows or columns (ones with nothing in
877 any cell) are hidden; otherwise, they are shown.
878
879 If @code{show-row-labels-in-corner} is 1, then row labels are shown in
880 the upper left corner; otherwise, they are shown nested.
881
882 If @code{show-alphabetic-markers} is 1, markers are shown as letters
883 (e.g. @samp{a}, @samp{b}, @samp{c}, @dots{}); otherwise, they are
884 shown as numbers starting from 1.
885
886 When @code{footnote-marker-position} is 1, footnote markers are shown
887 as superscripts, otherwise as subscripts.
888
889 @code{notes} is a text string that contains user-specified notes.  It
890 is displayed when the user hovers the cursor over the table, like
891 ``alt text'' on a webpage.  It is not printed.  It is usually empty.
892
893 @code{table-look} is the name of a SPSS ``TableLook'' table style,
894 such as ``Default'' or ``Academic''; it is often empty.
895
896 TableSettings ends with an arbitrary number of null bytes.
897
898 @node SPV Light Member Formats
899 @subsection Formats
900
901 @cartouche
902 @format
903 Formats @result{}
904     int[@t{nwidths}] int*[@t{nwidths}]
905     string[@t{encoding}]
906     int (00 @math{|} 01) 00 (00 @math{|} 01)
907     int[@t{epoch}]
908     byte[@t{decimal}] byte[@t{grouping}]
909     CustomCurrency
910     v1(i0)
911     v3(count(count(X5) count(X6)))
912
913 CustomCurrency @result{} int[@t{n-ccs}] string*[@t{n-ccs}]
914
915 X5 @result{} byte*33 int[@t{n}] int*[@t{n}]
916 X6 @result{}
917     01 00 (03 @math{|} 04) 00 00 00
918     string[@t{command}] string[@t{subcommand}]
919     string[@t{language}] string[@t{charset}] string[@t{locale}]
920     (00 @math{|} 01) 00 bool bool
921     int[@t{epoch}]
922     byte[@t{decimal}] byte[@t{grouping}]
923     double[@t{small}] 01
924     (string[@t{dataset}] string[@t{datafile}] i0 int[@t{date}] i0)?
925     CustomCurrency
926     byte[@t{missing}] bool (i2000000 i0)?
927 @end format
928 @end cartouche
929
930 If @code{nwidths} is nonzero, then the accompanying integers are
931 column widths as manually adjusted by the user.  (Row heights are
932 computed automatically based on the widths.)
933
934 @code{encoding} is a character encoding, usually a Windows code page
935 such as @code{en_US.windows-1252} or @code{it_IT.windows-1252}.  The
936 rest of the character strings in the member use this encoding.  The
937 encoding string is itself encoded in US-ASCII.
938
939 @code{epoch} is the year that starts the epoch.  A 2-digit year is
940 interpreted as belonging to the 100 years beginning at the epoch.  The
941 default epoch year is 69 years prior to the current year; thus, in
942 2017 this field by default contains 1948.  In the corpus, @code{epoch}
943 ranges from 1943 to 1948, plus some contain -1.
944
945 @code{decimal} is the decimal point character.  The observed values
946 are @samp{.} and @samp{,}.
947
948 @code{grouping} is the grouping character.  Usually, it is @samp{,} if
949 @code{decimal} is @samp{.}, and vice versa.  Other observed values are
950 @samp{'} (apostrophe), @samp{ } (space), and zero (presumably
951 indicating that digits should not be grouped).
952
953 @code{dataset} is the name of the dataset analyzed to produce the
954 output, e.g.@: @code{DataSet1}, and @code{datafile} the name of the
955 file it was read from, e.g.@: @file{C:\Users\foo\bar.sav}.  The latter
956 is sometimes the empty string.
957
958 @code{date} is a date, as seconds since the epoch, i.e.@: since
959 January 1, 1970.  Pivot tables within an SPV files often have dates a
960 few minutes apart, so this is probably a creation date for the tables
961 rather than for the file.
962
963 Sometimes @code{dataset}, @code{datafile}, and @code{date} are present
964 and other times they are absent.  The reader can distinguish by
965 assuming that they are present and then checking whether the
966 presumptive @code{dataset} contains a null byte (a valid string never
967 will).
968
969 @code{n-ccs} is observed as either 0 or 5.  When it is 5, the
970 following strings are CCA through CCE format strings.  @xref{Custom
971 Currency Formats,,, pspp, PSPP}.  Most commonly these are all
972 @code{-,,,} but other strings occur.
973
974 @node SPV Light Member Dimensions
975 @subsection Dimensions
976
977 A pivot table presents multidimensional data.  A Dimension identifies
978 the categories associated with each dimension.
979
980 @cartouche
981 @format
982 Dimensions @result{} int[@t{n-dims}] Dimension*[@t{n-dims}]
983 Dimension @result{} Value[@t{name}] DimUnknown int[@t{n-categories}] Category*[@t{n-categories}]
984 DimUnknown @result{}
985     byte[@t{d1}]
986     (00 @math{|} 01 @math{|} 02)[@t{d2}]
987     (i0 @math{|} i2)[@t{d3}]
988     (00 @math{|} 01)[@t{d4}]
989     (00 @math{|} 01)[@t{d5}]
990     01
991     int[@t{d6}]
992 @end format
993 @end cartouche
994
995 @code{name} is the name of the dimension, e.g. @code{Variables},
996 @code{Statistics}, or a variable name.
997
998 @code{d1} is usually 0 but many other values have been observed.
999
1000 @code{d3} is 2 over 99% of the time.
1001
1002 @code{d5} is 0 over 99% of the time.
1003
1004 @code{d6} is either -1 or the 0-based index of the dimension, e.g.@: 0
1005 for the first dimension, 1 for the second, and so on.  The latter is
1006 the case 98% of the time in the corpus.
1007
1008 @node SPV Light Member Categories
1009 @subsection Categories
1010
1011 Categories are arranged in a tree.  Only the leaf nodes in the tree
1012 are really categories; the others just serve as grouping constructs.
1013
1014 @cartouche
1015 @format
1016 Category @result{} Value[@t{name}] (Leaf @math{|} Group)
1017 Leaf @result{} 00 00 00 i2 int[@t{index}] i0
1018 Group @result{}
1019     (00 @math{|} 01)[@t{merge}] 00 01 (i0 @math{|} i2)[@t{data}]
1020     i-1 int[@t{n-subcategories}] Category*[@t{n-subcategories}]
1021 @end format
1022 @end cartouche
1023
1024 @code{name} is the name of the category (or group).
1025
1026 A Leaf represents a leaf category.  The Leaf's @code{index} is a
1027 nonnegative integer less than @code{n-categories} in the Dimension in
1028 which the Category is nested (directly or indirectly).
1029
1030 A Group represents a Group of nested categories.  Usually a Group
1031 contains at least one Category, so that @code{n-subcategories} is
1032 positive, but a few Groups with @code{n-subcategories} 0 has been
1033 observed.
1034
1035 If a Group's @code{merge} is 00, the most common value, then the group
1036 is really a distinct group that should be represented as such in the
1037 visual representation and user interface.  If @code{merge} is 01, the
1038 categories in this group should be shown and treated as if they were
1039 direct children of the group's containing group (or if it has no
1040 parent group, then direct children of the dimension), and this group's
1041 name is irrelevant and should not be displayed.  (Merged groups can be
1042 nested!)
1043
1044 A Group's @code{data} appears to be i2 when all of the categories
1045 within a group are leaf categories that directly represent data values
1046 for a variable (e.g. in a frequency table or crosstabulation, a group
1047 of values in a variable being tabulated) and i0 otherwise.
1048
1049 @node SPV Light Member Data
1050 @subsection Data
1051
1052 The final part of an SPV light member contains the actual data.
1053
1054 @cartouche
1055 @format
1056 Data @result{}
1057     int[@t{layers}] int[@t{rows}] int[@t{columns}] int*[@t{n-dimensions}]
1058     int[@t{n-data}] Datum*[@t{n-data}]
1059 Datum @result{} int64[@t{index}] v3(00?) Value
1060 @end format
1061 @end cartouche
1062
1063 The values of @code{layers}, @code{rows}, and @code{columns} each
1064 specifies the number of dimensions displayed in layers, rows, and
1065 columns, respectively.  Any of them may be zero.  Their values sum to
1066 @code{n-dimensions} from Dimensions (@pxref{SPV Light Member
1067 Dimensions}).
1068
1069 The @code{n-dimensions} integers are a permutation of the 0-based
1070 dimension numbers.  The first @code{layers} integers specify each of
1071 the dimensions represented by layers, the next @code{rows} integers
1072 specify the dimensions represented by rows, and the final
1073 @code{columns} integers specify the dimensions represented by columns.
1074 When there is more than one dimension of a given kind, the inner
1075 dimensions are given first.
1076
1077 The format of a Datum varies slightly from version 1 to version 3: in
1078 version 1 it allows for an extra optional 00 byte.
1079
1080 A Datum consists of an @code{index} and a Value.  Suppose there are
1081 @math{d} dimensions and dimension @math{i}, @math{0 \le i < d}, has
1082 @math{n_i} categories.  Consider the datum at coordinates @math{x_i},
1083 @math{0 \le i < d}, and note that @math{0 \le x_i < n_i}.  Then the
1084 index is calculated by the following algorithm:
1085
1086 @display
1087 let @i{index} = 0
1088 for each @math{i} from 0 to @math{d - 1}:
1089     @i{index} = (@math{n_i \times} @i{index}) @math{+} @math{x_i}
1090 @end display
1091
1092 For example, suppose there are 3 dimensions with 3, 4, and 5
1093 categories, respectively.  The datum at coordinates (1, 2, 3) has
1094 index @math{5 \times (4 \times (3 \times 0 + 1) + 2) + 3 = 33}.
1095
1096 @node SPV Light Member Value
1097 @subsection Value
1098
1099 Value is used throughout the SPV light member format.  It boils down
1100 to a number or a string.
1101
1102 @cartouche
1103 @format
1104 Value @result{} 00? 00? 00? 00? RawValue
1105 RawValue @result{}
1106     01 ValueMod int[@t{format}] double[@t{x}]
1107   @math{|} 02 ValueMod int[@t{format}] double[@t{x}]
1108     string[@t{varname}] string[@t{vallab}] (01 @math{|} 02 @math{|} 03)
1109   @math{|} 03 string[@t{local}] ValueMod string[@t{id}] string[@t{c}] (00 @math{|} 01)[@t{type}]
1110   @math{|} 04 ValueMod int[@t{format}] string[@t{vallab}] string[@t{varname}]
1111     (01 @math{|} 02 @math{|} 03) string[@t{s}]
1112   @math{|} 05 ValueMod string[@t{varname}] string[@t{varlabel}] (01 @math{|} 02 @math{|} 03)
1113   @math{|} ValueMod string[@t{format}] int[@t{n-args}] Argument*[@t{n-args}]
1114 Argument @result{}
1115     i0 Value
1116   @math{|} int[@t{x}] i0 Value*[@t{x}@math{+}1]      /* @t{x} @math{>} 0 */
1117 @end format
1118 @end cartouche
1119
1120 There are several possible encodings, which one can distinguish by the
1121 first nonzero byte in the encoding.
1122
1123 @table @asis
1124 @item 01
1125 The numeric value @code{x}, intended to be presented to the user
1126 formatted according to @code{format}, which is in the format described
1127 for system files.  @xref{System File Output Formats}, for details.
1128 Most commonly, @code{format} has width 40 (the maximum).
1129
1130 An @code{x} with the maximum negative double value @code{-DBL_MAX}
1131 represents the system-missing value SYSMIS.  (HIGHEST and LOWEST have
1132 not been observed.)  @xref{System File Format}, for more about these
1133 special values.
1134
1135 @item 02
1136 Similar to @code{01}, with the additional information that @code{x} is
1137 a value of variable @code{varname} and has value label @code{vallab}.
1138 Both @code{varname} and @code{vallab} can be the empty string, the
1139 latter very commonly.
1140
1141 The meaning of the final byte is unknown.  Possibly it is connected to
1142 whether the value or the label should be displayed.
1143
1144 @item 03
1145 A text string, in two forms: @code{c} is in English, and sometimes
1146 abbreviated or obscure, and @code{local} is localized to the user's
1147 locale.  In an English-language locale, the two strings are often the
1148 same, and in the cases where they differ, @code{local} is more
1149 appropriate for a user interface, e.g.@: @code{c} of ``Not a PxP table
1150 for MCN...'' versus @code{local} of ``Computed only for a PxP table,
1151 where P must be greater than 1.''
1152
1153 @code{c} and @code{local} are always either both empty or both
1154 nonempty.
1155
1156 @code{id} is a brief identifying string whose form seems to resemble a
1157 programming language identifier, e.g.@: @code{cumulative_percent} or
1158 @code{factor_14}.  It is not unique.
1159
1160 @code{type} is 00 for text taken from user input, such as syntax
1161 fragment, expressions, file names, data set names, and 01 for fixed
1162 text strings such as names of procedures or statistics.  In the former
1163 case, @code{id} is always the empty string; in the latter case,
1164 @code{id} is still sometimes empty.
1165
1166 @item 04
1167 The string value @code{s}, intended to be presented to the user
1168 formatted according to @code{format}.  The format for a string is not
1169 too interesting, and the corpus contains many clearly invalid formats
1170 like A16.39 or A255.127 or A134.1, so readers should probably ignore
1171 the format entirely.
1172
1173 @code{s} is a value of variable @code{varname} and has value label
1174 @code{vallab}.  @code{varname} is never empty but @code{vallab} is
1175 commonly empty.
1176
1177 The meaning of the final byte is unknown.
1178
1179 @item 05
1180 Variable @code{varname}, which is rarely observed as empty in the
1181 corpus, with variable label @code{varlabel}, which is often empty.
1182
1183 The meaning of the final byte is unknown.
1184
1185 @item 31 or 58
1186 (These bytes begin a ValueMod.)  A format string, analogous to
1187 @code{printf}, followed by one or more Arguments, each of which has
1188 one or more values.  The format string uses the following syntax:
1189
1190 @table @code
1191 @item \%
1192 @itemx \:
1193 @itemx \[
1194 @itemx \]
1195 Each of these expands to the character following @samp{\\}, to escape
1196 characters that have special meaning in format strings.  These are
1197 effective inside and outside the @code{[@dots{}]}  syntax forms
1198 described below.
1199
1200 @item \n
1201 Expands to a new-line, inside or outside the @code{[@dots{}]} forms
1202 described below.
1203
1204 @item ^@var{i}
1205 Expands to a formatted version of argument @var{i}, which must have
1206 only a single value.  For example, @code{^1} expands to the first
1207 argument's @code{value}.
1208
1209 @item [:@var{a}:]@var{i}
1210 Expands @var{a} for each of the values in @var{i}.  @var{a}
1211 should contain one or more @code{^@var{j}} conversions, which are
1212 drawn from the values for argument @var{i} in order.  Some examples
1213 from the corpus:
1214
1215 @table @code
1216 @item [:^1:]1
1217 All of the values for the first argument, concatenated.
1218
1219 @item [:^1\n:]1
1220 Expands to the values for the first argument, each followed by
1221 a new-line.
1222
1223 @item [:^1 = ^2:]2
1224 Expands to @code{@var{x} = @var{y}} where @var{x} is the second
1225 argument's first value and @var{y} is its second value.  (This would
1226 be used only if the argument has two values.  If there were more
1227 values, the second and third values would be directly concatenated,
1228 which would look funny.)
1229 @end table
1230
1231 @item [@var{a}:@var{b}:]@var{i}
1232 This extends the previous form so that the first values are expanded
1233 using @var{a} and later values are expanded using @var{b}.  For an
1234 unknown reason, within @var{a} the @code{^@var{j}} conversions are
1235 instead written as @code{%@var{j}}.  Some examples from the corpus:
1236
1237 @table @code
1238 @item [%1:*^1:]1
1239 Expands to all of the values for the first argument, separated by
1240 @samp{*}.
1241
1242 @item [%1 = %2:, ^1 = ^2:]1
1243 Given appropriate values for the first argument, expands to @code{X =
1244 1, Y = 2, Z = 3}.
1245
1246 @item [%1:, ^1:]1
1247 Given appropriate values, expands to @code{1, 2, 3}.
1248 @end table
1249 @end table
1250
1251 The format string is localized to the user's locale.
1252 @end table
1253
1254 @node SPV Light Member ValueMod
1255 @subsection ValueMod
1256
1257 A ValueMod can specify special modifications to a Value.
1258
1259 @cartouche
1260 @format
1261 ValueMod @result{}
1262     31 i0 (i0 @math{|} i1 string[@t{subscript}])
1263     v1(00 (i1 @math{|} i2) 00 00 int 00 00)
1264     v3(count(FormatString
1265              (31 Style | 58)
1266              (31 Style2 | 58)))
1267   @math{|} 31 int[@t{n-refs}] int16*[@t{n-refs}] Format
1268   @math{|} 58
1269
1270 Format @result{} 00 00 count(FormatString Style 58)
1271 FormatString @result{} count((count((i0 58)?) (58 @math{|} 31 string))?)
1272
1273 Style @result{}
1274     bool[@t{bold}] bool[@t{italic}] bool[@t{underline}] bool[@t{show}]
1275     string[@t{fgcolor}] string[@t{bgcolor}]
1276     string[@t{typeface}] byte[@t{size}]
1277
1278 Style2 @result{}
1279     int[@t{halign}] int[@t{valign}] double[@t{offset}]
1280     int16[@t{left-margin}] int16[@t{right-margin}]
1281     int16[@t{top-margin}] int16[@t{bottom-margin}]
1282 @end format
1283 @end cartouche
1284
1285 A ValueMod that begins with ``31 i0'' specifies a string to append to
1286 the main text of the Value, as a subscript.  The subscript text is a
1287 brief indicator, e.g.@: @samp{a} or @samp{a,b}, with its meaning
1288 indicated by the table caption.  In this usage, subscripts are similar
1289 to footnotes.  One apparent difference is that a Value can only
1290 reference one footnote but a subscript can list more than one letter.
1291
1292 A ValueMod that begins with 31 followed by a nonzero ``int'' specifies
1293 a footnote or footnotes that the Value references.  Footnote markers
1294 are shown appended to the main text of the Value, as superscripts.
1295
1296 The Format, if present, is a format string for substitutions using the
1297 syntax explained previously.  It appears to be an English-language
1298 version of the localized format string in the Value in which the
1299 Format is nested.
1300
1301 Style and Style2, if present, change the style for this individual
1302 Value.  @code{bold}, @code{italic}, and @code{underline} control the
1303 particular style.  @code{fgcolor} and @code{bgcolor} are strings, such
1304 as @code{#ffffff}.  The @code{size} is a font size in units of 1/96
1305 inch.
1306
1307 @code{halign} is 0 for center, 2 for left, 4 for right, 6 for decimal,
1308 0xffffffad for mixed.  For decimal alignment, @code{offset} is the
1309 decimal point's offset from the right side of the cell, in units of
1310 1/72 inch.
1311
1312 @code{valign} specifies vertical alignment: 0 for center, 1 for top, 3
1313 for bottom.
1314
1315 @code{left-margin}, @code{right-margin}, @code{top-margin}, and
1316 @code{bottom-margin} are in units of 1/72 inch.
1317
1318 @node SPV Legacy Detail Member Binary Format
1319 @section Legacy Detail Member Binary Format
1320
1321 Whereas the light binary format represents everything about a given
1322 pivot table, the legacy binary format conceptually consists of a
1323 number of named sources, each of which consists of a number of named
1324 variables, each of which is a 1-dimensional array of numbers or
1325 strings or a mix.  Thus, the legacy binary member format is quite
1326 simple.
1327
1328 This section uses the same context-free grammar notation as in the
1329 previous section, with the following additions:
1330
1331 @table @asis
1332 @item vAF(@var{x})
1333 In a version 0xaf legacy member, @var{x}; in other versions, nothing.
1334 (The legacy member header indicates the version; see below.)
1335
1336 @item vB0(@var{x})
1337 In a version 0xb0 legacy member, @var{x}; in other versions, nothing.
1338 @end table
1339
1340 A legacy detail member @file{.bin} has the following overall format:
1341
1342 @cartouche
1343 @format
1344 LegacyBinary @result{}
1345     00 byte[@t{version}] int16[@t{n-sources}] int[@t{member-size}]
1346     Metadata*[@t{n-sources}] Data*[@t{n-sources}]
1347 @end format
1348 @end cartouche
1349
1350 @code{version} is a version number that affects the interpretation of
1351 some of the other data in the member.  Versions 0xaf and 0xb0 are
1352 known.  We will refer to ``version 0xaf'' and ``version 0xb0'' members
1353 later on.
1354
1355 A legacy member consists of @code{n-sources} data sources, each of
1356 which has Metadata and Data.
1357
1358 @code{member-size} is the size of the legacy binary member, in bytes.
1359
1360 The following sections go into more detail.
1361
1362 @menu
1363 * SPV Legacy Member Metadata::
1364 * SPV Legacy Member Data::
1365 @end menu
1366
1367 @node SPV Legacy Member Metadata
1368 @subsection Metadata
1369
1370 @cartouche
1371 @format
1372 Metadata @result{}
1373     int[@t{n-data}] int[@t{n-variables}] int[@t{offset}]
1374     vAF(byte*32[@t{source-name}])
1375     vB0(byte*64[@t{source-name}] int[@t{x}])
1376 @end format
1377 @end cartouche
1378
1379 A data source has @code{n-variables} variables, each with
1380 @code{n-data} data values.
1381
1382 @code{source-name} is a 32- or 64-byte string padded on the right with
1383 zero bytes.  The names that appear in the corpus are very generic:
1384 usually @code{tableData} for pivot table data or @code{source0} for
1385 chart data.
1386
1387 A given Metadata's @code{offset} is the offset, in bytes, from the
1388 beginning of the member to the start of the corresponding Data.  This
1389 allows programs to skip to the beginning of the data for a particular
1390 source; it is also important to determine whether a source includes
1391 any string data (@pxref{SPV Legacy Member Data}).
1392
1393 The meaning of @code{x} in version 0xb0 is unknown.
1394
1395 @node SPV Legacy Member Data
1396 @subsection Data
1397
1398 @cartouche
1399 @format
1400 Data @result{} NumericData*[@t{n-variables}] StringData?
1401 NumericData @result{} byte*288[@t{variable-name}] double*[@t{n-data}]
1402 @end format
1403 @end cartouche
1404
1405 Data follow the Metadata in the legacy binary format, with sources in
1406 the same order.  Each NumericSeries begins with a @code{variable-name}
1407 that generally indicates its role in the pivot table, e.g.@: ``cell'',
1408 ``cellFormat'', ``dimension0categories'', ``dimension0group0'',
1409 followed by the numeric data, one double per datum.  A double with the
1410 maximum negative double @code{-DBL_MAX} represents the system-missing
1411 value SYSMIS.
1412
1413 @cartouche
1414 @format
1415 StringData @result{} i1 string[@t{source-name}] Pairs Labels
1416
1417 Pairs @result{} int[@t{n-string-vars}] PairSeries*[@t{n-string-vars}]
1418 PairVar @result{} string[@t{pair-var-name}] int[@t{n-pairs}] Pair*[@t{n-pairs}]
1419 Pair @result{} int[@t{i}] int[@t{j}]
1420
1421 Labels @result{} int[@t{n-labels}] Label*[@t{n-labels}]
1422 Label @result{} int[@t{frequency}] int[@t{s}]
1423 @end format
1424 @end cartouche
1425
1426 A source may include a mix of numeric and string data values.  When a
1427 source includes any string data, the data values that are strings are
1428 set to SYSMIS in the NumericData, and StringData follows the
1429 NumericData.  A source that contains no string data omits the
1430 StringData.  To reliably determine whether a source includes
1431 StringData, the reader should check whether the offset following the
1432 NumericData is the offset of the next source, as indicated by its
1433 Metadata (or the end of the member, in the case of the last source).
1434
1435 StringData repeats the name of the source (from Metadata).
1436
1437 The string data overlays the numeric data.  @code{n-string-vars} is
1438 the number of variables in the source that include string data.  More
1439 precisely, it is the 1-based index of the last variable in the source
1440 that includes any string data; thus, it would be 4 if there are 5
1441 variables and only the fourth one includes string data.
1442
1443 Each PairVar consists a sequence of 0 or more Pair nonterminals, each
1444 of which maps from a 0-based index within variable @code{i} to a
1445 0-based label index @code{j}, e.g.@: pair @code{i} = 2, @code{j} = 3,
1446 means that the third data value (with value SYSMIS) is to be replaced
1447 by the string of the fourth Label.
1448
1449 The labels themselves follow the pairs.  The valuable part of each
1450 label is the string @code{s}.  Each label also includes a
1451 @code{frequency} that reports the number of pairs that reference it
1452 (although this is not useful).
1453
1454 @node SPV Legacy Detail Member XML Format
1455 @section Legacy Detail Member XML Format
1456
1457 This format is still under investigation.
1458
1459 The design of the detail XML format is not what one would end up with
1460 for describing pivot tables.  This is because it is a special case
1461 of a much more general format (``visualization XML'' or ``VizML'')
1462 that can describe a wide range of visualizations.  Most of this
1463 generality is overkill for tables, and so we end up with a funny
1464 subset of a general-purpose format.
1465
1466 The important elements of the detail XML format are:
1467
1468 @itemize @bullet
1469 @item
1470 Variables.  Variables in detail XML roughly correspond to the
1471 dimensions in a light detail member.  There is one variable for each
1472 dimension, plus one variable for each level of labeling along an axis.
1473
1474 The bulk of variables are defined with @code{sourceVariable} elements.
1475 The data for these variables comes from the associated
1476 @code{tableData.bin} member.  Some variables are defined, with
1477 @code{derivedVariable} elements, as a constant or in terms of a
1478 mapping function from a source variable.
1479
1480 @item
1481 Assignment of variables to axes.  A variable can appear as columns, or
1482 rows, or layers.  The @code{faceting} element and its sub-elements
1483 describe this assignment.
1484 @end itemize
1485
1486 All elements have an optional @code{id} attribute.  In practice many
1487 elements are assigned @code{id} attributes that are never referenced.
1488
1489 @menu
1490 * SPV Detail visualization Element::
1491 * SPV Detail userSource Element::
1492 * SPV Detail sourceVariable Element::
1493 * SPV Detail derivedVariable Element::
1494 * SPV Detail extension Element::
1495 * SPV Detail graph Element::
1496 * SPV Detail location Element::
1497 * SPV Detail coordinates Element::
1498 * SPV Detail faceting Element::
1499 * SPV Detail facetLayout Element::
1500 @end menu
1501
1502 @node SPV Detail visualization Element
1503 @subsection The @code{visualization} Element
1504
1505 @format
1506 Parent: Document root
1507 Contents:
1508      extension?
1509      userSource
1510      (sourceVariable @math{|} derivedVariable)@math{+}
1511      graph
1512      labelFrame@math{+}
1513      container?
1514      style@math{+}
1515      layerController?
1516 @end format
1517
1518 This element has the following attributes.
1519
1520 @defvr {Required} creator
1521 The version of the software that created this SPV file, as a string of
1522 the form @code{xxyyzz}, which represents software version xx.yy.zz,
1523 e.g.@: @code{160001} is version 16.0.1.  The corpus includes major
1524 versions 16 through 19.
1525 @end defvr
1526
1527 @defvr {Required} date
1528 The date on the which the file was created, as a string of the form
1529 @code{YYYY-MM-DD}.
1530 @end defvr
1531
1532 @defvr {Required} lang
1533 The locale used for output, in Windows format, which is similar to the
1534 format used in Unix with the underscore replaced by a hyphen, e.g.@:
1535 @code{en-US}, @code{en-GB}, @code{el-GR}, @code{sr-Cryl-RS}.
1536 @end defvr
1537
1538 @defvr {Required} name
1539 The title of the pivot table, localized to the output language.
1540 @end defvr
1541
1542 @defvr {Required} style
1543 The @code{id} of a @code{style} element (@pxref{SPV Detail style
1544 element}).  This is the base style for the entire pivot table.  In
1545 every example in the corpus, the value is @code{visualizationStyle}
1546 and the corresponding @code{style} element has no attributes other
1547 than @code{id}.
1548 @end defvr
1549
1550 @defvr {Required} type
1551 A floating-point number.  The meaning is unknown.
1552 @end defvr
1553
1554 @defvr {Required} version
1555 The visualization schema version number.  In the corpus, the value is
1556 one of 2.4, 2.5, 2.7, and 2.8.
1557 @end defvr
1558
1559 @node SPV Detail userSource Element
1560 @subsection The @code{userSource} Element
1561
1562 Parent: @code{visualization} @*
1563 Contents:
1564
1565 This element has the following attributes.
1566
1567 @defvr {Optional} missing
1568 Always @code{listwise}.
1569 @end defvr
1570
1571 @node SPV Detail sourceVariable Element
1572 @subsection The @code{sourceVariable} Element
1573
1574 Parent: @code{visualization} @*
1575 Contents: @code{extension}* (@code{format} @math{|} @code{stringFormat})?
1576
1577 This element defines a variable whose values can be used elsewhere in
1578 the visualization.  It ties this element's @code{id} to a variable
1579 from the @file{tableData.bin} member that corresponds to this
1580 @file{.xml}.
1581
1582 This element has the following attributes.
1583
1584 @defvr {Required} categorical
1585 Always set to @code{true}.
1586 @end defvr
1587
1588 @defvr {Required} source
1589 Always set to @code{tableData}, the @code{source-name} in the
1590 corresponding @file{tableData.bin} member (@pxref{SPV Legacy Member
1591 Metadata}).
1592 @end defvr
1593
1594 @defvr {Required} sourceName
1595 The name of a variable within the source, the @code{variable-name} in
1596 the corresponding @file{tableData.bin} member (@pxref{SPV Legacy
1597 Member Data}).
1598 @end defvr
1599
1600 @defvr {Optional} dependsOn
1601 The @code{variable-name} of a variable linked to this one, so that a
1602 viewer can work with them together.  For a group variable, this is the
1603 name of the corresponding categorical variable.
1604 @end defvr
1605
1606 @defvr {Optional} label
1607 The variable label, if any
1608 @end defvr
1609
1610 @defvr {Optional} labelVariable
1611 The @code{variable-name} of a variable whose string values correspond
1612 one-to-one with the values of this variable and are suitable for use
1613 as value labels.
1614 @end defvr
1615
1616 @node SPV Detail derivedVariable Element
1617 @subsection The @code{derivedVariable} Element
1618
1619 Parent: @code{visualization} @*
1620 Contents: @code{extension}* (@code{format} @math{|} @code{stringFormat} @code{valueMapEntry}*)
1621
1622 Like @code{sourceVariable}, this element defines a variable whose
1623 values can be used elsewhere in the visualization.  Instead of being
1624 read from a data source, the variable's data are defined by a
1625 mathematical expression.
1626
1627 This element has the following attributes.
1628
1629 @defvr {Required} categorical
1630 Always set to @code{true}.
1631 @end defvr
1632
1633 @defvr {Required} value
1634 An expression that defines the variable's value.  In theory this could
1635 be an arbitrary expression in terms of constants, functions, and other
1636 variables, e.g.@: @math{(@var{var1} + @var{var2}) / 2}.  In practice,
1637 the corpus contains only the following forms of expressions:
1638
1639 @table @code
1640 @item constant(@var{number})
1641 @itemx constant(@var{variable})
1642 A constant.  The meaning when a variable is named is unknown.
1643 Sometimes the ``variable name'' has spaces in it.
1644
1645 @item map(@var{variable})
1646 Transforms the values in the named @var{variable} using the
1647 @code{valueMapEntry}s contained within the element.
1648 @end table
1649 @end defvr
1650
1651 @defvr {Optional} dependsOn
1652 The @code{variable-name} of a variable linked to this one, so that a
1653 viewer can work with them together.  For a group variable, this is the
1654 name of the corresponding categorical variable.
1655 @end defvr
1656
1657 @menu
1658 * SPV Detail valueMapEntry Element::
1659 @end menu
1660
1661 @node SPV Detail valueMapEntry Element
1662 @subsubsection The @code{valueMapEntry} Element
1663
1664 Parent: @code{derivedVariable} @*
1665 Contents: empty
1666
1667 A @code{valueMapEntry} element defines a mapping from one or more
1668 values of a source expression to a target value.  (In the corpus, the
1669 source expression is always just the name of a variable.)  Each target
1670 value requires a separate @code{valueMapEntry}.  If multiple source
1671 values map to the same target value, they can be combined or separate.
1672
1673 @code{valueMapEntry} has the following attributes.
1674
1675 @defvr {Required} from
1676 A source value, or multiple source values separated by semicolons,
1677 e.g.@: @code{0} or @code{13;14;15;16}.
1678 @end defvr
1679
1680 @defvr {Required} to
1681 The target value.
1682 @end defvr
1683
1684 @node SPV Detail extension Element
1685 @subsection The @code{extension} Element
1686
1687 This is a general-purpose ``extension'' element.  Readers that don't
1688 understand a given extension should be able to safely ignore it.  The
1689 attributes on this element, and their meanings, vary based on the
1690 context.  Each known usage is described separately below.  The current
1691 extensions use attributes exclusively, without any nested elements.
1692
1693 @subsubheading @code{visualization} Parent Element
1694
1695 With @code{visualization} as its parent element, @code{extension} has
1696 the following attributes.
1697
1698 @defvr {Optional} numRows
1699 An integer that presumably defines the number of rows in the displayed
1700 pivot table.
1701 @end defvr
1702
1703 @defvr {Optional} showGridline
1704 Always set to @code{false} in the corpus.
1705 @end defvr
1706
1707 @defvr {Optional} minWidthSet
1708 @defvrx {Optional} maxWidthSet
1709 Always set to @code{true} in the corpus.
1710 @end defvr
1711
1712 @subsubheading @code{container} Parent Element
1713
1714 With @code{container} as its parent element, @code{extension} has the
1715 following attributes.
1716
1717 @defvr {Required} combinedFootnotes
1718 Always set to @code{true} in the corpus.
1719 @end defvr
1720
1721 @subsubheading @code{sourceVariable} and @code{derivedVariable} Parent Element
1722
1723 With @code{sourceVariable} or @code{derivedVariable} as its parent
1724 element, @code{extension} has the following attributes.  A given
1725 parent element often contains several @code{extension} elements that
1726 specify the meaning of the source data's variables or sources, e.g.@:
1727
1728 @example
1729 <extension from="0" helpId="corrected_model"/>
1730 <extension from="3" helpId="error"/>
1731 <extension from="4" helpId="total_9"/>
1732 <extension from="5" helpId="corrected_total"/>
1733 @end example
1734
1735 @defvr {Required} from
1736 An integer or a name like ``dimension0''.
1737 @end defvr
1738
1739 @defvr {Required} helpId
1740 An identifier.
1741 @end defvr
1742
1743 @node SPV Detail graph Element
1744 @subsection The @code{graph} Element
1745
1746 Parent: @code{visualization} @*
1747 Contents: @code{location}@math{+} @code{coordinates} @code{faceting} @code{facetLayout} @code{interval}
1748
1749 @code{graph} has the following attributes.
1750
1751 @defvr {Required} cellStyle
1752 @defvrx {Required} style
1753 Each of these is the @code{id} of a @code{style} element (@pxref{SPV
1754 Detail style element}).  The former is the default style for
1755 individual cells, the latter for the entire table.
1756 @end defvr
1757
1758 @node SPV Detail location Element
1759 @subsection The @code{location} Element
1760
1761 Parent: @code{graph} @*
1762 Contents: empty
1763
1764 Each instance of this element specifies where some part of the table
1765 frame is located.  All the examples in the corpus have four instances
1766 of this element, one for each of the parts @code{height},
1767 @code{width}, @code{left}, and @code{top}.  Some examples in the
1768 corpus add a fifth for part @code{bottom}, even though it is not clear
1769 how all of @code{top}, @code{bottom}, and @code{heigth} can be honored
1770 at the same time.  In any case, @code{location} seems to have little
1771 importance in representing tables; a reader can safely ignore it.
1772
1773 @defvr {Required} part
1774 One of @code{height}, @code{width}, @code{top}, @code{bottom}, or
1775 @code{left}.  Presumably @code{right} is acceptable as well but the
1776 corpus contains no examples.
1777 @end defvr
1778
1779 @defvr {Required} method
1780 How the location is determined:
1781
1782 @table @code
1783 @item sizeToContent
1784 Based on the natural size of the table.  Observed only for
1785 parts @code{height} and @code{width}.
1786
1787 @item attach
1788 Based on the location specified in @code{target}.  Observed only for
1789 parts @code{top} and @code{bottom}.
1790
1791 @item fixed
1792 Using the value in @code{value}.  Observed only for parts @code{top},
1793 @code{bottom}, and @code{left}.
1794
1795 @item same
1796 Same as the specified @code{target}.  Observed only for part
1797 @code{left}.
1798 @end table
1799 @end defvr
1800
1801 @defvr {Optional} min
1802 Minimum size.  Only observed with value @code{100pt}.  Only observed
1803 for part @code{width}.
1804 @end defvr
1805
1806 @defvr {Dependent} target
1807 Required when @code{method} is @code{attach} or @code{same}, not
1808 observed otherwise.  This is the ID of an element to attach to.
1809 Observed with the ID of @code{title}, @code{footnote}, @code{graph},
1810 and other elements.
1811 @end defvr
1812
1813 @defvr {Dependent} value
1814 Required when @code{method} is @code{fixed}, not observed otherwise.
1815 Observed values are @code{0%}, @code{0px}, @code{1px}, and @code{3px}
1816 on parts @code{top} and @code{left}, and @code{100%} on part
1817 @code{bottom}.
1818 @end defvr
1819
1820 @node SPV Detail coordinates Element
1821 @subsection The @code{coordinates} Element
1822
1823 Parent: @code{graph} @*
1824 Contents: empty
1825
1826 This element is always present and always empty, with no attributes
1827 (except @code{id}).
1828
1829 @node SPV Detail faceting Element
1830 @subsection The @code{faceting} Element
1831
1832 Parent: @code{graph} @*
1833 Contents: @code{cross} @code{layer}*
1834
1835 The @code{faceting} element describes the row, column, and layer
1836 structure of the table.  Its @code{cross} child determines the row and
1837 column structure, and each @code{layer} child (if any) represents a
1838 layer.
1839
1840 @code{faceting} has no attributes (other than @code{id}).
1841
1842 @subsubheading The @code{cross} Element
1843
1844 Parent: @code{faceting} @*
1845 Contents: @code{nest} @code{nest}
1846
1847 The @code{cross} element describes the row and column structure of the
1848 table.  It has exactly two @code{nest} children, the first of which
1849 describes the table's rows and the second the table's columns.
1850
1851 @code{cross} has no attributes (other than @code{id}).
1852
1853 @subsubheading The @code{nest} Element
1854
1855 Parent: @code{cross} @*
1856 Contents: @code{variableReference}@math{+}
1857
1858 A given @code{nest} usually consists of one or more dimensions, each
1859 of which is represented by @code{variableReference} child elements.
1860 Minimally, a dimension has two @code{variableReference} children, one
1861 for the categories, one for the data, e.g.:
1862
1863 @example
1864 <nest>
1865   <variableReference ref="dimension0categories"/>
1866   <variableReference ref="dimension0"/>
1867 </nest>
1868 @end example
1869
1870 @noindent
1871 Groups of categories introduce additional variable references, e.g.@:
1872
1873 @example
1874 <nest>
1875   <variableReference ref="dimension0categories"/>
1876   <variableReference ref="dimension0group0"/>
1877   <variableReference ref="dimension0"/>
1878 </nest>
1879 @end example
1880
1881 @noindent
1882 Grouping can be hierarchical, e.g.@:
1883
1884 @example
1885 <nest>
1886   <variableReference ref="dimension0categories"/>
1887   <variableReference ref="dimension0group1"/>
1888   <variableReference ref="dimension0group0"/>
1889   <variableReference ref="dimension0"/>
1890 </nest>
1891 @end example
1892
1893 @noindent
1894 XXX what are group maps?
1895
1896 @example
1897 <nest id="nest_1973">
1898   <variableReference ref="dimension1categories"/>
1899   <variableReference ref="dimension1group1map"/>
1900   <variableReference ref="dimension1group0map"/>
1901   <variableReference ref="dimension1"/>
1902 </nest>
1903 <nest>
1904   <variableReference ref="dimension0categories"/>
1905   <variableReference ref="dimension0group0map"/>
1906   <variableReference ref="dimension0"/>
1907 </nest>
1908 @end example
1909
1910 @noindent
1911 A @code{nest} can contain multiple dimensions:
1912
1913 @example
1914 <nest>
1915   <variableReference ref="dimension1categories"/>
1916   <variableReference ref="dimension1group0"/>
1917   <variableReference ref="dimension1"/>
1918   <variableReference ref="dimension0categories"/>
1919   <variableReference ref="dimension0"/>
1920 </nest>
1921 @end example
1922
1923 One @code{nest} within a given @code{cross} may have no dimensions, in
1924 which case it still has one @code{variableReference} child, which
1925 references a @code{derivedVariable} whose @code{value} attribute is
1926 @code{constant(0)}.  In the corpus, such a @code{derivedVariable} has
1927 @code{row} or @code{column}, respectively, as its @code{id}.
1928
1929 @code{nest} has no attributes (other than @code{id}).
1930
1931 @subsubheading The @code{variableReference} Element
1932
1933 Parent: @code{nest} @*
1934 Contents: empty
1935
1936 @code{variableReference} has one attribute.
1937
1938 @defvr {Required} ref
1939 The @code{id} of a @code{sourceVariable} or @code{derivedVariable}
1940 element.
1941 @end defvr
1942
1943 @subsubheading The @code{layer} Element
1944
1945 Parent: @code{faceting} @*
1946 Contents: empty
1947
1948 Each layer is represented by a pair of @code{layer} elements.  The
1949 first of this pair is for a category variable, the second for the data
1950 variable, e.g.:
1951
1952 @example
1953 <layer value="0" variable="dimension0categories" visible="true"/>
1954 <layer value="dimension0" variable="dimension0" visible="false"/>
1955 @end example
1956
1957 @noindent
1958 @code{layer} has the following attributes.
1959
1960 @defvr {Required} variable
1961 The @code{id} of a @code{sourceVariable} or @code{derivedVariable}
1962 element.
1963 @end defvr
1964
1965 @defvr {Required} value
1966 The value to select.  For a category variable, this is always
1967 @code{0}; for a data variable, it is the same as the @code{variable}
1968 attribute.
1969 @end defvr
1970
1971 @defvr {Optional} visible
1972 Whether the layer is visible.  Generally, category layers are visible
1973 and data layers are not, but sometimes this attribute is omitted.
1974 @end defvr
1975
1976 @defvr {Optional} method
1977 When present, this is always @code{nest}.
1978 @end defvr
1979
1980 @node SPV Detail facetLayout Element
1981 @subsection The @code{facetLayout} Element
1982
1983 Parent: @code{graph} @*
1984 Contents: @code{tableLayout} @code{facetLevel}@math{+} @code{setCellProperties}*
1985
1986 @subsubheading The @code{tableLayout} Element
1987
1988 Parent: @code{facetLayout} @*
1989 Contents: empty
1990
1991 @defvr {Required} verticalTitlesInCorner
1992 Always set to @code{true}.
1993 @end defvr
1994
1995 @defvr {Optional} style
1996 The @code{id} of a @code{style} element.
1997 @end defvr
1998
1999 @defvr {Optional} fitCells
2000 Always set to @code{ticks}.
2001 @end defvr
2002
2003 @subsubheading The @code{facetLevel} Element
2004
2005 Parent: @code{facetLayout} @*
2006 Contents: @code{axis}
2007
2008 Each @code{facetLevel} describes a @code{variableReference} or
2009 @code{layer}, and a table has one @code{facetLevel} element for
2010 each such element.  For example, an SPV detail member that contains
2011 four @code{variableReference} elements and two @code{layer} elements
2012 will contain six @code{facetLevel} elements.
2013
2014 In the corpus, @code{facetLevel} elements and the elements that they
2015 describe are always in the same order.  The correspondence may also be
2016 observed in two other ways.  First, one may use the @code{level}
2017 attribute, described below.  Second, in the corpus, a
2018 @code{facetLevel} always has an @code{id} that is the same as the
2019 @code{id} of the element it describes with @code{_facetLevel}
2020 appended.  One should not formally rely on this, of course, but it is
2021 usefully indicative.
2022
2023 @defvr {Required} level
2024 A 1-based index into the @code{variableReference} and @code{layer}
2025 elements, e.g.@: a @code{facetLayout} with a @code{level} of 1
2026 describes the first @code{variableReference} in the SPV detail member,
2027 and in a member with four @code{variableReference} elements, a
2028 @code{facetLayout} with a @code{level} of 5 describes the first
2029 @code{layer} in the member.
2030 @end defvr
2031
2032 @defvr {Required} gap
2033 Always observed as @code{0pt}.
2034 @end defvr
2035
2036 @subsubheading The @code{axis} Element
2037
2038 Parent: @code{facetLevel} @*
2039 Contents: @code{label}? @code{majorTicks}
2040
2041 @defvr {Attribute} style
2042 The @code{id} of a @code{style} element.
2043 @end defvr
2044
2045 @subsubheading The @code{label} Element
2046
2047 Parent: @code{axis} or @code{labelFrame} @*
2048 Contents: @code{text}@math{+} @math{|} @code{descriptionGroup}
2049
2050 This element represents a label on some aspect of the table.  For example,
2051 the table's title is a @code{label}.
2052
2053 The contents of the label can be one or more @code{text} elements or a
2054 @code{descriptionGroup}.
2055
2056 @defvr {Attribute} style
2057 @defvrx {Optional} textFrameStyle
2058 Each of these is the @code{id} of a @code{style} element.
2059 @code{style} is the style of the label text, @code{textFrameStyle} the
2060 style for the frame around the label.
2061 @end defvr
2062
2063 @defvr {Optional} purpose
2064 The kind of entity being labeled, one of @code{title},
2065 @code{subTitle}, @code{layer}, or @code{footnote}.
2066 @end defvr
2067
2068 @subsubheading The @code{descriptionGroup} Element
2069
2070 Parent: @code{label} @*
2071 Contents: (@code{description} @math{|} @code{text})@math{+}
2072
2073 A @code{descriptionGroup} concatenates one or more elements to form a
2074 label.  Each element can be a @code{text} element, which contains
2075 literal text, or a @code{description} element that substitutes a value
2076 or a variable name.
2077
2078 @defvr {Attribute} target
2079 The @code{id} of an element being described.  In the corpus, this is
2080 always @code{faceting}.
2081 @end defvr
2082
2083 @defvr {Attribute} separator
2084 A string to separate the description of multiple groups, if the
2085 @code{target} has more than one.  In the corpus, this is always a
2086 new-line.
2087 @end defvr
2088
2089 Typical contents for a @code{descriptionGroup} are a value by itself:
2090 @example
2091 <description name="value"/>
2092 @end example
2093 @noindent or a variable and its value, separated by a colon:
2094 @example
2095 <description name="variable"/><text>:</text><description name="value"/>
2096 @end example
2097
2098 @subsubheading The @code{description} Element
2099
2100 Parent: @code{descriptionGroup} @*
2101 Contents: empty
2102
2103 A @code{description} is like a macro that expands to some property of
2104 the target of its parent @code{descriptionGroup}.
2105
2106 @defvr {Attribute} name
2107 The name of the property.  Only @code{variable} and @code{value}
2108 appear in the corpus.
2109 @end defvr
2110
2111 @subsubheading The @code{majorTicks} Element
2112
2113 Parent: @code{axis} @*
2114 Contents: @code{gridline}?
2115
2116 @defvr {Attribute} labelAngle
2117 @defvrx {Attribute} length
2118 Both always defined to @code{0}.
2119 @end defvr
2120
2121 @defvr {Attribute} style
2122 @defvrx {Attribute} tickFrameStyle
2123 Each of these is the @code{id} of a @code{style} element.
2124 @code{style} is the style of the tick labels, @code{tickFrameStyle}
2125 the style for the frames around the labels.
2126 @end defvr
2127
2128 @subsubheading The @code{gridline} Element
2129
2130 Parent: @code{majorTicks} @*
2131 Contents: empty
2132
2133 Represents ``gridlines,'' which for a table represents the lines
2134 between the rows or columns of a table (XXX?).
2135
2136 @defvr {Attribute} style
2137 The style for the gridline.
2138 @end defvr
2139
2140 @defvr {Attribute} zOrder
2141 Observed as a number between 28 and 31.  Does not seem to be
2142 important.
2143 @end defvr
2144
2145 @subsubheading The @code{setCellProperties} Element
2146
2147 Parent: @code{facetLayout} @*
2148 Contents: @code{setMetaData} @code{setStyle}* @code{setFormat}@math{+} @code{union}?
2149
2150 This element sets style properties of cells designated by the
2151 @code{target} attribute of its child elements, as further restricted
2152 by the optional @code{union} element if present.  The @code{target}
2153 values often used, e.g.@: @code{graph} or @code{labeling}, actually
2154 affect every cell, so the @code{union} element is a useful
2155 restriction.
2156
2157 @defvr {Optional} applyToConverse
2158 If present, always @code{true}.  This appears to invert the meaning of
2159 the @code{target} of sub-elements: the selected cells are the ones
2160 @emph{not} designated by @code{target}.  This is confusing, given the
2161 additional restrictions of @code{union}, but in the corpus
2162 @code{applyToConverse} is never present along with @code{union}.
2163 @end defvr
2164
2165 @subsubheading The @code{setMetaData} Element
2166
2167 Parent: @code{setCellProperties} @*
2168 Contents: empty
2169
2170 This element is not known to have any visible effect.
2171
2172 @defvr {Required} target
2173 The @code{id} of an element whose metadata is to be set.  In the
2174 corpus, this is always @code{graph}, the @code{id} used for the
2175 @code{graph} element.
2176 @end defvr
2177
2178 @defvr {Required} key
2179 @defvrx {Required} value
2180 A key-value pair to set for the target.
2181
2182 In the corpus, @code{key} is @code{cellPropId} or, rarely,
2183 @code{diagProps}, and @code{value} is always the @code{id} of the
2184 parent @code{setCellProperties}.
2185 @end defvr
2186
2187 @subsubheading The @code{setStyle} Element
2188
2189 Parent: @code{setCellProperties} @*
2190 Contents: empty
2191
2192 This element associates a style with the target.
2193
2194 @defvr {Required} target
2195 The @code{id} of an element whose style is to be set.  In the corpus,
2196 this is always the @code{id} of an @code{interval}, @code{labeling},
2197 or, rarely, @code{graph} element.
2198 @end defvr
2199
2200 @defvr {Required} style
2201 The @code{id} of a @code{style} element that identifies the style to
2202 set on the target.
2203 @end defvr
2204
2205 @subsubheading The @code{setFormat} Element
2206
2207 @format
2208 Parent: @code{setCellProperties}
2209 Contents:
2210     @code{format}
2211   @math{|} @code{numberFormat}
2212   @math{|} @code{stringFormat}@math{+}
2213   @math{|} @code{dateTimeFormat}
2214 @end format
2215
2216 This element sets the format of the target, ``format'' in this case
2217 meaning the SPSS print format for a variable.
2218
2219 The details of this element vary depending on the schema version, as
2220 declared in the root @code{visualization} element's @code{version}
2221 attribute (@pxref{SPV Detail visualization Element}).  In version 2.5
2222 and earlier, @code{setFormat} contains one of a number of child
2223 elements that correspond to the different varieties of print formats.
2224 In version 2.7 and later, @code{setFormat} instead always contains a
2225 @code{format} element.
2226
2227 XXX reinvestigate the above claim about versions: it appears to be
2228 incorrect.
2229
2230 The @code{setFormat} element itself has the following attributes.
2231
2232 @defvr {Required} target
2233 The @code{id} of an element whose style is to be set.  In the corpus,
2234 this is always the @code{id} of an @code{majorTicks} or
2235 @code{labeling} element.
2236 @end defvr
2237
2238 @defvr {Optional} reset
2239 If this is @code{true}, this format overrides the target's previous
2240 format.  If it is @code{false}, the adds to the previous format.  In
2241 the corpus this is always @code{true}.  The default behavior is
2242 unknown.
2243 @end defvr
2244
2245 @menu
2246 * SPV Detail format Element::
2247 * SPV Detail numberFormat Element::
2248 * SPV Detail stringFormat Element::
2249 * SPV Detail dateTimeFormat Element::
2250 * SPV Detail affix Element::
2251 * SPV Detail relabel Element::
2252 * SPV Detail union Element::
2253 @end menu
2254
2255 @node SPV Detail format Element
2256 @subsubsection The @code{format} Element
2257
2258 Parent: @code{sourceVariable}, @code{derivedVariable}, @code{formatMapping}, @code{labeling}, @code{formatMapping}, @code{setFormat} @*
2259 Contents: (@code{affix}@math{+} @math{|} @code{relabel}@math{+})?
2260
2261 This element appears only in schema version 2.7 (@pxref{SPV Detail
2262 visualization Element}).
2263
2264 This element determines a format, equivalent to an SPSS print format.
2265
2266 @subsubheading Attributes for All Formats
2267
2268 These attributes apply to all kinds of formats.  The most important of
2269 these attributes determines the high-level kind of formatting in use:
2270
2271 @defvr {Optional} baseFormat
2272 Either @code{dateTime} or @code{elapsedTime}.  When this attribute is
2273 omitted, this element is a numeric or string format.
2274 @end defvr
2275
2276 @noindent
2277 Whether, in the corpus, other attributes are always present (``yes''),
2278 never present (``no''), or sometimes present (``opt'') depends on
2279 @code{baseFormat}:
2280
2281 @multitable {maximumFractionDigits} {@code{dateTime}} {@code{elapsedTime}} {number} {string}
2282 @headitem Attribute @tab @code{dateTime} @tab @code{elapsedTime} @tab number @tab string
2283 @item errorCharacter        @tab yes @tab yes @tab yes @tab opt
2284 @item @w{ }
2285 @item separatorChars        @tab yes @tab  no @tab  no @tab no
2286 @item @w{ }
2287 @item mdyOrder              @tab yes @tab  no @tab  no @tab no
2288 @item @w{ }
2289 @item showYear              @tab yes @tab  no @tab  no @tab no
2290 @item yearAbbreviation      @tab yes @tab  no @tab  no @tab no
2291 @item @w{ }
2292 @item showMonth             @tab yes @tab  no @tab  no @tab no
2293 @item monthFormat           @tab yes @tab  no @tab  no @tab no
2294 @item @w{ }
2295 @item showDay               @tab yes @tab opt @tab  no @tab no
2296 @item dayPadding            @tab yes @tab opt @tab  no @tab no
2297 @item dayOfMonthPadding     @tab yes @tab  no @tab  no @tab no
2298 @item dayType               @tab yes @tab  no @tab  no @tab no
2299 @item @w{ }
2300 @item showHour              @tab yes @tab opt @tab  no @tab no
2301 @item hourFormat            @tab yes @tab opt @tab  no @tab no
2302 @item hourPadding           @tab yes @tab yes @tab  no @tab no
2303 @item @w{ }
2304 @item showMinute            @tab yes @tab yes @tab  no @tab no
2305 @item minutePadding         @tab yes @tab yes @tab  no @tab no
2306 @item @w{ }
2307 @item showSecond            @tab yes @tab yes @tab  no @tab no
2308 @item secondPadding         @tab  no @tab yes @tab  no @tab no
2309 @item @w{ }
2310 @item showMillis            @tab  no @tab yes @tab  no @tab no
2311 @item @w{ }
2312 @item minimumIntegerDigits  @tab  no @tab  no @tab yes @tab no
2313 @item maximumFractionDigits @tab  no @tab yes @tab yes @tab no
2314 @item minimumFractionDigits @tab  no @tab yes @tab yes @tab no
2315 @item useGrouping           @tab  no @tab opt @tab yes @tab no
2316 @item scientific            @tab  no @tab  no @tab yes @tab no
2317 @item small                 @tab  no @tab  no @tab opt @tab no
2318 @item suffix                @tab  no @tab  no @tab opt @tab no
2319 @item @w{ }
2320 @item tryStringsAsNumbers   @tab  no @tab  no @tab  no @tab yes
2321 @item @w{ }
2322 @end multitable
2323
2324 @defvr {Attribute} errorCharacter
2325 A character that replaces the formatted value when it cannot otherwise
2326 be represented in the given format.  Always @samp{*}.
2327 @end defvr
2328
2329 @subsubheading Date and Time Attributes
2330
2331 These attributes are used with @code{dateTime} and @code{elapsedTime}
2332 formats or both.
2333
2334 @defvr {Attribute} separatorChars
2335 Exactly four characters.  In order, these are used for: decimal point,
2336 grouping, date separator, time separator.  Always @samp{.,-:}.
2337 @end defvr
2338
2339 @defvr {Attribute} mdyOrder
2340 Within a date, the order of the days, months, and years.
2341 @code{dayMonthYear} is the only observed value, but one would expect
2342 that @code{monthDayYear} and @code{yearMonthDay} to be reasonable as
2343 well.
2344 @end defvr
2345
2346 @defvr {Attribute} showYear
2347 @defvrx {Attribute} yearAbbreviation
2348 Whether to include the year and, if so, whether the year should be
2349 shown abbreviated, that is, with only 2 digits.  Each is @code{true}
2350 or @code{false}; only values of @code{true} and @code{false},
2351 respectively, have been observed.
2352 @end defvr
2353
2354 @defvr {Attribute} showMonth
2355 @defvrx {Attribute} monthFormat
2356 Whether to include the month (@code{true} or @code{false}) and, if so,
2357 how to format it.  @code{monthFormat} is one of the following:
2358
2359 @table @code
2360 @item long
2361 The full name of the month, e.g.@: in an English locale,
2362 @code{September}.
2363
2364 @item short
2365 The abbreviated name of the month, e.g.@: in an English locale,
2366 @code{Sep}.
2367
2368 @item number
2369 The number representing the month, e.g.@: 9 for September.
2370
2371 @item paddedNumber
2372 A two-digit number representing the month, e.g.@: 09 for September.
2373 @end table
2374
2375 Only values of @code{true} and @code{short}, respectively, have been
2376 observed.
2377 @end defvr
2378
2379 @defvr {Attribute} dayPadding
2380 @defvrx {Attribute} dayOfMonthPadding
2381 @defvrx {Attribute} hourPadding
2382 @defvrx {Attribute} minutePadding
2383 @defvrx {Attribute} secondPadding
2384 These attributes presumably control whether each field in the output
2385 is padded with spaces to its maximum width, but the details are not
2386 understood.  The only observed value for any of these attributes is
2387 @code{true}.
2388 @end defvr
2389
2390 @defvr {Attribute} showDay
2391 @defvrx {Attribute} showHour
2392 @defvrx {Attribute} showMinute
2393 @defvrx {Attribute} showSecond
2394 @defvrx {Attribute} showMillis
2395 These attributes presumably control whether each field is displayed
2396 in the output, but the details are not understood.  The only
2397 observed value for any of these attributes is @code{true}.
2398 @end defvr
2399
2400 @defvr {Attribute} dayType
2401 This attribute is always @code{month} in the corpus, specifying that
2402 the day of the month is to be displayed; a value of @code{year} is
2403 supposed to indicate that the day of the year, where 1 is January 1,
2404 is to be displayed instead.
2405 @end defvr
2406
2407 @defvr {Attribute} hourFormat
2408 @code{hourFormat}, if present, is one of:
2409
2410 @table @code
2411 @item AMPM
2412 The time is displayed with an @code{am} or @code{pm} suffix, e.g.@:
2413 @code{10:15pm}.
2414
2415 @item AS_24
2416 The time is displayed in a 24-hour format, e.g.@: @code{22:15}.
2417
2418 This is the only value observed in the corpus.
2419
2420 @item AS_12
2421 The time is displayed in a 12-hour format, without distinguishing
2422 morning or evening, e.g.@: @code{10;15}.
2423 @end table
2424
2425 @code{hourFormat} is sometimes present for @code{elapsedTime} formats,
2426 which is confusing since a time duration does not have a concept of AM
2427 or PM.  This might indicate a bug in the code that generated the XML
2428 in the corpus, or it might indicate that @code{elapsedTime} is
2429 sometimes used to format a time of day.
2430 @end defvr
2431
2432 @subsubheading Numeric Attributes
2433
2434 These attributes are used for formats when @code{baseFormat} is
2435 @code{number}.  Attributes @code{maximumFractionDigits}, and
2436 @code{minimumFractionDigits}, and @code{useGrouping} are also used
2437 when @code{baseFormat} is @code{elapsedTime}.
2438
2439 @defvr {Attribute} minimumIntegerDigits
2440 Minimum number of digits to display before the decimal point.  Always
2441 observed as @code{0}.
2442 @end defvr
2443
2444 @defvr {Attribute} maximumFractionDigits
2445 @defvrx {Attribute} maximumFractionDigits
2446 Maximum or minimum, respectively, number of digits to display after
2447 the decimal point.  The observed values of each attribute range from 0
2448 to 9.
2449 @end defvr
2450
2451 @defvr {Attribute} useGrouping
2452 Whether to use the grouping character to group digits in large
2453 numbers.  It would make sense for the grouping character to come from
2454 the @code{separatorChars} attribute, but that attribute is only
2455 present when @code{baseFormat} is @code{dateTime} or
2456 @code{elapsedTime}, in the corpus at least.  Perhaps that is because
2457 this attribute has only been observed as @code{false}.
2458 @end defvr
2459
2460 @defvr {Attribute} scientific
2461 This attribute controls when and whether the number is formatted in
2462 scientific notation.  It takes the following values:
2463
2464 @table @code
2465 @item onlyForSmall
2466 Use scientific notation only when the number's magnitude is smaller
2467 than the value of the @code{small} attribute.
2468
2469 @item whenNeeded
2470 Use scientific notation when the number will not otherwise fit in the
2471 available space.
2472
2473 @item true
2474 Always use scientific notation.  Not observed in the corpus.
2475
2476 @item false
2477 Never use scientific notation.  A number that won't otherwise fit will
2478 be replaced by an error indication (see the @code{errorCharacter}
2479 attribute).  Not observed in the corpus.
2480 @end table
2481 @end defvr
2482
2483 @defvr {Optional} small
2484 Only present when the @code{scientific} attribute is
2485 @code{onlyForSmall}, this is a numeric magnitude below which the
2486 number will be formatted in scientific notation.  The values @code{0}
2487 and @code{0.0001} have been observed.  The value @code{0} seems like a
2488 pathological choice, since no real number has a magnitude less than 0;
2489 perhaps in practice such a choice is equivalent to setting
2490 @code{scientific} to @code{false}.
2491 @end defvr
2492
2493 @defvr {Optional} prefix
2494 @defvrx {Optional} suffix
2495 Specifies a prefix or a suffix to apply to the formatted number.  Only
2496 @code{suffix} has been observed, with value @samp{%}.
2497 @end defvr
2498
2499 @subsubheading String Attributes
2500
2501 These attributes are used for formats when @code{baseFormat} is
2502 @code{string}.
2503
2504 @defvr {Attribute} tryStringsAsNumbers
2505 When this is @code{true}, it is supposed to indicate that string
2506 values should be parsed as numbers and then displayed according to
2507 numeric formatting rules.  However, in the corpus it is always
2508 @code{false}.
2509 @end defvr
2510
2511 @node SPV Detail numberFormat Element
2512 @subsubsection The @code{numberFormat} Element
2513
2514 Parent: @code{setFormat} @*
2515 Contents: @code{affix}@math{+}
2516
2517 This element appears only in schema version 2.5 and earlier
2518 (@pxref{SPV Detail visualization Element}).  Possibly this element
2519 could also contain @code{relabel} elements in a more diverse corpus.
2520
2521 This element has the following attributes.
2522
2523 @defvr {Attribute} maximumFractionDigits
2524 @defvrx {Attribute} minimumFractionDigits
2525 @defvrx {Attribute} minimumIntegerDigits
2526 @defvrx {Optional} scientific
2527 @defvrx {Optional} small
2528 @defvrx {Optional} suffix
2529 @defvrx {Optional} useGroupging
2530 The syntax and meaning of these attributes is the same as on the
2531 @code{format} element for a numeric format.  @pxref{SPV Detail format
2532 element}.
2533 @end defvr
2534
2535 @node SPV Detail stringFormat Element
2536 @subsubsection The @code{stringFormat} Element
2537
2538 Parent: @code{setFormat} @*
2539 Contents: (@code{affix}@math{+} @math{|} @code{relabel}@math{+})?
2540
2541 This element appears only in schema version 2.5 and earlier
2542 (@pxref{SPV Detail visualization Element}).
2543
2544 This element has no attributes.
2545
2546 @node SPV Detail dateTimeFormat Element
2547 @subsubsection The @code{dateTimeFormat} Element
2548
2549 Parent: @code{setFormat} @*
2550 Contents: empty
2551
2552 This element appears only in schema version 2.5 and earlier
2553 (@pxref{SPV Detail visualization Element}).  Possibly this element
2554 could also contain @code{affix} and @code{relabel} elements in a more
2555 diverse corpus.
2556
2557 The following attribute is required.
2558
2559 @defvr {Attribute} baseFormat
2560 Either @code{dateTime} or @code{time}.
2561 @end defvr
2562
2563 When @code{baseFormat} is @code{dateTime}, the following attributes
2564 are available.
2565
2566 @defvr {Attribute} dayOfMonthPadding
2567 @defvrx {Attribute} dayPadding
2568 @defvrx {Attribute} dayType
2569 @defvrx {Attribute} hourFormat
2570 @defvrx {Attribute} hourPadding
2571 @defvrx {Attribute} mdyOrder
2572 @defvrx {Attribute} minutePadding
2573 @defvrx {Attribute} monthFormat
2574 @defvrx {Attribute} separatorChars
2575 @defvrx {Attribute} showDay
2576 @defvrx {Attribute} showHour
2577 @defvrx {Attribute} showMinute
2578 @defvrx {Attribute} showMonth
2579 @defvrx {Attribute} showSecond
2580 @defvrx {Attribute} showYear
2581 @defvrx {Attribute} yearAbbreviation
2582 The syntax and meaning of these attributes is the same as on the
2583 @code{format} element when that element's @code{baseFormat} is
2584 @code{dateTime}.  @pxref{SPV Detail format Element}.
2585 @end defvr
2586
2587 When @code{baseFormat} is @code{time}, the following attributes are
2588 available.
2589
2590 @defvr {Attribute} hourFormat
2591 @defvrx {Attribute} hourPadding
2592 @defvrx {Attribute} minutePadding
2593 @defvrx {Attribute} monthFormat
2594 @defvrx {Attribute} separatorChars
2595 @defvrx {Attribute} showDay
2596 @defvrx {Attribute} showHour
2597 @defvrx {Attribute} showMinute
2598 @defvrx {Attribute} showMonth
2599 @defvrx {Attribute} showSecond
2600 @defvrx {Attribute} showYear
2601 @defvrx {Attribute} yearAbbreviation
2602 The syntax and meaning of these attributes is the same as on the
2603 @code{format} element when that element's @code{baseFormat} is
2604 @code{elapsedTime}.  @pxref{SPV Detail format Element}.
2605 @end defvr
2606
2607 @node SPV Detail affix Element
2608 @subsubsection The @code{affix} Element
2609
2610 Parent: @code{format} or @code{numberFormat} or @code{stringFormat} @*
2611 Contents: empty
2612
2613 Possibly this element could have @code{dateTimeFormat} as a parent in
2614 a more diverse corpus.
2615
2616 This defines a suffix (or, theoretically, a prefix) for a formatted
2617 value.  It is used to insert a reference to a footnote.  It has the
2618 following attributes:
2619
2620 @defvr {Attribute} definesReference
2621 This specifies the footnote number as a natural number: 1 for the
2622 first footnote, 2 for the second, and so on.
2623 @end defvr
2624
2625 @defvr {Attribute} position
2626 Position for the footnote label.  Always @code{superscript}.
2627 @end defvr
2628
2629 @defvr {Attribute} suffix
2630 Whether the affix is a suffix (@code{true}) or a prefix
2631 (@code{false}).  Always @code{true}.
2632 @end defvr
2633
2634 @defvr {Attribute} value
2635 The text of the suffix or prefix.  Typically a letter, e.g.@: @code{a}
2636 for footnote 1, @code{b} for footnote 2, @enddots{}  The corpus
2637 contains other values: @code{*}, @code{**}, and a few that begin with
2638 at least one comma: @code{,b}, @code{,c}, @code{,,b}, and @code{,,c}.
2639 @end defvr
2640
2641 @node SPV Detail relabel Element
2642 @subsubsection The @code{relabel} Element
2643
2644 Parent: @code{format} or @code{stringFormat} @*
2645 Contents: empty
2646
2647 Possibly this element could have @code{numberFormat} or
2648 @code{dateTimeFormat} as a parent in a more diverse corpus.
2649
2650 This specifies how to display a given value.  It is used to implement
2651 value labels and to display the system-missing value in a
2652 human-readable way.  It has the following attributes:
2653
2654 @defvr {Attribute} from
2655 The value to map.  In the corpus this is an integer or the
2656 system-missing value @code{-1.797693134862316E300}.
2657 @end defvr
2658
2659 @defvr {Attribute} to
2660 The string to display in place of the value of @code{from}.  In the
2661 corpus this is a wide variety of value labels; the system-missing
2662 value is mapped to @samp{.}.
2663 @end defvr
2664
2665 @node SPV Detail union Element
2666 @subsubsection The @code{union} Element
2667
2668 Parent: @code{setCellProperties} @*
2669 Contents: @code{intersect}@math{+}
2670
2671 This element represents a set of cells, computed as the union of the
2672 sets represented by each of its children.
2673
2674 @subsubheading The @code{intersect} Element
2675
2676 Parent: @code{union} @*
2677 Contents: @code{where}@math{+} @math{|} @code{intersectWhere}?
2678
2679 This element represents a set of cells, computed as the intersection
2680 of the sets represented by each of its children.
2681
2682 Of the two possible children, in the corpus @code{where} is far more
2683 common, appearing thousands of times, whereas @code{intersectWhere}
2684 only appears 4 times.
2685
2686 Most @code{intersect} elements have two or more children.
2687
2688 @subsubheading The @code{where} Element
2689
2690 Parent: @code{intersect} @*
2691 Contents: empty
2692
2693 This element represents the set of cells in which the value of a
2694 specified variable falls within a specified set.
2695
2696 @defvr {Attribute} variable
2697 The @code{id} of a variable, e.g.@: @code{dimension0categories} or
2698 @code{dimension0group0map}.
2699 @end defvr
2700
2701 @defvr {Attribute} include
2702 A value, or multiple values separated by semicolons,
2703 e.g.@: @code{0} or @code{13;14;15;16}.
2704 @end defvr
2705
2706 @subsubheading The @code{intersectWhere}
2707
2708 Parent: @code{intersect} @*
2709 Contents: empty
2710
2711 The meaning of this element is unknown.
2712
2713 @defvr {Attribute} variable
2714 @defvrx {Attribute} variable2
2715 The meaning of these attributes is unknown.  In the four examples in
2716 the corpus they always take the values @code{dimension2categories} and
2717 @code{dimension0categories}, respectively.
2718 @end defvr