javascript

The <javascript/> element points to a javascript file that is executed when Xopus activates an Xopus Canvas. The script is executed after the configuration is loaded but before any associated files are loaded. The script has access to the Xopus API.

Example

<config version="1.0" xmlns="http://www.xopus.com/xmlns/config">

  <import src="config.xml"/>
  <javascript src="js/blockdragger.js"/>

  <pipeline xml="xml/doc.xml" xsd="xsd/schema.xsd">
    <view id="defaultView" default="true">
      <transform xsl="xsl/presentation.xsl" />
    </view>
    <view id="Other View">
      <treeTransform/>
    </view>
  </pipeline>
</config>

Javascript loaded using a <script> element in the html can also access the Xopus API. However, the Xopus API may not be fully initialized when such a script is executed. Xopus can not signal such a script that is ready to be accessed. The only way to be sure is to detect if the Editor object is intialized yet.

Example

// Demo of polling technique needed to wait
// for the Xopus API when the <javascript/>
// element is NOT used.
function waitForXopus()
{
  if (typeof Editor == "undefined")
    setTimeout(waitForXopus, 250);
  else
    useXopusAPI();
}

function useXopusAPI()
{
  ...
}

Elements and Attributes

Parent Elements

Element Description
config

The <config/> contains the global configuration.

<config version="1.0" xmlns="http://www.xopus.com/xmlns/config"/> is the root of an Xopus Local Configuration. It specifies the uri of the xml document to be loaded, its xml schema and what xsl files should be used to render the views.

Child Elements

None

Attributes

Attribute Use Description
src Required

The src attribute refers to a file on the server.

Related Topics


Title Description
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.

Xopus API

The Xopus API allows integrators to customize Xopus. This ranges from configuring Xopus to save xml to building custom user interfaces on top of Xopus.

src

The src attribute refers to a file on the server.

Script Files

The Xopus API can be accessed in multiple ways.