template.xml Reference

A Workshop template defines a set of files and/or code to be used to check the contents of or add content to a Workshop application or project.

At startup, Workshop loads its set of templates from the 'templates' directory below the Workshop root directory (BEA_HOME/weblogic81/workshop/templates). Templates are defined in zip files. Each zip file containing templates must include a template.xml file at the root level of the zip file.

A template.xml file may contain any number of project or application template definitions. A template definition may optionally include display information indicating where and how the template will be displayed to the user. All templates, regardless of whether they contain display information, may be accessed programmatically by extension writers, or be extended or referenced by other template definitions.

Templates can be displayed to the user in the following locations:

Application Templates

Project Templates

Templates displayed in application tree context menus will appear in the Install submenu.

template.xml File Elements

<template-definition>
    <project-template>
        <display>
        <content>
    <application-template>
        <display>
        <content>
        <project-template-ref>

<template-definition> Element

The top-level element for application and project templates. The <template-definition> element can contain any number of <project-template> and <application-template> elements.

<template-definition>
        <project-template>
        <application-template>

Syntax

<template-definition>
    <!-- Children <project-template> and <application-template> elements. -->
</template-definition>

Hierarchy

Parents: None.

Children: <project-template>, <application-template>.

Related Topics

None.

<project-template> Element

A project template defines a set of content for populating a single new or existing project of a specific project type. A project template can also use a custom template processor class located in an extension jar to call the IDE extension API, examine and update configuration files, query the user for input, or control the addition of content to a source directory.

Project template definitions may be displayed in the New Project Dialog, Import Project Dialog, or in the application tree project-context menu under Install. They may also be extended by other project templates and referenced by application templates.

A project template is used by an IProjectTemplateProcessor to examine, configure or populate a project instance. IProjectTemplateProcessor has two methods: check() which determines if the project conforms to the template, and
load() which configures or adds content to the project. A custom IProjectTemplateProcessor implementation may be specified in the template definition; otherwise the default Workshop implementation will be used.

Project templates may extend other project templates. See the extends attribute below.

<template-definition>
    <project-template>
        <display>
        <content>

Syntax

<project-template
    type="projectType"
    id="projectID"
    [extends="extendedProjectID"]
    [processor="IProjectTemplateProcessor"]
    [default-name="defName"]
>

Attributes

Attribute Description
type Required string. Identifies the type of project that will be created. Project types are defined in extension.xml and define how the project builds, deploys and runs, as well as how this template will be processed. See the table below for possible values.
id Required string. Uniquely identifies this template among all templates defined for its project type. Note that this id does not have to be unique among all project templates.

extends

Optional string. Points to the id of a project template of the same type that this template extends. If this attribute is set, then uninitialized, non-required attributes will be set to values from the extended template. Category lists will always be inherited. Content from the extended template will be included in this template, but display information will not be inherited.

processor Optional string. Class name of an IProjectTemplateProcessor implementation. This class will be instantiated when extension code calls IProjectTemplate.createProcessor(). If this attribute is omitted, then a default processor implementation will be created.
default-name Optional string. The name that will be used for the project if one is not provided by the user.

Hierarchy

Parents: <template-definition>.

Children: <display>, <content>.

Related Topics

None.

<display> Element

Specifies the display options for the New Project dialog.

<template-definition>
    <project-template>
        <display>

Syntax

<display
    location=" newdialog | importdialog | contextmenu "
    label="projLabel"
    [icon="imageName"]
    [description="projDescription"]
    [priority="menuLocationInteger"]
    [categories="projCategory1, projCategory2, ..."]
>

Attributes

Attribute Description

location

Required string. Comma separated list of display location identifiers.
Workshop-defined values:
newdialog - the New Project dialog
importdialog - the Import Project dialog
contextmenu - the project context menu

label Required string. Label that will be displayed in the New Project dialogs.
icon Optional string. Icon that will be displayed for this template. All project types will specify a default icon which will be used if this attribute is omitted. The value of this attribute may be a GIF file in the template ZIP file, or it may be a resource in an extension JAR file.
description Optional string. Description of this template that will be displayed in the Project dialogs.
priority

Optional integer. Used to order the templates displayed in the dialog template list, higher values being displayed before lower values.

categories Optional string. Comma separated list of template category names.

Hierarchy

Parents: <project-template>.

Children: none.

Related Topics

None.

<content> Element

Specifies a menu item.

<template-definition>
    <project-template>
        <content>

Syntax

<content
    type=" archive | file "     destination=" project | libraries | modules "     source="sourceFileOrZIP"
    [overwrite=" true | false "] >

Attributes

Attribute Description

type

