Working with XML templates

XML content assist provides a comment template, a chunk of predefined code that you can insert into a file. You can use the default template as provided, customize that template, or create your own templates.

For example, you may work on a group of XML pages that should all contain a table with a specific appearance. Create a template that contains the tags for that table, including the appropriate attributes and attribute values for each tag. (You can copy and paste the tags from a structured text editor into the template's Pattern field.) Then select the name of the template from a content assist proposal list whenever you want to insert your custom table into an XML file.

To create a new XML template follow these steps:

  1. Click Window > Preferences > Web and XML > XML Files > XML Templates.
  2. Click New if you want to create a completely new template.
  3. Supply a new template name and description
  4. Specify the Context for the template. This is the content in which the template is available in the proposal list when content assist is requested.
  5. Specify the Pattern for your template using the appropriate tags, attributes, or attribute values to be inserted by contente assit.
  6. If you want to insert a variable, click the Variable button and select the variable to be inserted. For example, the word_selection variable indicates the word that is selected at the beginning of template insertion, and the cursor variable determines where the cursor will be after the template is inserted in the HTML document
  7. Click Apply and then OK to save your changes.
You can edit, remove, import, or export a template by using the same Preferences page. If you have modified a default template, you can restore it to its default value. You can also restore a removed template if you have not exited from the workbench since it was removed.

If you have a template that you do not want to remove but you no longer want the template to appear in the content assist list, go to the Templates preferences page and templates its check box.

(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.