Previous Topic: Normalize OperationNext Topic: Format Operation


Normalize Property—Transforms Event Property Values

Normalize operations begin with a <Normalize> property. Normalize operations transform the syntax of event property values to give values from all sources a uniform nomenclature.

This property has the following format:

<Normalize>
   <Field input= type= [inputtype= connectionstring= jdbcdriver= query= 
   returntype=]|[jclass= method=]|[cmdline=] output= />
       [<mapentry mapin= mapout=>]
</Normalize>

Note: The input, type, and output attributes are required for type in the <Normalize> property. Other required attributes depend on the type of normalize operation you are writing.

input

Defines the list of properties to normalize.

type

Defines the type of normalization to perform. You can have multiple fields of the same or different types within a single Normalize property with no restrictions. The following are available types:

map

Matches and normalizes properties against regular expressions. Map normalization uses mapentry elements that represent an expression and an output for assigning to the property if the expression is matched. These elements are read from top to bottom until a property matches an element, after which additional mapentries are not considered. This type requires use of the following attributes:

  • mapin
  • mapout
jdbc

Uses property values as input parameters in a JDBC query to determine the normalized value for the properties. This type requires the following attributes:

  • inputtype
  • connectionstring
  • jdbcdriver
  • query
  • returntype
methodcall

Uses property values as input parameters in a Java method call to determine the normalized value for the properties. Properties are treated as strings using this option and the Java method must accept a string array as its only parameter. This type requires the following attributes:

  • jclass
  • method
exe

Uses property values as input parameters in an executable to determine the normalized value for the properties. This type requires the following attribute:

  • cmdline
mapin

(map only) Defines a regular expression pattern that compares the input property value.

mapout

(map only) Defines the assigned value to the output property if the input property matches the mapin regular expression.

inputtype

(jdbc only) Defines the value types for the input properties. Valid values are any Java primitive types such as int, string, long, and bool.

connectionstring

(jdbc only) Defines a JDBC connection string to a database instance. This string must include the database instance, name, user name, and password. The subsequent JDBC example shows use of a string.

jdbc driver

(jdbc only) Defines the JDBC driver Java class. Write the class for this attribute without the .class extension.

query

(jdbc only) Defines a SQL SELECT query that returns the value to use for the input property.

returntype

(jdbc only) Defines the value type of the value returned from the JDBC query. Valid types are any Java primitive type such as int, string, and bool.

jclass

(methodcall only) Defines the Java class full name where you run a method.

method

(methodcall only) Defines the name of the Java method that returns the value used for the input property.

cmdline

(exe only) Defines the command line that includes the full pathname and returns the value for the input property. Use substitution markers ({0}, {1}, and {2}) that are replaced with the input property values.

output

Defines the property that is assigned the output value of the normalization operation. The output property is assigned the following value for each normalization type:

For all normalization types, you can use a new or existing output property.

Example: Normalizing city output by mapping with regular expressions

The following example maps the city and state input properties to one city output property according to regular expressions:

<Normalize>
   <Field input="city,state" type="map" output="city">
       <mapentry mapin="^Cin.*,IA$" mapout="Cincinnati" />
       <mapentry mapin="^Cin.*,OH$" mapout="Cincinnati" />
   </Field>
</Normalize>

The <Normalize> property searches for city properties that begin with Cin, have a state property of IA or OH, and normalizes these input properties to a city output that reads Cincinnati.

Example: Normalizing vendor output using a jdbc query

The following example finds the vendorid input property and normalizes the property to display the vendor's name using a jdbc query:

<Normalize>
   <Field input="vendorid" inputtype="string" type="jdbc"
   connectionstring="jdbc:sqlserver://server01;databaseName=trapdb;
   user=sa;password=sa;" 
   jdbcdriver="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
   query="select vendorname from traptable where vendorid=?" returntype="string" 
   output="vendorname" />
</Normalize>

The <Normalize> property searches for vendorid properties and normalizes these properties by running a JDBC query to find the vendor name for each vendorid in a database that contains this information. The property displays the vendor name in place of the vendorid in a new vendorname output property.

Example: Normalizing zip code output using a Java method

The following example finds the city, state, and zip input properties and normalizes this information into one ninedigitzipcode property by running a Java method:

<Normalize>
   <Field input="city,state,zip" type="methodcall" 
   jclass="com.ca.eventplus.catalog.methods.ZipCode" method="ConvertZip" 
   output="ninedigitzip" />
</Normalize>

The <Normalize> property normalizes the city, state, and zip input properties into the value of the zip code expressed in nine digits by running a Java method to obtain this value. The property displays the nine-digit zip code in a new output property in place of the input properties.

Example: Normalizing zip code output using a command line executable

The following example finds the city, state, and zip input properties and normalizes this information into one ninedigitzip property by running a command line executable:

<Normalize>
   <Field input="city,state,zip" type="exe" cmdline="c:\\normzip.exe {0} {1} {2}"
   output="ninedigitzip" />
</Normalize>

The <Normalize> property normalizes the city, state, and zip input properties into the value of the zip code expressed in nine digits by running a command line executable to obtain this value. The executable contains substitution markers that are replaced with each input property value to calculate the nine-digit zip code using this information. The property displays the nine-digit zip code in a new output property in place of the input properties.