Required string. Indicates how the source file should be processed.
Values supported by the default template processor:
archive - a zip file
file - a file

destination Required string. Where the content will be placed.
Values supported by the default template processor:
project - the root of the project directory
libraries - the application Libraries directory
modules - the application Modules directory
source Required string. The content source file; when opening as a stream, will first look in the template ZIP file, then it try to open the content as a resource.
overwrite Optional boolean. Specifies the behavior if same files already exist in the application directories. If this attribute is omitted, the value is false. The default template processor will immediately quit processing this content element if overwrite is false and a collision occurs.

Hierarchy

Parents: <project-template>.

Children: none.

Related Topics

None.

<application-template> Element

An application template defines a set of content for populating a new or existing Workshop application. An application template can also use a custom template processor class located in an extension jar to call the IDE extension API, examine and update configuration files, query the user for input, or control the addition of content to the application directory.

Application template definitions may be displayed in the New Application Dialog, or in the application tree root context menu under Install. They may also be extended by other application templates and referenced by application templates.

Application templates may also contain any number of content elements, however these content members may only contain application-level data: data in the Libraries, Modules folders, etc. Project content must be specified in a project template.
Project templates may be referenced, or they may be completely defined inside the application template. Project templates defined inside the application template will not appear in the New Project and Add Project dialog and may only be used
when creating this application.

<template-definition>
    <application-template>
        <display>
        <content>
        <project-template-ref>

Syntax

<application-template
    id="uniqueID"     extends="extendedAppID"
    processor="processorClass"
>

Attributes

Attribute Description
id Required string. Uniquely identifies this application template among all application templates defined in this template zip file. Note that this id does not have to be unique among all application templates loaded by Workshop.
extends Optional string. Points to the id of another application template which the current template extends. Content from extended template will be included in the extending template.

processor

Optional string. If no processor is specified, the default processor will be used: IProjectTemplateProcessor.

Hierarchy

Parents: <template-definition>.

Children: <display>, <content>, <project-template-ref>.

Related Topics

None.

<display> Element

The display element specifies display information to be used when displaying this template at a given location or locations.
An application template may contain any number of display elements, each specifying one or more display locations.

<template-definition>
    <application-template>
        <display>

Syntax

<display
    location=" newdialog | contextmenu "
    label="appLabel"
    [icon="imageName"]
    [description="appDescription"]
    [priority="menuLocationInteger"]
    [categories="appCategory1, appCategory2, ..."]
>

Attributes

Attribute Description

location

Required string. Comma separated list of display location identifiers.
Workshop-defined values:
newdialog - the New Application dialog
contextmenu - the project context menu

label Required string. Label that will be displayed in the New Application dialog.
icon Optional string. Icon that will be displayed for this template. A default application template icon is provided by Workshop
if this attribute is omitted. The value of this attribute may be a GIF file in the template ZIP file, or it may be a resource in an extension JAR.
description Optional string. Description of this template that will be displayed in the New Application dialog.
priority

Optional integer. Used to order the templates displayed in the dialog template list, higher values being displayed before lower values.

categories Optional string. Comma separated list of template category names.

Hierarchy

Parents: <application-template>.

Children: none.

Related Topics

None.

<content> Element

Specifies a unit of content to be loaded when the the application is created.

<template-definition>
    <application-template>
        <content>

Syntax

<content
    type=" archive | file"     destination=" libraries | modules "     source="sourceFileOrZIP"
    [overwrite=" true | false "]
>

Attributes

Attribute Description

type

Required string. Indicates how the source file should be processed.
Values supported by the default template processor:
archive - a zip file
file - a file

destination Required string. Specifies where the content will be placed.
Values supported by the default template processor:
libraries - the application Libraries directory
modules - the application Modules directory
source Required string. The content source file; when opening as a stream, will first look in the template ZIP file, then it try to open the content as a resource.
overwrite Optional. Specifies the behavior if same files already exist in the application directories. If this attribute is omitted, the value is false. The default template processor will immediately quit processing this content element if overwrite is false and a collision occurs.

Hierarchy

Parents: <application-template>.

Children: none.

Related Topics

None.

<project-template-ref> Element

A reference to an externally defined project template. The referenced project template may be defined in the current template ZIP file, or any other template ZIP file in the /template directory. The project type id and template id are used to find the referenced project template. The referenced project template will be used to create a project with the name given and the content defined by the project template.

<template-definition>
    <application-template>
        <project-template-ref>

Syntax

<project-template-ref
    default-name="name"
    type="projType"
    template="projTemplateID"
>

Attributes

Attribute Description

default-name

Required string. The name that will be used for the created project.

type Required string. A project type id. See the table below for possible values.
template Required string. A project template id.

