Controlling Variable and Value Label Display

The display of variable names and/or labels and values and/or value labels in pivot tables is determined by the current settings for SET TVARS and SET TNUMBERS—the corresponding text attributes in the OXML also reflect those settings. The system default is to display labels when they exist and names or values when they don't. The settings can be changed to always show names or values and never show labels or always show both.

The XSLT templates showVarInfo and showValueInfo are designed to ignore those settings and always show both names or values and labels (if present).

Figure 1. showVarInfo and showValueInfo templates
<!--display both variable names and labels-->
<xsl:template name="showVarInfo">
 <xsl:text>Variable Name: </xsl:text>
 <xsl:value-of select="@varName"/>
 <xsl:if test="@label">
   <xsl:text>Variable Label: </xsl:text>
   <xsl:value-of select="@label"/>

<!--display both values and value labels-->
<xsl:template name="showValueInfo">
 <!--Numeric vars have a number attribute,
  string vars have a string attribute -->
  <xsl:when test="parent::*/@number">
   <xsl:value-of select="parent::*/@number"/>
  <xsl:when test="parent::*/@string">
   <xsl:value-of select="parent::*/@string"/>
 <xsl:if test="parent::*/@label">
   <xsl:text>: </xsl:text>
   <xsl:value-of select="parent::*/@label"/>
  • <xsl:text>Variable Name: </xsl:text> and <xsl:value-of select="@varName"/> display the text "Variable Name:" followed by the variable name.
  • <xsl:if test="@label"> checks to see if the variable has a defined label.
  • If the variable has a defined label, <xsl:text>Variable Label: </xsl:text> and <xsl:value-of select="@label"/> display the text "Variable Label:" followed by the defined variable label.
  • Values and value labels are handled in a similar fashion, except instead of a varName attribute, values will have either a number attribute or a string attribute.