Lookup Values

Looking up values from external sources or the database that you are working with can be done through the use of a lookup editor.

This editor firstly needs to be configured for the attribute on an element, and can only be configured for attributes in Xopus. This however does not mean that you cannot lookup values for elements, but it is not a standard feature and requires some more work.

A simple lookup configuration looks like this:

<x:lookupConfig xmlns:myns="http://mynamespace">
  <x:lookup 
      parentPattern="self::image"
           name="src" 
      url="lookup/image.html" 
      forceLookup="true" 
      autoOpen="true"/>
</x:lookupConfig>

This results in a lookup being opened for the src attribute of an image. More about this can be found on the lookup page.

This HTML page is a page that displays the values to lookup, and this page can return its values in two ways:

Standard Table Lookup

The standard method uses a table and a standard Xopus script that takes care of returning the values.

...

<script language="JavaScript" src="../../../../../xopus/media/lookup.js"></script>

...

<tr id="/img/xopus.gif">
  <td>Xopus</td>
  <td><img src="/img/xopus.gif"/></td>
</tr>
... 

<script language="JavaScript">
 initLookupTables();    
</script>

The three parts above are needed to make this page work. The best way to learn about this is to look at the Simple example with the Xopus download.

More attributes can be looked up at once through the use of an 'extra' element:

<tr id="/img/xopus.gif">
  <extra>
    <value name="width">44</value>
    <value name="height">65</value>
    <value name="title">Xopus logo</value>
  </extra>        
  <td>Q42</td>
  <td><img src="/img/xopus.gif" /></td>
</tr>

top.choose lookup

This method provides Xopus with the attributes directly through the use of script.

Note: It is not possible to create cross-domain lookups, as it is impossible for JavaScript from one domain to access windows or iframes therefore, on other domains.

top.choose
(
  {
    src:'/img/xopus.gif',
    width:44,
    height:65,
    title:'Xopus logo'
  }
);

The above code calls the choose function in the Xopus window, and provides the attributes directly to Xopus.