Hierarchy

Parents: <application-template>.

Children: none.

Related Topics

None.

WebLogic Workshop Project Types

Type

Description

urn:com-bea-ide:project.type:Datasync Datasync projects contain server data including campaigns, content, placeholders, content selectors, user segments, and property sets.
urn:com-bea-ide:project.type:Control Control projects are used to create Java controls and packaging them as JAR files.
urn:com-bea-ide:project.type:WebApp WebApp projects can contain web applications, web services, and business processes.
urn:com-bea-ide:project.type:EJB EJB projects are used to create EJBs and packaging them as JAR files.
urn:com-bea-ide:project.type:PortalWebApp A WebApp project that also enables Portals. This should only be added to an portal enabled application.
urn:com-bea-ide:project.type:Java A project for developing Java applications.
urn:com-bea-ide:project.type:Schema This project stores XSD files and compiles them into XMLBean classes.

Example

The following is an annotated example of a template.xml file.

<template-definition>

<!-- This a Web project template and extends the 'default' Web project template. -->
    <project-template id="_example_proj1_"
            type="urn:com-bea-ide:project.type:WebApp"
            extends="default"
            processor="workshop.workspace.project.TestTemplateProcessor">
        <!-- Defines where and how this template will be displayed to the Workshop user. -->
        <display 
            location="newdialog,importdialog" 
            label="_Example Project_"
            description="This project template demonstrates the Workshop template syntax, and extends the default web project template. See {wlw_install_dir}/templates/example-template.zip."
            icon="exampleProject.gif"
            priority="0"
            categories="_Example_" />
        <!-- zip to be extracted at the root of the project directory -->
        <content type="archive" destination="project" source="default-project.zip"/>
        <!-- file to be put in the libraries directory -->
        <content type="file" destination="libraries" source="CreditScoreBean.jar" overwrite="true"/>
        <!-- file to be put in the modules directory -->
        <content type="file" destination="modules" source="CreditScoreEJB.jar" overwrite="true"/>
    </project-template>

    <!-- This a Web project template that will appear in the Application tree's Install context menu 
         when the user right-clicks on a Web project folder. 
         Note that this template uses a custom template processor implementation.  This class could
         query the user for input, examine and update existing configuration files, and control how
         content elements are added to the project. -->
    <project-template id="_example_proj1_installmenu_"
            type="urn:com-bea-ide:project.type:WebApp"
            processor="workshop.workspace.project.InstallTemplateProcessor">
        <!-- Defines where and how this template will be displayed to the Workshop user. -->
        <display 
            location="contextmenu" 
            label="_Add Project Resources_"
            description="This project template demonstrates the Workshop template syntax, and extends the default web project template. See {wlw_install_dir}/templates/example-template.zip."
            icon="exampleProject.gif"
            categories="_Example_" />
        <!-- zip to be extracted at the root of the project directory -->
        <content type="archive" destination="project" source="ui_resouces.zip"/>
    </project-template>

<application-template id="_example_app1_">
        <display
            location="newdialog"
            icon="exampleApp.gif"
            label="_Example Application 1_"
            description="This application template demonstrates the Workshop template syntax. See {wlw_install_dir}/templates/example-template.zip."
            priority="1"
            categories="_Example_" />
        <!-- zip to be extracted in the libraries directory -->
        <content type="archive" destination="libraries" source="libraries.zip"/>
        <!-- file to be put in the modules directory -->
        <content type="file" destination="modules" source="testEJB.jar"/>
        <!-- references a project template defined in another template zip file -->
        <project-template-ref default-name="_StandardControl_" type="Control" template="default"/>
        <!-- references a project template defined above -->
        <project-template-ref default-name="_ExampleWebApp_" type="urn:com-bea-ide:project.type:WebApp" template="_example_proj1_"/>
        <!-- project template only used in this application template -->
        <project-template default-name="_ExampleJava_" 
                id="_example_app1_proj1_"
                type="Java">
            <content type="file" destination="project" source="Example.java"/>
        </project-template>
    </application-template>

    <!--
        This application template extends an application template defined in this
        template zip.  Currently we only support extending app templates defined
        in the same template zip.
      -->
    <application-template id="_example_app2_"
            extends="_example_app1_">
        <display
            location="contextmenu"
            label="_Example Application Content_" />
        <!-- A project template only used in this application template.
             Extends the default control project -->
        <project-template default-name="_ExampleControl_" 
                id="_example_app2_proj1_"
                type="Control"
                extends="default">
            <content type="file" destination="project" source="Example.java"/>
        </project-template>
    </application-template>

</template-definition>

Related Topics

Application and Project Templates

IProjectTemplateProcessor