SetColumnMapping.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
  4. <sect1 id="SetColumnMapping">
  5. <title><emphasis role="bold">SetColumnMapping</emphasis></title>
  6. <para><emphasis role="bold">STD.File.SetColumnMapping<indexterm>
  7. <primary>STD.File.SetColumnMapping</primary>
  8. </indexterm><indexterm>
  9. <primary>File.SetColumnMapping</primary>
  10. </indexterm><indexterm>
  11. <primary>SetColumnMapping</primary>
  12. </indexterm>(</emphasis> <emphasis> file, mapping </emphasis> <emphasis
  13. role="bold">);</emphasis></para>
  14. <informaltable colsep="0" frame="none" rowsep="0">
  15. <tgroup cols="2">
  16. <colspec colwidth="80.50pt" />
  17. <colspec />
  18. <tbody>
  19. <row>
  20. <entry><emphasis>file</emphasis></entry>
  21. <entry>A null-terminated string containing the logical
  22. filename.</entry>
  23. </row>
  24. <row>
  25. <entry><emphasis>mapping</emphasis></entry>
  26. <entry>A null-terminated string containing a comma-delimited list of
  27. field mappings.</entry>
  28. </row>
  29. </tbody>
  30. </tgroup>
  31. </informaltable>
  32. <para>The <emphasis role="bold">SetColumnMapping </emphasis>function defines
  33. how the data in the fields of the <emphasis>file</emphasis> mist be
  34. transformed between the actual data storage format and the input format used
  35. to query that data.</para>
  36. <para>The format for each field in the <emphasis>mapping</emphasis> list
  37. is:</para>
  38. <para><emphasis role="bold">&lt;field&gt;{set(&lt;transform&gt;(
  39. args),...),get(&lt;transform&gt;,...),displayname(&lt;name&gt;)}</emphasis></para>
  40. <informaltable colsep="0" frame="none" rowsep="0">
  41. <tgroup cols="2">
  42. <colspec colwidth="80.50pt" />
  43. <colspec />
  44. <tbody>
  45. <row>
  46. <entry><emphasis>&lt;field&gt;</emphasis></entry>
  47. <entry>The name of the field in the file.</entry>
  48. </row>
  49. <row>
  50. <entry><emphasis role="bold">set</emphasis></entry>
  51. <entry>Optional. Specifies the transforms applied to the values
  52. supplied by the user to convert them to values in the file.</entry>
  53. </row>
  54. <row>
  55. <entry><emphasis>&lt;transform&gt;</emphasis></entry>
  56. <entry>Optional. The name of a function to apply to the value. This
  57. is typically the name of a plugin function. The value being
  58. converted is always provided as the first parameter to the function,
  59. but extra parameters can be specified in brackets after the
  60. transform name (similar to SALT hygiene).</entry>
  61. </row>
  62. <row>
  63. <entry><emphasis role="bold">get</emphasis></entry>
  64. <entry>Optional. Specifies the transforms applied to the values in
  65. the file to convert them to the formatted values as they are
  66. understood by the user.</entry>
  67. </row>
  68. <row>
  69. <entry><emphasis role="bold">displayname</emphasis></entry>
  70. <entry>Optional. Allows a different <emphasis>name</emphasis> to be
  71. associated with the field than the user would naturally
  72. understand.</entry>
  73. </row>
  74. </tbody>
  75. </tgroup>
  76. </informaltable>
  77. <para>Note that you may mix unicode and string functions, as the system
  78. automatically converts the parameters to the appropriate types expected for
  79. the functions.</para>
  80. <para>Example:</para>
  81. <programlisting format="linespecific">// A file where the firstname(string) and lastname(unicode) are
  82. //always upper-cased:
  83. // There is no need for a displayname since it isn't really a
  84. // different field as far as the user is concerned, and there is
  85. // obviously no get transformations.
  86. firstname{set(stringlib.StringToUpperCase)},
  87. surname{set(unicodelib.UnicodeToUpperCase)}
  88. // A name translated using a phonetic key
  89. // it is worth specifying a display name here, because it will make
  90. // more sense to the user, and the user may want to enter either the
  91. // translated or untranslated names.
  92. dph_lname{set(metaphonelib.DMetaPhone1),
  93. displayname(lname)}
  94. // A file where a name is converted to a token using the namelib
  95. // functions. (I don't think we have an example of this)
  96. // (one of the few situations where a get() attribute is useful)
  97. fnametoken{set(namelib.nameToToken),
  98. get(namelib.tokenToName),
  99. displayname(fname)}
  100. // upper case, and only include digits and alphabetic.
  101. searchname{set(stringlib.StringToUpperCase,
  102. stringlib.StringFilter(
  103. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'))}
  104. // A file with a field that that needs to remove accents and then
  105. // uppercase:
  106. lastname{set(unicodeLIb.CleanAccents,stringLib.StringToUpperCase)}
  107. </programlisting>
  108. </sect1>