<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!--
Copyright (c) 2006 UGS Corp.

All Rights Reserved.

This software and related documentation are proprietary to UGS Corp.
-->
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Creating a Template File</title>
      <script language="javaScript">
        abridged="false";
        displayConditions=new Array();
      </script>
      <link type="text/css" href="../css/main_styles.css" rel="stylesheet">
   </head>
   <body class="bodydocs" onload="top.pageLoader()" bgcolor="#FFFFFF">
      <div class="title_topic4" id="xps10_pagetitle">Creating a Template File</div>
      <hr noshade="true">
      <p class="para_topic">Creating the template is a programming task that includes constructing commands, creating an HTML format, and designing the operations for the template. </p>
      <div class="title_division">More About the Template File Commands</div>
      <p class="para_division">The template is an HTML file that contains both regular HTML tags and special NX extended tags, or embedded commands, that perform NX functions. When Author HTML processes the template file, it passes the regular HTML tags through to the output file. It processes each NX embedded command and replaces it with data from the NX part.</p>
      <div class="title_division">Viewing the Template During Development</div>
      <p class="para_division">As you are developing the template, you can view it with a standard browser or viewer. Your browser or viewer will ignore the NX embedded commands. However, since much of the final data that will appear in the output file will be generated by Author HTML, viewing the template with a browser may be confusing.</p>
      <div class="title_division">Basic Template Syntax</div>
      <p class="para_division">The basic format of an NX embedded command is:</p>
      <p class="para_division">&lt;@OP Keyword=value&gt;</p>
      <p class="para_division">This breaks down as follows:</p>
      <table cellspacing="3" width="100%" align="center">
         <tr>
            <th bgcolor="#c0c0c0" colspan="1" rowspan="1" valign="top">
               <p class="para_th">Syntax Element</p>
            </th>
            <th bgcolor="#c0c0c0" colspan="1" rowspan="1" valign="top">
               <p class="para_th">Description</p>
            </th>
         </tr>
         <tr>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">&lt;@</p>
            </td>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">Prefix string for an NX embedded command.</p>
            </td>
         </tr>
         <tr>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">OP</p>
            </td>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">The name of a command. Examples of commands could be UGSHADE, UGVRML, UGPARTINFO, etc.</p>
            </td>
         </tr>
         <tr>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">Keyword=value</p>
            </td>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">Parameter to the embedded command, used to provide additional information. Names and values may be different for each possible embedded command.</p>
            </td>
         </tr>
      </table><br><table border="0">
         <tr>
            <td valign="top" align="left"><img align="left" src="../graphics/note.gif" alt="Note" title="Note"></td>
            <td valign="bottom" align="left" width="100%">
               <div class="para_note">
                  <p class="para_note_body">  The Web Express filename commands are platform-dependent. On Windows, filename specifications must use back slashes (\). On Unix, filename specifications must use forward slashes (/).</p>
               </div>
            </td>
         </tr>
      </table>
      <div class="title_division">Example</div>
      <p class="para_division">Here is an example of an NX embedded command:</p>
      <p class="para_division">  &lt;@UGATTRIBUTE NAME=&quot;*&quot; TITLE=&quot;SERVER&quot;&gt;</p>
      <p class="para_division">This particular embedded command uses the @UGATTRIBUTE command with the following syntax to get an attribute value from the part.</p>
      <table cellspacing="3" width="100%" align="center">
         <tr>
            <th bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_th">Syntax Element</p>
            </th>
            <th bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_th">Description</p>
            </th>
         </tr>
         <tr>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">&lt;@UGATTRIBUTE</p>
            </td>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">Key sequence and command name</p>
            </td>
         </tr>
         <tr>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">NAME=&quot;&quot;</p>
            </td>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">Entity name where the attribute is attached</p>
            </td>
         </tr>
         <tr>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">TITLE=&quot;&quot;</p>
            </td>
            <td bgcolor="#f4f4f4" colspan="1" rowspan="1" valign="top">
               <p class="para_td">Specifies the title of the attribute to fetch</p>
            </td>
         </tr>
      </table><br><p class="para_division">Given this example, the output HTML file might contain the string &quot;http://www.ugs.com/&quot; as a replacement for the embedded command. This shows the basic idea for how embedded commands are implemented.</p>
      <div class="title_division">Example Using the &lt;@UGPARTINFO...&gt; Function</div>
      <p class="para_division">For a more detailed example we will examine the &lt;@UGPARTINFO...&gt; function. The &lt;@UGPARTINFO ...&gt; function is designed to return the names of all of the components used in an assembly (not the tree, but all unique components). The basic command is:</p>
      <p class="para_division">&lt;@UGPARTINFO&gt; returns the names of all components.</p>
      <p class="para_division">To format the names returned by this command into HTML you use a keyword=value pair. In this case the keyword is FORMAT. The FORMAT=&quot;&quot; keyword provides HTML formatting structure to the returned values of the embedded function. For example, to place the part list into a bullet list on the HTML page you could use the following NX embedded command in the template file:</p>
      <p class="para_division">&lt;ul&gt; &lt;@UGPARTINFO FORMAT=&quot;&lt;li&gt;$name\n&quot;&gt; &lt;/ul&gt;</p>
      <div class="title_division">Output of &lt;@UGPARTINFO...&gt; Function</div>
      <p class="para_division">Placing this command in a template file and specifying it with Select Template could generate the following output in the HTML file:</p>
      <ul>
         <li>
            <p class="para_item">  part1.prt</p>
         </li>
         <li>
            <p class="para_item">  part2.prt</p>
         </li>
         <li>
            <p class="para_item">  part3.prt</p>
         </li>
      </ul>
      <p class="para_division">The FORMAT keyword provides formatting information that is applied to each returned value from the function. In the case of the part list, it is applied once for every component part. A function has a defined list of returned values or parameters that can be referenced in the output. The parameters of the function are generally referenced by putting a dollar sign ($) followed by a parameter name in the FORMAT statement (i.e., $title). Parameters can include alphabetic characters, the underscore and parenthesis. For clarity, parameters can be delimited with curly braces (i.e., ${title}). In the above example, $name is used to place the parameter value for the name of a part in the output string.</p>
      <p class="para_division">The FORMAT statement has a default value that varies with the command. The list parameters can be extended to include anything that can be returned for a given command, allowing extensibility in the future without problems of backward compatibility.</p>
      <p class="para_division">The &lt;@UGATTRIBUTE ...&gt; command also has a FORMAT keyword, and parameters for output (FORMAT=&quot;$value&quot;).</p>
      <div class="title_division">Using Wildcards</div>
      <p class="para_division">Some of the keyword and value pairs accept wildcards. Wildcards are supported for the TITLE, NAME fields in those commands that have those keywords. The wildcard function allows the use of the asterisk (*) to represent any set of characters. For example, to get all strings that start with &quot;SH&quot;, use the wildcard &quot;SH*&quot;. To get strings that start with &quot;SH&quot; and end in a &quot;W&quot;, use &quot;SH*W&quot;. Multiple &quot;*&quot; characters can be used in a wildcard. Wildcard processing is presently case insensitive.</p>
      <div class="title_division">Example</div>
      <p class="para_division">The following example uses the ATTRIBUTE command.</p>
      <p class="para_division"> &lt;ul&gt;   &lt;@UGATTRIBUTE NAME=&quot;CURVE1&quot; TITLE=&quot;*&quot; FORMAT=&quot;&lt;li&gt;$TITLE = $VALUE\n&quot;&gt;  &lt;/ul&gt;</p>
      <p class="para_division">The FORMAT statement shown above is putting the attribute title (the $title parameter) and value of the attribute (the $value parameter) into a list with an equal sign between values. Since the TITLE field is a wildcard, the format statement is applied to each attribute.</p>
      <div class="title_division">Output</div>
      <p class="para_division">The output might look something like this:</p>
      <p class="para_division">  * SERVER = http://www.ugswest.com</p>
      <p class="para_division">  * TARGET_DIRECTORY = this/that/other/</p>
      <p class="para_division">  * PAGE_NAME = part.html</p>
      <div class="title_division">Adding Complexity</div>
      <p class="para_division">You could add more complexity, where both the NAME and the TITLE are wildcards:</p>
      <p class="para_division"> &lt;ul&gt;   &lt;@UGATTRIBUTE NAME=&quot;*&quot; TITLE=&quot;*&quot; FORMAT=&quot;&lt;li&gt;$title = $value\n&quot;     HEADER=&quot;&lt;li&gt; $name\n &lt;ul&gt;\n&quot; FOOTER=&quot;&lt;/ul&gt;\n&quot;&gt;  &lt;/ul&gt;</p>
      <p class="para_division">This time the UGATTRIBUTE command is using a HEADER and a FOOTER keyword/value pair, allowing for two nested loops.</p>
      <div class="title_division">Pseudo Code</div>
      <p class="para_division">A little pseudo code can clarify what is going on:</p>
      <p class="para_division"> for ( name = first_match to last_match )   {   output( HEADER )   for ( title = first_match to last_match )   {   output( FORMAT )   }   output( FOOTER )   }</p>
      <div class="title_division">Output</div>
      <p class="para_division">The output from this embedded command might look like the following:</p>
      <p class="para_division">  * OBJECT1</p>
      <p class="para_division">  o ATTR1 = value1   o ATTR2 = value2</p>
      <p class="para_division">  * OBJECT2</p>
      <p class="para_division">  o ATTR3 = value3   o ATTR4 = value4</p>
      <p class="para_division">The result is a nested list of objects with their attached attributes and values.</p>
      <div class="title_division">Nesting Commands</div>
      <p class="para_division">Another feature of the embedded command interface is that the commands can be recursive, where a given command can contain another command. That can be most useful in the FORMAT keyword.</p>
      <div class="title_division">Example</div>
      <p class="para_division">For example:</p>
      <p class="para_division">&lt;@UGFILE NAME=&quot;&lt;@UGVAR&gt;/&lt;@UGPARTINFO NAME=&quot;WORK&quot;&gt;.html&quot; MODE=&quot;WRITE&quot;&gt; &lt;HTML&gt; &lt;head&gt;&lt;title=&quot;ThePage&quot;&gt;&lt;/head&gt; &lt;body&gt; &lt;li&gt; &lt;A href= &lt;@UGATTRIBUTE NAME=&quot;*&quot; TITLE=&quot;SERVER&quot; FORMAT=&quot;'$value/index.shtml'&quot;&gt; &lt;@UGPARTINFO FORMAT=&quot;\&gt;$name&quot;&gt; &lt;/A&gt;</p>
      <p class="para_division">The command above contains a link, and the value that the link will point to is obtained from a part attribute. You might build up a href (hypertext reference) from attributes like the server name and the target directory along with the part name. </p>
      <div class="title_division">Output</div>
      <p class="para_division">Sample output from the command might look like the following:</p>
      <p class="para_division">&lt;li&gt;&lt;A href=&quot;http://www.ugs.com/part.html&gt; part.prt &lt;/A&gt;</p>
      <p class="para_division">&lt;li&gt;&lt;A href=&quot;http://www.ugs.com/part1.html&gt; part1.prt &lt;/A&gt;</p>
   </body>
</html>