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