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