lookup
This topic describes the lookup element.
Description
A <lookup> element can be used to specify an external source of values for attributes or elements. The source can be any HTML document. The document will be opened by SDL LiveContent Create when a value for the attribute can be specified. The HTML document can return its value using script.
<x:config version="1.0" xmlns:x="http://www.xopus.com/xmlns/config">
<x:lookupConfig>
<x:lookup
parentPattern="self::picture"
name="source"
url="lookup/image/index.html"
forceLookup="true"
autoOpen="true"/>
<x:lookup
parentPattern="self::a"
name="href"
url="lookup/link/index.html"
forceLookup="false"
autoOpen="true"/>
</x:lookupConfig>
</x:config
Or, with nodeConfig:
<x:node match="a/@href">
<x:lookup
url="lookup/link/index.html"
forceLookup="true"
autoOpen="true"/>
</x:node>
There are two ways to use this. You can create a simple lookup, following the example below. This includes the script media/lookup.js which uses the table structure below it to look up the value. Or you can write your own thing on the API.
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../../../../xopus/media/lookup.css" />
<script language="JavaScript" src="../../../../../xopus/media/lookup.js"></script>
</head>
<body>
<h1 selectable="true">
<script language="JavaScript">
document.writeln(top.dialogArguments.title);
</script>
</h1>
<table class="xopus-lookup" border="0" cellspacing="0" cellpadding="0" align="center">
<tr id="http://www.q42.nl">
<td>1. Q42</td>
<td>http://www.q42.nl</td>
</tr>
<tr id="http://xopus.com">
<td>2. Xopus</td>
<td>http://www.xopus.com</td>
</tr>
etc...
</table>
<script language="JavaScript">
initLookupTables();
</script>
</body>
</html>
The dialog is passed a number of arguments through dialogArguments:
name(the name of the attribute that is being looked up)value(the current value)node(the node that represents the attribute)canvas(the canvas element)attributes
The id attributes on the table-data elements are the values that will be passed back to the script. You can create your own table of values. At the end of the example is the line initLookupTables() which initiates the table as something clickable.
The other way to use this, is to create an HTML page of your own, and to construct the JavaScript yourself. You can find the following in js/lookup.js, and this shows you what happens. What is important here is the results object, the names and values that are set on it, and the call to top.choose(results) where the results object is passed back to SDL LiveContent Create . Here an HTML element is passed to the function.
//Construct name/value pairs to send
var results = {};
//set the property on the object and give it its value.
results[window.dialogArguments.name] = el.id;
// Get value elements
var valueEls = el.getElementsByTagName('value');
for (var i=0; i<valueEls.length; i++)
{
var valueEl = valueEls[i];
//add to results
results[valueEl.name] = valueEl.innerHTML;
}
top.choose(results);
As you can see, top.choose(results) is called. The results object var is passed to SDL LiveContent Create and set on the element indicated in the lookup. You can re-write the HTML lookup page and the script above any way you like as long as you pass a similar results object to top.choose in the end.
The line top.choose(results); is very important here as it signals the top window to choose something.
Namespace
http://www.xopus.com/xmlns/config
Attributes
| Name | Description and use | Type |
|---|---|---|
url | Specify the page on the server to load in the lookup dialog. | |
forceLookup | Optional. When | Boolean |
autoOpen | Optional. When set to | Boolean |
parentPattern | Only applies to
The owner element of the lookup attribute. parentPattern contains an XPath query, using the owner element as context.
| |
name | Only applies to Name of the lookup attribute. | string |
Parent Element
node
lookupConfig
History
| Version | Event |
|---|---|
| SDL LiveContent Create 5.0 | Introduction |