Data Model > Available DSCs > SPSS Statistics SAV DSC > Writing to an SPSS Statistics .sav file > SPSS WebApp XML file
 
SPSS WebApp XML file
SPSS WebApp is an application development system that enables you to deliver live statistical analyses over the Web. SPSS WebApp can analyze data in a number of formats, including IBM SPSS Statistics .sav files. SPSS WebApp can work with more metadata than is contained within the .sav file and SPSS WebApp stores this additional metadata in an XML file.
The SPSS Statistics SAV DSC automatically creates an XML file for use with SPSS WebApp when you use the SPSS Statistics SAV DSC to write data to a .sav file. The XML file contains information (such as how variables are grouped together in hierarchies and special custom properties) that is available in the MDM document but which it is not possible to store in the .sav file.
This topic provides information about how the SPSS Statistics SAV DSC writes the information in the MDM document to the XML file. It assumes familiarity with the MDM and the SPSS WebApp XML file format.
SPSS WebApp XML file creation
The XML file is created immediately after the .sav file is created. The XML file is in the same directory as the .sav file and with the same name but with the addition of an .xml filename extension. This will not create a new .sav file if one already exists, however note that it will overwrite an existing XML file without giving a warning.
The SPSS WebApp framework requires the .sav file and its related XML file to be placed in a designated "datafiles-import" folder. The SPSS Statistics SAV DSC does not have any intrinsic awareness of the location of this folder, and if necessary the files must be moved to the required folder manually.
Variable names
Variable names and labels when writing to a .sav file describes how alias names are created from the MDM variable names for use as IBM SPSS Statistics variable names and how these alias names are stored in the MDM document. The SPSS WebApp XML file refers to all of the IBM SPSS Statistics variables using these alias names.
However, the SPSS WebApp XML format requires additional names; for example for naming groups of variables. These names are also limited in length, and are not allowed to conflict with existing names. The SPSS Statistics SAV DSC creates these additional alias names as necessary and ensures that they do not conflict with existing alias names. However, these WebApp-specific names are not stored in the MDM document. Each export from the MDM document might therefore result in different names for the same WebApp groups and other WebApp-specific items.
Information stored in the SPSS WebApp XML file
datasetinfo header
The creates a datasetinfo header element with both name and datasource attributes. Here is an example:
<?xml version="1.0" encoding="UTF-8"?>
<spssmetadataextension>
  <extension>
    <datasetinfoname="museum" datasource="museum.sav">
      <description>Automatically generated by mrSavDsc</description>
      <security>
        <groupgroupname="- Everyone -"/>
      </security>
    </datasetinfo>
  </extension>
