Data Action plugin.xml File Resources Section - tns:resources

The tns:resources section registers all of the files that contribute to your extension.

Resources


1 <tns:resources>
2    <tns:resource id="currencyconversion" path="scripts/currencyconversion.js" type="script" optimizedGroup="base"/>
3    <tns:resource-folder id="nls" path="resources/nls" optimizable="true">
4       <tns:extensions>
5          <tns:extension name="js" resource-type="script"/>
6       </tns:extensions>
7    </tns:resource-folder>
8 </tns:resources>

You need to register each JavaScript, CSS, Image, and Translation Resource File here. The section is contained within the <tns:resources> element and contains any number of the following elements:

  • <tns:resource>

    These elements are used to register a single file (for example, a JavaScript or CSS file).

  • <tns:resource-folder>

    These elements are used to register all the files under a specified folder at the same time. For example, an image folder or the folder containing the resource files for Native Language Support.

More information on how to register each type of file is provided in the following sections.

JavaScript Files

Each JavaScript file in your extension must be registered with a line similar to the one shown below.

<tns:resource id="currencyconversion" path="scripts/currencyconversion.js" type="script" optimizedGroup="base"/>

Where:

  • id is the ID given to the file.

    Set the ID to match the JavaScript filename without the .js extension.

  • path is the relative path to the JavaScript file from the plugin.xml file. JavaScript files should be stored under your extension's scripts directory.

    Use all lowercase for your JavaScript files with no special characters (for example, underscore, hyphen).

  • type is the type of file being registered. It must be set to script for JavaScript files.
  • optimizedGroup groups multiple JavaScript files into a single compressed file. Third-party extensions must leave this set to base.

CSS Files

Each CSS file in your extension must be registered with a line similar to the one shown below.

<tns:resource id="currencyconversionstyles" path="resources/currencyconversion.css" type="css"/>

Where:

  • id is the ID given to the file.

    Set the ID to match the CSS filename without the .css extension.

  • path is the relative path to the CSS file from the plugin.xml file. CSS files should be stored under your extension's resources directory.

    Use all lowercase for your CSS files with no special characters (for example, underscore, hyphen).

  • type is the type of file being registered. It should always be set to css for CSS files.

Image Folders

If your extension has images that you need to refer to from within your JavaScript code, then put them in a resources/images directory within your extension's directory structure and add a <tns:resource-folder> element to your plugin.xml as follows:

<tns:resource-folder id="images" path="resources/images" optimizable="false"/>

If your images are only referenced by your CSS files, then you don't need to add this <tns:resource-folder> element to your plugin.xml file. In this case, you must still add them to the resources/images directory so that you can then refer to them using a relative path from your CSS file.

Native Language Support Resource Folders

Oracle Analytics implements Native Language Support. This requires developers to externalize the strings they display in their user interface into separate JSON resource files. You can then provide different localized versions of those files in a prescribed directory structure and Oracle Analytics automatically uses the correct file for the user's chosen language. You can provide as many translated versions of the resource files as needed. A Native Language Support resource folder points Oracle Analytics to the root of the prescribed Native Language Support directory structure used by your extension. All extensions that use Native Language Support resource files must have a <tns:resource-folder> entry that looks exactly like the example below.


1 <tns:resource-folder id="nls" path="resources/nls" optimizable="true">
2    <tns:extensions>
3       <tns:extension name="js" resource-type="script"/>
4    </tns:extensions>
5 </tns:resource-folder>

See Generated Folders and Files for details about the contents of the files and the prescribed directory structure that you should follow.