English

How To: Set up aliases for the field names of ArcSDE layer served by ArcIMS

Summary

Instructions provided describe how to set up aliases for the field names of ArcSDE layer served by ArcIMS.

Procedure

There are two methods that can be implemented to achieve this.

  • Client Side
    The easiest option is for field aliasing to be handled by the client application itself. If the HTML viewer is being used, aliasing can be implemented using JavaScript. Similarly, aliasing can be employed in ASP/JSP environment.

    A. Create a field alias list for each layer. For example:

    Code:
    fieldAliasList[x]="<database>.<user>.<layername>.<fieldname1>:<aliased_fieldname1>|<database>.<user>.<layername>.<fieldname2>:<aliased_fieldname2>";
    ...
    ...
    fieldAliasList[0]="DATA.GISDBA.USA_CITIES.CITY_FIPS:City FIPS|DATA.GISDBA.USA_CITIES.CITY_NAME:City Name";


    Note:
    The example above shows a generic example and a sample field alias array for a layer with an id=0. A similar array must be defined for each layer that contains fields to be aliased.
    B. Parse the response and populate the field names returned from the server
    C. Loop through and replace the field names for each layer. An example of this functionality can be seen in the 'writeOutDataPage()' function within the aimsIdentify.js file.
  • Client and Server Side
    When importing data into SDE an alias can be specified for the field names using the '-a' switch. This reduces the amount of client side programming necessary to parse out the aliased field name. This can be best described in an example which involves importing the 'states' shapefile, from the ESRI Tutorial data, to an SDE featureclass.

    A. Create a field alias list, essentially a text file, that lists all of the columns in the shapefile and how they appear in the feature class. For example, this is the contents of the Fields.txt file referenced in Step B, below:

    Code:
    <shape_column> [sde_column] /*do not include this line
    STATE_NAME NAME
    STATE_FIPS FIPS
    SUB_REGION REGION
    STATE_ABBR ABBREVIATION
    ...
    ...

    B. Run the shp2sde command to import the shapefile into an SDE feature class. For example:

    Code:
    C:\>shp2sde -o create -l states2,shape -f "C:\Program Files\ArcGIS\ArcIMS\Samples\TutorialData\states.shp" -a file="C:\Temp\fields.txt" -e a
    -s <servername> -i <instancename> -u <username> -p <password>

    The new fields now appear with aliased field names such as ARCADMIN.TEST.NAME.
    C. Since the field names are aliased at the server level, simple string functions ("InStr", "Len", etc) can be employed in the client application to remove "ARCADMIN.TEST" leaving behind "NAME".