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