For better human readability, and thus understanding by the end users, it is often desired to use spaces in the DisplayName of SiteColumns and ContentTypes FieldRefs: "The columnname". But beware, this gives some peculiarities with the different approaches to query and display the SharePoint content...
Enterprise Search
Upon first crawling of the content source, this ends up in a CrawledProperty with the name "The_x0020_ColumnName". This can be mapped to a ManagedProperty. The name of this property may not include any spaces. Here it could be "TheColumnName". With Enterprise Search, one can now query and select on the property 'TheColumnName'. For instance, query via the AdvancedSearchBox webpart, and display the results via the SearchCoreResults webpart. Rather handy to skip in the XML-based query (SQL-CAML), and the rendering of the query result (XSLT), the special handling of the space character.CAML-based site content query
When query and displaying site data via the ContentQueryWebPart, one must select and display on the actual field / column name. That is, in the CommonViewFields specification, the actual column name must be used. Due to the space in the name, CAML space-mapping must be applied; resulting in 'The_x0020_columnname'. Example:<property name="CommonViewFields" type="string">
Title,String;The_x0020_columnname,Choice;Editor,User
</property>
Title,String;The_x0020_columnname,Choice;Editor,User
</property>
This is all pretty well-known SharePoint stuff.
Something that is less known, is that yet another CAML translation must be applied to successfully display the CQWP queryresults via XSLT rendering. The CAML-space character '_x0020_' must itself be translated into '_x005F_x0020_'. So for instance:
<td class="ms-vb" nowrap="">
<xsl:value-of select="@The_x005F_x0020_columnname"/>
</td>
<xsl:value-of select="@The_x005F_x0020_columnname"/>
</td>
Thus...
To summarize: when you put a space in the displayname of a field, this may wind up in 4 different 'names' within the query/display pipeline:- The actual displayname itself: "The columnname"
- The managed property name for within enterprise search: "TheColumnName"
- The query fieldspecification within CQWP: "The_x0020_columnname"
- The query result rendering used by CQWP: "The_x005F_x0020_columnname"