[prev in list] [next in list] [prev in thread] [next in thread] 

List:       stringtemplate-interest
Subject:    [stringtemplate-interest] C# - problem with NULL-replacement when
From:       "Christophe Vanderhaeghen" <christophe () soletis ! be>
Date:       2009-12-16 16:51:37
Message-ID: 001001ca7e70$08af17d0$1a0d4770$ () be
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

According to the documentation found at this location:
<http://www.antlr.org/wiki/display/ST/Expressions>
http://www.antlr.org/wiki/display/ST/Expressions, the following should work,
right?

StringTemplate hello = new StringTemplate("Hello, $names; null=\"?\",
separator=\", \"$");
hello.SetAttribute("names", "test123");

hello.SetAttribute("names", null); // should become ?

hello.SetAttribute("names", "test456");

Console.Out.Write(hello.ToString());

The separator works well, but the NULL is not replaced. When I have a single
value, then the NULL-replacement works fine.

Could you confirm this behavior in C#?

Thanks in advance,

Christophe Vanderhaeghen

 


[Attachment #5 (text/html)]

<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:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","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.apple-style-span
	{mso-style-name:apple-style-span;}
span.apple-converted-space
	{mso-style-name:apple-converted-space;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
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=NL-BE link=blue vlink=purple style='word-wrap: break-word;
-webkit-nbsp-mode: space;-webkit-line-break: after-white-space'>

<div class=Section1>

<div>

<div>

<div>

<div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>Hi,</span><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"; \
color:black'><o:p></o:p></span></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>According to the documentation found at this location:<span
class=apple-converted-space>&nbsp;</span></span><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:black'><a
href="http://www.antlr.org/wiki/display/ST/Expressions"><span \
lang=EN-US>http://www.antlr.org/wiki/display/ST/Expressions</span></a></span><span \
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif"; color:black'>, \
the following should work, right?</span><span style='font-size: \
11.0pt;font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p>

<div>

<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier \
New"; color:#2B91AF'>StringTemplate</span><span class=apple-converted-space><span
lang=EN-US style='font-size:10.0pt;font-family:"Courier \
New";color:black'>&nbsp;</span></span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:black'>hello =<span \
class=apple-converted-space>&nbsp;</span></span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:blue'>new</span><span \
class=apple-converted-space><span lang=EN-US style='font-size:10.0pt; \
font-family:"Courier New";color:black'>&nbsp;</span></span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier \
New";color:#2B91AF'>StringTemplate</span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:black'>(</span><span \
lang=EN-US style='font-size:10.0pt;font-family:"Courier \
New";color:#A31515'>&quot;Hello, $names; null=\&quot;?\&quot;, separator=\&quot;, \
\&quot;$&quot;</span><span lang=EN-US style='font-size:10.0pt;font-family:"Courier \
New";color:black'>);<br> hello.SetAttribute(</span><span lang=EN-US \
style='font-size:10.0pt;font-family: "Courier \
New";color:#A31515'>&quot;names&quot;</span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:black'>,<span \
class=apple-converted-space>&nbsp;</span></span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier \
New";color:#A31515'>&quot;test123&quot;</span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p>


</div>

<div>

<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier \
New"; color:black'>hello.SetAttribute(</span><span lang=EN-US \
style='font-size:10.0pt; font-family:"Courier \
New";color:#A31515'>&quot;names&quot;</span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:black'>,<span \
class=apple-converted-space>&nbsp;</span></span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:blue'>null</span><span \
lang=EN-US style='font-size:10.0pt;font-family:"Courier \
New";color:black'>);</span><span class=apple-converted-space><span lang=EN-US \
style='font-size:10.0pt; font-family:"Courier \
New";color:#9BBB59'>&nbsp;</span></span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:#9BBB59'>// should become \
?</span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"; \
color:black'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier \
New"; color:black'>hello.SetAttribute(</span><span lang=EN-US \
style='font-size:10.0pt; font-family:"Courier \
New";color:#A31515'>&quot;names&quot;</span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:black'>,<span \
class=apple-converted-space>&nbsp;</span></span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier \
New";color:#A31515'>&quot;test456&quot;</span><span lang=EN-US \
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p>


</div>

<div>

<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Courier \
New"; color:black'>Console.Out.Write(hello.ToString());</span><span style='font-size:
11.0pt;font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p>

</div>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>The separator works well, but the NULL is not replaced. When I
have a single value, then the NULL-replacement works fine.<br>
<br>
Could you confirm this behavior</span><span lang=EN-US style='font-size:11.0pt;
font-family:"Calibri","sans-serif"'> in C#<span \
style='color:black'>?</span></span><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p>


<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>Thanks in advance,</span><span style='font-size:11.0pt;font-family:
"Calibri","sans-serif";color:black'><o:p></o:p></span></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span
lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:black'>Christophe Vanderhaeghen</span><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif";color:black'><o:p></o:p></span></p>

</div>

</div>

</div>

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

</div>

</div>

</body>

</html>



_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest@antlr.org
http://www.antlr.org/mailman/listinfo/stringtemplate-interest


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic