<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>I *<b>think</b>* you cannot, but I thought I&#8217;d at
least show my example, as there might be a more elegant way to express this:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:10.0pt;
font-family:"Courier New";color:#7F0055'>import</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>
org.antlr.stringtemplate.*;</span><span style='font-size:10.0pt;font-family:
"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:10.0pt;
font-family:"Courier New";color:#7F0055'>public</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>class</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> STTest {</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>public</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>static</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span
style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>void</span></b><span
style='font-size:10.0pt;font-family:"Courier New";color:black'> main(String[]
args) {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringTemplateGroup
stg = </span><b><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055'>new</span></b><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> StringTemplateGroup(</span><span style='font-size:10.0pt;
font-family:"Courier New";color:#2A00FF'>&quot;Source&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stg.defineTemplate(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;reader&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;$if(name)$$Parser(node={get(\&quot;$XMLName$\&quot;).getText()})$$else$$Parser(node={get(\&quot;$XMLName$\&quot;).getAttribute()})$$endif$&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stg.defineTemplate(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;Parser&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;$parser$&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringTemplateGroup
stg2 = </span><b><span style='font-size:10.0pt;font-family:"Courier New";
color:#7F0055'>new</span></b><span style='font-size:10.0pt;font-family:"Courier New";
color:black'> StringTemplateGroup(</span><span style='font-size:10.0pt;
font-family:"Courier New";color:#2A00FF'>&quot;Class&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stg2.setSuperGroup(stg);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringTemplate
st = stg2.defineTemplate(</span><span style='font-size:10.0pt;font-family:"Courier New";
color:#2A00FF'>&quot;prop&quot;</span><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>,</span><span style='font-size:10.0pt;font-family:
"Courier New";color:#2A00FF'>&quot;$reader(parser={eval($node$)})$&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; st.setAttribute(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;name&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;fName&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; st.setAttribute(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;XMLName&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;XMLName&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringTemplate
st2 = stg2.defineTemplate(</span><span style='font-size:10.0pt;font-family:
"Courier New";color:#2A00FF'>&quot;prop&quot;</span><span style='font-size:
10.0pt;font-family:"Courier New";color:black'>,</span><span style='font-size:
10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;$reader(parser={eval2($node$)})$&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; st2.setAttribute(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;XMLName&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>&quot;XMLName2&quot;</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.</span><i><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>out</span></i><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>.println(st.toString());</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.</span><i><span
style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>out</span></i><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>.println(st2.toString());</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>}</span><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Yields an expected:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>eval(get(&quot;XMLName&quot;).getText())</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>eval2(get(&quot;XMLName2&quot;).getAttribute())<o:p></o:p></span></p>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

<p class=MsoNormal>What bothers me is the &#8220;Parser&#8221; template, which
seems trivial.&nbsp; It&#8217;s there because I needed to set a conditional &#8220;node&#8221;
variable, and the only way I could think to do it was to pass it as a parameter.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I thought about putting the &#8220;node&#8221; definition in
the st2 definition, but then I am repeating it all over the place.&nbsp; <o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Jim<o:p></o:p></p>

</div>

</body>

</html>