Skip to main content
summaryrefslogblamecommitdiffstats
blob: c9e5912f20eba812c40d3a814bcbf64c9baf916c (plain) (tree)



























                                                                                                                                                                                                               

                                                                                                                                                                                                          



































                                                                                                                                                                                      
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css"/>
<title>Common JET Tags</title>
</head>
<body>
<h2>Common JET Tags</h2>
<p>JET includes four <b>tag libraries</b>, which are collections of related tags. These are:
<ul>
  <li> Control tags - used for accessing the input model, and controlling template execution.</li>
  <li> Format tags - used to alter (format) text in templates according to certain rules. </li>
  <li> Java tags - special tags useful to generating Java code.</li>
  <li> Workspace tags - used for creating workspace resources, such as files, folders and projects.</li>
</ul>
</p>
<p>Although there are many tags available, only a few are needed to get started. 
These tags are either control or workspace tags</p>
<h3>Most common control tags</h3>
<p>Control tags usually access the input model, and either produce a value, or cause an action based on the information
extracted from the input model. The control tags access the input model via <b>XPath expressions</b>. 
(See <a href="essentialXPath.xhtml">Essential XPath</a>).
Three control tags are used frequently:
<ul>
  <li> <code><a href="../references/taglibs/controlTags/getTag.html">c:get</a></code> - Write a value from the input model into the expanded template.</li>
  <li> <code><a href="../references/taglibs/controlTags/iterateTag.html">c:iterate</a></code> - Traverse elements in the input model and evaluate the contained template text once for each element. </li>
  <li> <code><a href="../references/taglibs/controlTags/setTag.html">c:set</a></code> - create or set an attribute on a model element. This is frequently used to store the result of a calculation. </li>
</ul>

</p>
<h3>Most common workspace tags</h3>
<p>Three workspace tags are used frequently:
<ul>
  <li> <code><a href="../references/taglibs/workspaceTags/fileTag.html">ws:file</a></code> - Write a workspace file, settings its contents to the result of expanding a template.</li>
  <li> <code><a href="../references/taglibs/workspaceTags/folderTag.html">ws:folder</a></code> - Create a workspace folder. </li>
  <li> <code><a href="../references/taglibs/workspaceTags/projectTag.html">ws:project</a></code> - Create a workspace project. </li>
</ul>
</p>
<h3>Accessing model elements within tag attributes</h3>
<p>Frequently, templates must use a model value in a tag's attribute. For example, the name of a generated file
might depend on a value from the input model. To do this, the <code>main.jet</code> template would require a <code>ws:file</code> that looks like:
<br/><br/>
<samp>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;ws:file template="..." path="... value from the model..."/&gt;
</samp>
<br/><br/>
Because JET does not permit one XML tag to be embedded in an attribute value of another, JET provides 
<b>Dynamic XPath Expressions</b>, which can be used only in tag attribute values. The format of a dynamic
XPath expression is:
<br/><br/>
<samp>
&nbsp;&nbsp;&nbsp;&nbsp;{<i>XPath expression</i>}
</samp>
<br/><br/>
So, the <code>ws:file</code> tag above would be written as:
<br/><br/>
<samp>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;ws:file template="..." path="{<i>XPath expression</i>}"/&gt;
</samp>
<br/><br/>
</p>
</body>
</html>

Back to the top