Description

A Datakey defines how to generate a unique identifier for XML elements within an application's data. Altio adds these unique identifiers or keys to each data element as an AL_ID attribute.

Every data element that has multiple instances beneath the same parent element should have a Datakey defined for it. The default Datakey definition is the element name concatenated to the Datakey value of the parent element. This will suffice for elements that have only a single instance below a specific parent element, and so you do not need to specify a Datakey for them.

Displaying the existing Datakeys

In the Application Explorer window, double-click on the Datakeys node to show the Datakeys defined for an application.

images/set_up_datakeys/image002.jpg  

 

Creating Datakeys

Extracting Datakeys automatically

To automatically create datakeys, test a Service Function and from the Test results window, click on the Extract Datakeys button.

A popup window should be displayed, giving a list of the extracted datakeys:

For more information about testing a Service Function see: The Test tab section in Setting the HTTP Service Functions, Setting the SOAP Service Functions, Setting the JDBC Service Functions, or Setting the JAVA Service Functions depending on the type of Service Function you want to test.

Creating Datakeys manually

To manually create datakeys, do one of the following:

Setting the properties of a Datakey

  1. Double-click on the Datakey you want to set to display its properties

.images/set_up_datakeys/image006.jpg

  1. If you want to change the default name, enter the name you want. This Datakey will be applied to elements matching this name.

  2. In the Prefix cell, you can enter a text to be added to the start of each key generated from this Datakey.

  3. In the Key cell, enter an Xpath that predicate expression defining how each key is generated. The simplest way is using an attribute from the element as a key. For example: @SALE_ID.

  4. For more information: see the example below.

  1. If you do not want the Datakey to be applied apply to all the elements matching the Name but only some of them, enter a Namespace URI. The Datakey will only be applied to elements matching this namespace. If no namespace URI is entered then the Datakey will be applied to all elements matching Name.

Example

Given the following XML and a Datakey with a name of STOCK, the unique id or AL_ID added by Altio to the STOCK element shown will be as follows:

<STOCKS xmlns:a="www.bensemporium.com" MARKET="NASDAQ" >
     <a:STOCK ID="BE01">Ben's Emporium Ltd
           <SYMBOL>BE</SYMBOL>
     </STOCK>
</STOCKS>

 

Key

Prefix

Namespace URI

AL_ID generated

@ID

 

 

BE01

text()

 

 

Ben's Emporium Ltd

concat(name(), '-', @ID)

 

 

STOCK-BE01

concat(parent::STOCKS/@MARKET, @ID)"

 

 

NASDAQBE01

concat(name(), '-', SYMBOL\text())

 

 

STOCK-BE

concat(namespace-uri(), '-', name(), '-', @ID)"

 

 

www.bensemporium.com-STOCK-BE01

@ID

ST-

 

ST-BE01

@ID

 

www.bensemporium.com

BE01

@ID

 

www.jimsdiscountstore.com

None, Datakey does not apply to this particular STOCK

 

Please note: attributes used for constructing datakey shall be read-only. Once an element is created, values of these attributes shall not be changed. Otherwise AltioLive will not be able to locate the original element for updating.

For more information on Datakeys, see the chapter called Integrating AltioLive.