</spssmetadataextension>
name
The SPSS Statistics SAV DSC uses the first name that it finds from the following:
The MDM document's label in the Analysis user context and the base label type and language.
The MDM document's label in the Question user context and the base label type and language.
The name of the .sav file.
datasource
The name of the .sav file including the .sav filename extension.
description
This always has the text "Automatically generated by mrSavDsc".
security
The groupname attributes are generated from the SecurityGroups custom property (see Properties and settings used by the SPSS Statistics SAV DSC on the MDM document object in the WebApp user context. This custom property should be in the form of a semicolon-separated list of security group names. For example, if the SecurityGroups custom property on the MDM document object has the value "World;LocalUser;WanUser", the SPSS Statistics SAV DSC generates the following XML:
<security>
  <groupgroupname="World"/>
  <groupgroupname="LocalUser"/>
  <groupgroupname="WanUser"/>
</security>
If the SecurityGroups custom property does not exist on the MDM document object, the generates a security group called "- Everyone -" as shown in the first example above.
MDM properties and custom properties
The SPSS Statistics SAV DSC creates tag elements in the XML file to store additional information that is available for the variable instances in the MDM document. This additional information can come from native MDM properties (such as VariableInstance.MinValue) and MDM custom properties. The SPSS Statistics SAV DSC includes all of the variable instance custom properties that it finds in the WebApp user context regardless of the name and also a few custom properties with specific names that it finds in other user contexts, such as the IsFilter custom property in the Analysis or Question user context.
The SPSS Statistics SAV DSC includes this information for all of the variable instances that have been assigned an alias name in the DataSource object that is being used for the export, regardless of whether those variable instances are actually included in the export or not. This means that sometimes the XML file will include variables that do not appear in the .sav file.
As mentioned above, these properties are stored using the XML tag element. The same tag can occur multiple times once for each value. The SPSS Statistics SAV DSC attempts to store all variables with same tag name (property) and value in the same XML element. For example:
<tagname="max" value="5">
  <variablename="dinosaur"/>
  <variablename="whales"/>
  <variablename="human"/>
  <variablename="species"/>
  <variablename="mammals"/>
</tag>
The SPSS Statistics SAV DSC depends on XML equality to decide whether two values are identical or not. This means that the same tag stored with two values that only differ in case will be stored as two XML elements.
Variable, property, and custom property names in MDM are not case-sensitive, but may have a mixture of upper and lower case. The SPSS Statistics SAV DSC converts all variable, property, and custom property names to lower case before storing them in the XML file. This allows XPATH queries to correctly locate a tag name.
The same variable is not stored in more than one tag of the same name. If a variable instance has the information stored in more than one property or custom property, the MDM inheritance rules are used to decide which value is used. These rules specify that DataSourceProperties take precedence over VariableInstance custom properties, which in turn take precedence over the Variable DataSourceProperties, which in turn take precedence over the Variable custom properties. This implies that DataSourceProperties can hide VariableInstance custom properties and that VariableInstance custom properties can hide Variable custom properties.
In addition to these inheritance rules, the SPSS Statistics SAV DSC gives priority to custom properties in the WebApp user context over all other properties and custom properties. For example, if the VariableInstance.MinValue property has a value of 42 and there is a custom property called min on the same variable instance in the WebApp user context with a value of 19, the SPSS Statistics SAV DSC creates a tag named min and a value of 19. If the min custom property did not exist, the would have created a tag named min with a value of 42.
Note that the VariableInstance.MinValue and VariableInstance.MaxValue properties are only exported to the XML file for numeric variables (type Long and Double) and only if the properties are explicitly defined and not empty. When the properties are defined, the SPSS Statistics SAV DSC creates WebApp tags called min and max (if not already present) and adds the variables to the tag element.
Filter and weight properties
Variables can be defined as filters and weighting variables in a number of ways in the MDM document:
by setting the Variable.UsageType property
by adding the IsFilter or IsWeight custom property to the Analysis or Question user context.
If the vtWeight or vtFilter UsageType flags are set, the SPSS Statistics SAV DSC creates a tag called weight or filter, respectively. The tag has no value attribute.
If the IsFilter or IsWeight custom property is present in either the Question or Analysis user context, it will override the UsageType flag. If present in both user contexts, the Analysis user context takes priority. If the custom property has a value of True, the SPSS Statistics SAV DSC will create a filter tag. However, note that according to general property inheritance rules, it is possible to override these custom properties by creating custom properties in the WebApp user context.
Here is an example:
<?xml version="1.0" encoding="UTF-8"?>
<spssmetadataextension>
  <extension>
    <datasetinfoname="museum" datasource="museum.sav">
      <description>Automatically generated by mrSavDsc</description>
      <security>
        <groupgroupname="- Everyone -"/>
      </security>
    </datasetinfo>
    <tagname="weight">
      <variablename="genbalan"/>
      <variablename="agebalan"/>
    </tag>
    <tagname="filter">
      <variablename="myfilter"/>
    </tag>
  </extension>
</spssmetadataextension>
Note that the genbalan and agebalan variables would have been included in the weight tag if any of the following were true:
The IsWeight custom property exists in the Analysis or Question user context on the variable object and has a value of True.
The Variable.UsageType property is set to vtWeight.
There is a weight custom property in the WebApp user context on the variable.
Defining customized information
The SPSS Statistics SAV DSC stores in the XML file all of the variable instance custom properties in the WebApp user context. Although none of the WebApp custom properties have a special meaning to the SPSS Statistics SAV DSC, any custom properties that you define in the WebApp user context will be stored in the XML file. You can use this feature to set up any information that you want to pass to WebApp. You can use MDM Explorer to create custom properties in the WebApp user context.
Groups of variables
The SPSS Statistics SAV DSC inspects all of the variable instances to see if they are part of a hierarchical structure (such as a grid) and when relevant defines variable groups in the XML file. However, the MDM can handle deeply nested hierarchies whereas the WebApp XML allows for only one level of grouping. The SPSS Statistics SAV DSC handles nested hierarchies by creating variable groups for the deepest level and each iteration at the higher levels. The names of the variable groups in the XML file are based on the relevant part of the variable instance full names to which a suffix is added to indicate the group type. For example, for a straightforward grid question, the SPSS Statistics SAV DSC creates the main part of the group name by removing the variable instance-specific part of the full name. However, this might then be altered by the Alias Map component to remove certain non-alphanumeric characters (such as the underscore) and make it unique.
The variable groups in the WebApp XML have a type of scale, ordinal, categorical, or banner. When the variables at the same level in the hierarchy are of different types, the SPSS Statistics SAV DSC creates a separate group of each type that is present. The type mappings are shown in the following table.
Group type
Includes MDM variable types
Group name suffix
scale
Long, Double
_s
ordinal
Boolean, Categorical
_o
banner
All other types
_b
Note that the categorical group type is not used by default. However, you can specify that it should be used by creating a custom property called Categorical in the WebApp user context.
The SPSS Statistics SAV DSC defines separate groups for helper field variables. Helper field groups have a group name suffix of _h.
Here is an example that shows the two groups created for the plan_order grid. The first group is for the helper field variables, the second for the main variables.
<variablegroupname="plaordho" label="plan_order_h_o"
type="ordinal">
  <variablename="ploficoe"/>
  <variablename="porsecoe"/>
  <variablename="plothcoe"/>
  <variablename="porfocoe"/>
  <variablename="porfice1"/>
</variablegroup>
<variablegroupname="plaordeo" label="plan_order_o"
type="ordinal">
  <variablename="$porfico"/>
  <variablename="$porseco"/>
  <variablename="$porthco"/>
  <variablename="$porfoco"/>
  <variablename="$porfco1"/>
</variablegroup>
Information not stored in the XML file
Information about multiple response sets is not stored in the XML file because this information is defined in the .sav file. In addition, grouping information is not stored in the XML file for text variables that are stored in more than one .sav file variable. However, text variables that are created in the .sav file from the same MDM text variable can be identified using their alias names, which are derived from the same full name.
See also
Variable names and labels when writing to a .sav file
Variable definitions when writing to a .sav file
Missing values when writing to a .sav file
Troubleshooting when writing to a .sav file
Writing to an SPSS Statistics .sav file