blob: 2a953c345b5d387db82cad7609563315520a053f [file] [log] [blame]
kpriceef160682006-08-29 18:08:31 +00001<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html lang="en-us" xml:lang="en-us">
syeshinbefd53e2005-07-27 18:16:40 +00003<head>
kpriceef160682006-08-29 18:08:31 +00004<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
kpriceb59c9f62008-04-02 21:24:37 +00005<meta name="copyright" content="Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html. Contributors: IBM Corporation - initial API and implementation" />
6<meta name="DC.rights.owner" content="(C) Copyright 2000, 2008" />
kpriceef160682006-08-29 18:08:31 +00007<meta content="public" name="security" />
8<meta content="index,follow" name="Robots" />
9<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
10<meta content="task" name="DC.Type" />
11<meta name="DC.Title" content="Working with XML templates" />
kpriceb59c9f62008-04-02 21:24:37 +000012<meta name="abstract" content="XML content assist provides a comment template, a section of predefined code that you can insert into a file. You may find a template useful when you have a certain piece of code you want to reuse several times, and you do not want to write it out every time." />
13<meta name="description" content="XML content assist provides a comment template, a section of predefined code that you can insert into a file. You may find a template useful when you have a certain piece of code you want to reuse several times, and you do not want to write it out every time." />
kprice02ec4b02008-05-14 23:26:58 +000014<meta content="templates, working with predefined XML code, XML files" name="DC.subject" />
15<meta content="templates, working with predefined XML code, XML files" name="keywords" />
kpriceef160682006-08-29 18:08:31 +000016<meta scheme="URI" name="DC.Relation" content="../topics/txedtsrc.html" />
17<meta scheme="URI" name="DC.Relation" content="../topics/twcdast.html" />
18<meta content="XHTML" name="DC.Format" />
19<meta content="twmacro" name="DC.Identifier" />
20<meta content="en-us" name="DC.Language" />
21<link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" />
syeshinbefd53e2005-07-27 18:16:40 +000022<title>Working with XML templates</title>
syeshin66078272005-09-20 16:53:38 +000023</head>
syeshinbefd53e2005-07-27 18:16:40 +000024<body id="twmacro"><a name="twmacro"><!-- --></a>
25
kpriceef160682006-08-29 18:08:31 +000026
syeshinbefd53e2005-07-27 18:16:40 +000027<h1 class="topictitle1">Working with XML templates</h1>
kpriceef160682006-08-29 18:08:31 +000028
29
30
31
kpriceb59c9f62008-04-02 21:24:37 +000032<div><p>XML content assist provides a comment template, a section of predefined
kpriceef160682006-08-29 18:08:31 +000033code that you can insert into a file. You may find a template useful when
34you have a certain piece of code you want to reuse several times, and you
35do not want to write it out every time.</p>
36
37<div class="section"><p>You can use a default template as provided, customize that template,
38or create your own templates.</p>
kpriceb59c9f62008-04-02 21:24:37 +000039<p>For example, you can work on a group of
40XML pages that should all contain a table with a specific appearance. Create
41a template that contains the tags for that table, including the appropriate
kpriceef160682006-08-29 18:08:31 +000042attributes and attribute values for each tag. (You can copy and paste the
43tags from a structured text editor into the template's <span class="uicontrol">Pattern</span> field.)
44Then select the name of the template from a content assist proposal list whenever
kpriceb59c9f62008-04-02 21:24:37 +000045you want to insert your custom table into an XML file.</p>
46<p>To create a new
47XML template, complete the following steps:</p>
syeshinbefd53e2005-07-27 18:16:40 +000048</div>
kpriceef160682006-08-29 18:08:31 +000049
50<ol>
51<li class="stepexpand"><span>Click <span class="menucascade"><span class="uicontrol">Window</span> &gt; <span class="uicontrol">Preferences</span>
kpriceb59c9f62008-04-02 21:24:37 +000052</span> and select <span class="menucascade"><span class="uicontrol">XML</span> &gt; <span class="uicontrol">XML
53Files</span> &gt; <span class="uicontrol">Templates</span></span>.</span></li>
kpriceef160682006-08-29 18:08:31 +000054
55<li class="stepexpand"><span>Click <span class="uicontrol">New</span> if you want to create a completely
syeshinbefd53e2005-07-27 18:16:40 +000056new template.</span></li>
kpriceef160682006-08-29 18:08:31 +000057
58<li class="stepexpand"><span>Supply a new template <span class="uicontrol">Name</span> and <span class="uicontrol">Description</span>.</span>
59</li>
60
61<li class="stepexpand"><span>Specify the <span class="uicontrol">Context</span> for the template.</span>
62 This is the context in which the template is available in the proposal
syeshinbefd53e2005-07-27 18:16:40 +000063list when content assist is requested. </li>
kpriceef160682006-08-29 18:08:31 +000064
65<li class="stepexpand"><span>Specify the <span class="uicontrol">Pattern</span> for your template using
syeshind0bdb8e2005-10-27 17:44:14 +000066the appropriate tags, attributes, or attribute values to be inserted by content
67assist.</span></li>
kpriceef160682006-08-29 18:08:31 +000068
69<li class="stepexpand"><span>If you want to insert a variable, click the <span class="uicontrol">Insert Variable</span> button
70and select the variable to be inserted. </span> For example, the <strong>date</strong> variable
71indicates the current date will be inserted. </li>
72
kpriceb59c9f62008-04-02 21:24:37 +000073<li class="stepexpand"><span>Click <span class="uicontrol">OK</span> and then <span class="uicontrol">Apply</span> to
syeshinbefd53e2005-07-27 18:16:40 +000074save your changes.</span></li>
kpriceef160682006-08-29 18:08:31 +000075
syeshinbefd53e2005-07-27 18:16:40 +000076</ol>
kpriceef160682006-08-29 18:08:31 +000077
78<div class="section">You can edit, remove, import, or export a template by using the same
79preferences page. If you have modified a default template, you can restore
syeshinbefd53e2005-07-27 18:16:40 +000080it to its default value. You can also restore a removed template if you have
81not exited from the workbench since it was removed. <p>If you have a template
kpriceef160682006-08-29 18:08:31 +000082that you do not want to remove but you no longer want it to appear in the
kpriceb59c9f62008-04-02 21:24:37 +000083content assist list, clear its check box in the table on the Templates preferences
84page.</p>
syeshinbefd53e2005-07-27 18:16:40 +000085</div>
kpriceef160682006-08-29 18:08:31 +000086
87</div>
88
syeshind0bdb8e2005-10-27 17:44:14 +000089<div><div class="reltasks"><strong>Related tasks</strong><br />
90<div><a href="../topics/txedtsrc.html" title="You can use the Source view to view and work with a file's source code directly.">Editing in the Source view</a></div>
91<div><a href="../topics/twcdast.html" title="You can use content assist to help you finish a tag or line of code in the Source view of the XML editor. You can also use content assist to insert templates into your XML code.">Using XML content assist</a></div>
syeshinbefd53e2005-07-27 18:16:40 +000092</div>
kpriceef160682006-08-29 18:08:31 +000093</div>
94
95</body>
syeshinbefd53e2005-07-27 18:16:40 +000096</html>