lookup
A lookup element can be used to specify an external source of values for an attribute. The source can be any html document. The document will be opened by Xopus when a value for the attribute can be specified. The html document can return its value using script.
Example
<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>
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.
You can use $xml and $xsd in the lookup-url, they will be replaced by xopus with the current documents xml and xsd URI. This will allow you to acces both in your lookup window.
Example
<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://www.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 attribuut that is being looked up)
-
value (the current value)
-
node (the node that represents the attribute)
-
canvas (the canvas element)
The id attributes on the table-data elementes 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 media/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 Xopus. Here an HTML element is passed to the function.
Example
//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 Xopus 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.
"top.choose(results);" is very important here as it signals the top window to choose something.
Warning
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.
Elements and Attributes
Parent Elements
| Element | Description |
|---|---|
| lookupConfig |
The |
Child Elements
None
Attributes
| Attribute | Use | Description |
|---|---|---|
| parentPattern | Required |
The |
| name | Required | |
| url | Required |
The url attribute specifies the page to load in the lookup dialog. |
| forceLookup | Optional |
If the forceLookup attribute is set, users can not edit the attribute for which the lookup dialog was specified manually using the attribute editor. The input field will be disabled in the attribute editor. |
| autoOpen | Optional |
The |
- Support /
- Documentation /
- Developer Guide /
- Reference /
- Xopus Local Configuration /
- Elements /
- lookup
Related Topics
| Title | Description |
|---|---|
| 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. |
| Upgrade from Xopus 2 to 3 |
Xopus 3 is not backward compatible with Xopus 2. So in order to upgrade to Xopus 3, the Xopus integration needs to be upgraded as well. This document explains the steps you need to take to upgrade your Xopus 2 integration. |
| autoOpen |
The |
| forceLookup |
If the forceLookup attribute is set, users can not edit the attribute for which the lookup dialog was specified manually using the attribute editor. The input field will be disabled in the attribute editor. |
| name (3) |
Specifies the qualified name of the attribute for which the value will be looked up using a lookup dialog. |
| parentPattern |
The |
| url |
The url attribute specifies the page to load in the lookup dialog. |
| lookupConfig |
The |