<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:georss="http://www.georss.org/georss" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Nesterovsky bros - Announce</title>
    <link>http://www.nesterovsky-bros.com/weblog/</link>
    <description />
    <language>en-us</language>
    <copyright>Nesterovsky bros</copyright>
    <lastBuildDate>Sat, 18 May 2013 10:59:36 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.12105.0</generator>
    <managingEditor>contact@nesterovsky-bros.com</managingEditor>
    <webMaster>contact@nesterovsky-bros.com</webMaster>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=04f31825-657d-470b-9223-bb1e8961fc9d</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,04f31825-657d-470b-9223-bb1e8961fc9d.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,04f31825-657d-470b-9223-bb1e8961fc9d.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=04f31825-657d-470b-9223-bb1e8961fc9d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
While trying to generalize our practices from KendoUI related projects we've participated
so far, we updated <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2fscripts%2fapi%2fcontrols.js"> control.js</a> -
a small javascript additions to KendoUI.
</p>
        <p>
At present we have defined:
</p>
        <p>
1. An extended model. See <a href="2013/04/03/KendoUIExtendedModel.aspx" rel="bookmark">KendoUI
extended model</a>. 
</p>
        <p>
2. A lightweight user control - a widget to bind a template and a model, and to facilitate
declarative instantiation. See <a href="2013/03/26/KendoUIUserControl.aspx" rel="bookmark">KendoUI
User control</a>. 
</p>
        <p>
3. A reworked version of nesterovskyBros.defineControl() function. 
</p>
        <p style="padding-left: 1em">
          <code>var widgetType = scope.defineControl(<br />
{<br />
   name: widget-name-string,<br />
   model: widget-model-type,<br />
   template: optional-content-template,<br />
   windowOptions: optional-window-options<br />
},<br />
base);</code>
        </p>
        <p>
When <code>optional-content-template</code> is not specified then template is calculated
as following:
</p>
        <p style="padding-left: 1em">
          <code> var template = options.temlate || proto.template || model.temlate;<br /><br />
if (template === undefined) 
<br />
{<br />
  template = scope.template(options.name.toLowerCase() + "-template"); 
<br />
} </code>
        </p>
        <p>
When <code>windowOptions</code> is specified then <code>widgetType.dialog(options)</code> function
is defined. It's used to open dialog based on the specified user control. <code>windowOptions</code> is
passed to <code>kendo.ui.Window</code> constructor. <code>windowOptions.closeOnEscape</code> indicates
whether to close opened dialog on escape.
</p>
        <p>
          <code>widgetType.dialog()</code> returns a <code>kendo.ui.Window</code> instance with
content based on the user control. Window instance contains functions: 
</p>
        <ul>
          <li>
            <code>result()</code> - a <code>$.Deffered</code> for the dialog result, and 
</li>
          <li>
            <code>model()</code> - referring to the user control model. 
</li>
        </ul>
        <p>
 The model instance has functions:
</p>
        <ul>
          <li>
 <code>dialog()</code> referring to the dialog, and 
</li>
          <li>
            <code>result()</code> referring to the dialog result.</li>
        </ul>
        <p>
          <code>widget.dialog()</code> allows all css units in <code>windowOptions.width</code> and <code>windowOptions.height</code> parameters.
</p>
        <p>
          <code>base</code> - is optional user control base. It defaults to <code>nesterovskyBros.ui.UserControl</code>.
</p>
        <p>
4. Adjusted splitter. See <a href="2013/05/14/AdjustKendoUISplitter.aspx" rel="bookmark">Adjust
KendoUI Splitter</a>.
</p>
        <p>
5. Auto resize support.
</p>
        <p>
Layout is often depends on available area. One example is <code>Splitter</code> widget
that recalculates its panes when window or container <code>Splitter</code> is resized.
There are other cases when you would like to adjust layout when a container's
area is changed like: adjust grid, tab, editor or user's control contents.
</p>
        <p>
KendoUI does not provide a solution for this problem, so we have defined our own.
</p>
        <ul>
          <li>
A widget can be marked with <code>class="auto-resize"</code> marker;</li>
          <li>
A widget may define a <code>widgetType.autoResize(element)</code> function that adapts
widget to a new size.</li>
          <li>
A code can call <code>nesterovskyBros.resize(element)</code> function at trigger resizing
of the subtree.</li>
        </ul>
        <p>
To support existing controls we have defined <code>autoResize()</code> function for <code>Grid</code>, <code>Splitter</code>, <code>TabStrip</code>,
and <code>Editor</code> widgets.
</p>
        <p>
To see how auto resizing works, it's best to look into <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2findex.html">index.html</a>, <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2fscripts%2ftemplates%2fproducts.tmpl.html"> products.tmpl.html</a>,
and into the implementation <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2fscripts%2fapi%2fcontrols.js"> controls.js</a>.
</p>
        <p>
Please note that we consider <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2fscripts%2fapi%2fcontrols.js"> controls.js</a> as
an addition to KendoUI library. If in the future the library will integrate or implement
similar features we will be happy to start using their API.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d" />
      </body>
      <title>KendoUI controls.js</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,04f31825-657d-470b-9223-bb1e8961fc9d.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2013/05/18/KendoUIControlsjs.aspx</link>
      <pubDate>Sat, 18 May 2013 10:59:36 GMT</pubDate>
      <description>  &lt;p&gt;
While trying to generalize our practices from KendoUI related projects we've participated
so far, we updated &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2fscripts%2fapi%2fcontrols.js"&gt; control.js&lt;/a&gt; -
a small javascript additions to KendoUI.
&lt;/p&gt;
&lt;p&gt;
At present we have defined:
&lt;/p&gt;
&lt;p&gt;
1. An extended model. See &lt;a href="2013/04/03/KendoUIExtendedModel.aspx" rel="bookmark"&gt;KendoUI
extended model&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
2. A lightweight user control - a widget to bind a template and a model, and to facilitate
declarative instantiation. See &lt;a href="2013/03/26/KendoUIUserControl.aspx" rel="bookmark"&gt;KendoUI
User control&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
3. A reworked version of nesterovskyBros.defineControl() function. 
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;var widgetType = scope.defineControl(&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; name: widget-name-string,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; model: widget-model-type,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; template: optional-content-template,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; windowOptions: optional-window-options&lt;br /&gt;
},&lt;br /&gt;
base);&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
When &lt;code&gt;optional-content-template&lt;/code&gt; is not specified then template is calculated
as following:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt; var template = options.temlate || proto.template || model.temlate;&lt;br /&gt;
&lt;br /&gt;
if (template === undefined) 
&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; template = scope.template(options.name.toLowerCase() + "-template"); 
&lt;br /&gt;
} &lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
When &lt;code&gt;windowOptions&lt;/code&gt; is specified then &lt;code&gt;widgetType.dialog(options)&lt;/code&gt; function
is defined. It&amp;#39;s used to open dialog based on the specified user control. &lt;code&gt;windowOptions&lt;/code&gt; is
passed to &lt;code&gt;kendo.ui.Window&lt;/code&gt; constructor. &lt;code&gt;windowOptions.closeOnEscape&lt;/code&gt; indicates
whether to close opened dialog on escape.
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;widgetType.dialog()&lt;/code&gt; returns a &lt;code&gt;kendo.ui.Window&lt;/code&gt; instance with
content based on the user control. Window instance contains functions: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;result()&lt;/code&gt; - a &lt;code&gt;$.Deffered&lt;/code&gt; for the dialog result, and 
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;model()&lt;/code&gt; - referring to the user control model. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&amp;nbsp;The model instance has functions:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&amp;nbsp;&lt;code&gt;dialog()&lt;/code&gt; referring to the dialog, and 
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;result()&lt;/code&gt; referring to the dialog result.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;code&gt;widget.dialog()&lt;/code&gt; allows all css units in &lt;code&gt;windowOptions.width&lt;/code&gt; and &lt;code&gt;windowOptions.height&lt;/code&gt; parameters.
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;base&lt;/code&gt; - is optional user control base. It defaults to &lt;code&gt;nesterovskyBros.ui.UserControl&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
4. Adjusted splitter. See &lt;a href="2013/05/14/AdjustKendoUISplitter.aspx" rel="bookmark"&gt;Adjust
KendoUI Splitter&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
5. Auto resize support.
&lt;/p&gt;
&lt;p&gt;
Layout is often depends on available area. One example is &lt;code&gt;Splitter&lt;/code&gt; widget
that recalculates its panes when window or container &lt;code&gt;Splitter&lt;/code&gt; is resized.
There are other cases when you would like to adjust layout when a container&amp;#39;s
area is changed like: adjust grid, tab, editor or user&amp;#39;s control contents.
&lt;/p&gt;
&lt;p&gt;
KendoUI does not provide a solution for this problem, so we have defined our own.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
A widget can be marked with &lt;code&gt;class=&amp;quot;auto-resize&amp;quot;&lt;/code&gt; marker;&lt;/li&gt;
&lt;li&gt;
A widget may define a &lt;code&gt;widgetType.autoResize(element)&lt;/code&gt; function that adapts
widget to a new size.&lt;/li&gt;
&lt;li&gt;
A code can call &lt;code&gt;nesterovskyBros.resize(element)&lt;/code&gt; function at trigger resizing
of the subtree.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
To support existing controls we have defined &lt;code&gt;autoResize()&lt;/code&gt; function for &lt;code&gt;Grid&lt;/code&gt;, &lt;code&gt;Splitter&lt;/code&gt;, &lt;code&gt;TabStrip&lt;/code&gt;,
and &lt;code&gt;Editor&lt;/code&gt; widgets.
&lt;/p&gt;
&lt;p&gt;
To see how auto resizing works, it&amp;#39;s best to look into &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2findex.html"&gt;index.html&lt;/a&gt;, &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2fscripts%2ftemplates%2fproducts.tmpl.html"&gt; products.tmpl.html&lt;/a&gt;,
and into the implementation &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2fscripts%2fapi%2fcontrols.js"&gt; controls.js&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Please note that we consider &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fKendoUI%2fscripts%2fapi%2fcontrols.js"&gt; controls.js&lt;/a&gt; as
an addition to KendoUI library. If in the future the library will integrate or implement
similar features we will be happy to start using their API.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=04f31825-657d-470b-9223-bb1e8961fc9d" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,04f31825-657d-470b-9223-bb1e8961fc9d.aspx</comments>
      <category>Announce</category>
      <category>javascript</category>
      <category>kendoui</category>
      <category>Tips and tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=19c9c7e3-4b24-4407-806a-b118460873e3</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,19c9c7e3-4b24-4407-806a-b118460873e3.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,19c9c7e3-4b24-4407-806a-b118460873e3.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=19c9c7e3-4b24-4407-806a-b118460873e3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This time we <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=19c9c7e3-4b24-4407-806a-b118460873e3&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">update
csharpxom</a> to adjust it to C# 4.5. Additions are<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=19c9c7e3-4b24-4407-806a-b118460873e3&amp;url=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fhh156513(v%3dvs.110).aspx"><code>async</code> modifier</a> and <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=19c9c7e3-4b24-4407-806a-b118460873e3&amp;url=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fhh156528(v%3dvs.110).aspx"><code>await</code> operator</a>.
</p>
        <p>
They are used to simplify asynchronous programming.
</p>
        <p>
The following example from the msdn:
</p>
        <p style="padding-left: 1em">
          <code>private async Task&lt;byte[]&gt; GetURLContentsAsync(string url)<br />
{<br />
var content = new MemoryStream();<br />
var request = (HttpWebRequest)WebRequest.Create(url);<br /><br />
using(var response = await request.GetResponseAsync())<br />
using(var responseStream = response.GetResponseStream())<br />
{<br />
await responseStream.CopyToAsync(content);<br />
}<br /><br />
return content.ToArray();<br />
}</code>
        </p>
        <p>
looks like this in csharpxom:
</p>
        <p style="padding-left: 1em">
          <code>&lt;method name="GetURLContentsAsync" access="private" <span style="font-weight: bold">async="true"</span>&gt;<br />
&lt;returns&gt;<br />
&lt;type name="Task" namespace="System.Threading.Tasks"&gt;<br />
&lt;type-arguments&gt;<br />
&lt;type name="byte" rank="1"/&gt;<br />
&lt;/type-arguments&gt;<br />
&lt;/type&gt;<br />
&lt;/returns&gt;<br />
&lt;parameters&gt;<br />
&lt;parameter name="url"&gt;<br />
&lt;type name="string"/&gt;<br />
&lt;/parameter&gt;<br />
&lt;/parameters&gt;<br />
&lt;block&gt;<br />
&lt;var name="content"&gt;<br />
&lt;initialize&gt;<br />
&lt;new-object&gt;<br />
&lt;type name="MemoryStream" namespace="System.IO"/&gt;<br />
&lt;/new-object&gt;<br />
&lt;/initialize&gt;<br />
&lt;/var&gt;<br />
&lt;var name="request"&gt;<br />
&lt;initialize&gt;<br />
&lt;cast&gt;<br />
&lt;invoke&gt;<br />
&lt;static-method-ref name="Create"&gt;<br />
&lt;type name="WebRequest" namespace="System.Net"/&gt;<br />
&lt;/static-method-ref&gt;<br />
&lt;arguments&gt;<br />
&lt;var-ref name="url"/&gt;<br />
&lt;/arguments&gt;<br />
&lt;/invoke&gt;<br />
&lt;type name="HttpWebRequest" namespace="System.Net"/&gt;<br />
&lt;/cast&gt;<br />
&lt;/initialize&gt;<br />
&lt;/var&gt;<br /><br />
&lt;using&gt;<br />
&lt;resource&gt;<br />
&lt;var name="response"&gt;<br />
&lt;initialize&gt;<br /><span style="font-weight: bold">&lt;await&gt;</span><br />
&lt;invoke&gt;<br />
&lt;method-ref name="GetResponseAsync"&gt;<br />
&lt;var-ref name="request"/&gt;<br />
&lt;/method-ref&gt;<br />
&lt;/invoke&gt;<br /><span style="font-weight: bold">&lt;/await&gt;</span><br />
&lt;/initialize&gt;<br />
&lt;/var&gt;<br />
&lt;/resource&gt;<br />
&lt;using&gt;<br />
&lt;resource&gt;<br />
&lt;var name="responseStream"&gt;<br />
&lt;initialize&gt;<br />
&lt;invoke&gt;<br />
&lt;method-ref name="GetResponseStream"&gt;<br />
&lt;var-ref name="response"/&gt;<br />
&lt;/method-ref&gt;<br />
&lt;/invoke&gt;<br />
&lt;/initialize&gt;<br />
&lt;/var&gt;<br />
&lt;/resource&gt;<br />
&lt;expression&gt;<br /><span style="font-weight: bold">&lt;await&gt;</span><br />
&lt;invoke&gt;<br />
&lt;method-ref name="CopyToAsync"&gt;<br />
&lt;var-ref name="responseStream"/&gt;<br />
&lt;/method-ref&gt;<br />
&lt;arguments&gt;<br />
&lt;var-ref name="content"/&gt;<br />
&lt;/arguments&gt;<br />
&lt;/invoke&gt;<br /><span style="font-weight: bold">&lt;/await&gt;</span><br />
&lt;/expression&gt;<br />
&lt;/using&gt;<br />
&lt;/using&gt;<br /><br />
&lt;return&gt;<br />
&lt;invoke&gt;<br />
&lt;method-ref name="ToArray"&gt;<br />
&lt;var-ref name="content"/&gt;<br />
&lt;/method-ref&gt;<br />
&lt;/invoke&gt;<br />
&lt;/return&gt;<br />
&lt;/block&gt;<br />
&lt;/method&gt;</code>
        </p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=19c9c7e3-4b24-4407-806a-b118460873e3" />
      </body>
      <title>Languages XOM update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,19c9c7e3-4b24-4407-806a-b118460873e3.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2012/03/23/LanguagesXOMUpdate.aspx</link>
      <pubDate>Fri, 23 Mar 2012 00:07:35 GMT</pubDate>
      <description>  &lt;p&gt;
This time we &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=19c9c7e3-4b24-4407-806a-b118460873e3&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt;update
csharpxom&lt;/a&gt; to adjust it to C# 4.5. Additions are&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=19c9c7e3-4b24-4407-806a-b118460873e3&amp;amp;url=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fhh156513(v%3dvs.110).aspx"&gt; &lt;code&gt;async&lt;/code&gt; modifier&lt;/a&gt; and &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=19c9c7e3-4b24-4407-806a-b118460873e3&amp;amp;url=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fhh156528(v%3dvs.110).aspx"&gt; &lt;code&gt;await&lt;/code&gt; operator&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
They are used to simplify asynchronous programming.
&lt;/p&gt;
&lt;p&gt;
The following example from the msdn:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;private async Task&amp;lt;byte[]&amp;gt; GetURLContentsAsync(string url)&lt;br /&gt;
{&lt;br /&gt;
var content = new MemoryStream();&lt;br /&gt;
var request = (HttpWebRequest)WebRequest.Create(url);&lt;br /&gt;
&lt;br /&gt;
using(var response = await request.GetResponseAsync())&lt;br /&gt;
using(var responseStream = response.GetResponseStream())&lt;br /&gt;
{&lt;br /&gt;
await responseStream.CopyToAsync(content);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return content.ToArray();&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
looks like this in csharpxom:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;&amp;lt;method name="GetURLContentsAsync" access="private" &lt;span style="font-weight: bold"&gt;async="true"&lt;/span&gt;&amp;gt;&lt;br /&gt;
&amp;lt;returns&amp;gt;&lt;br /&gt;
&amp;lt;type name="Task" namespace="System.Threading.Tasks"&amp;gt;&lt;br /&gt;
&amp;lt;type-arguments&amp;gt;&lt;br /&gt;
&amp;lt;type name="byte" rank="1"/&amp;gt;&lt;br /&gt;
&amp;lt;/type-arguments&amp;gt;&lt;br /&gt;
&amp;lt;/type&amp;gt;&lt;br /&gt;
&amp;lt;/returns&amp;gt;&lt;br /&gt;
&amp;lt;parameters&amp;gt;&lt;br /&gt;
&amp;lt;parameter name="url"&amp;gt;&lt;br /&gt;
&amp;lt;type name="string"/&amp;gt;&lt;br /&gt;
&amp;lt;/parameter&amp;gt;&lt;br /&gt;
&amp;lt;/parameters&amp;gt;&lt;br /&gt;
&amp;lt;block&amp;gt;&lt;br /&gt;
&amp;lt;var name="content"&amp;gt;&lt;br /&gt;
&amp;lt;initialize&amp;gt;&lt;br /&gt;
&amp;lt;new-object&amp;gt;&lt;br /&gt;
&amp;lt;type name="MemoryStream" namespace="System.IO"/&amp;gt;&lt;br /&gt;
&amp;lt;/new-object&amp;gt;&lt;br /&gt;
&amp;lt;/initialize&amp;gt;&lt;br /&gt;
&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;var name="request"&amp;gt;&lt;br /&gt;
&amp;lt;initialize&amp;gt;&lt;br /&gt;
&amp;lt;cast&amp;gt;&lt;br /&gt;
&amp;lt;invoke&amp;gt;&lt;br /&gt;
&amp;lt;static-method-ref name="Create"&amp;gt;&lt;br /&gt;
&amp;lt;type name="WebRequest" namespace="System.Net"/&amp;gt;&lt;br /&gt;
&amp;lt;/static-method-ref&amp;gt;&lt;br /&gt;
&amp;lt;arguments&amp;gt;&lt;br /&gt;
&amp;lt;var-ref name="url"/&amp;gt;&lt;br /&gt;
&amp;lt;/arguments&amp;gt;&lt;br /&gt;
&amp;lt;/invoke&amp;gt;&lt;br /&gt;
&amp;lt;type name="HttpWebRequest" namespace="System.Net"/&amp;gt;&lt;br /&gt;
&amp;lt;/cast&amp;gt;&lt;br /&gt;
&amp;lt;/initialize&amp;gt;&lt;br /&gt;
&amp;lt;/var&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;using&amp;gt;&lt;br /&gt;
&amp;lt;resource&amp;gt;&lt;br /&gt;
&amp;lt;var name="response"&amp;gt;&lt;br /&gt;
&amp;lt;initialize&amp;gt;&lt;br /&gt;
&lt;span style="font-weight: bold"&gt;&amp;lt;await&amp;gt;&lt;/span&gt;
&lt;br /&gt;
&amp;lt;invoke&amp;gt;&lt;br /&gt;
&amp;lt;method-ref name="GetResponseAsync"&amp;gt;&lt;br /&gt;
&amp;lt;var-ref name="request"/&amp;gt;&lt;br /&gt;
&amp;lt;/method-ref&amp;gt;&lt;br /&gt;
&amp;lt;/invoke&amp;gt;&lt;br /&gt;
&lt;span style="font-weight: bold"&gt;&amp;lt;/await&amp;gt;&lt;/span&gt;
&lt;br /&gt;
&amp;lt;/initialize&amp;gt;&lt;br /&gt;
&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;/resource&amp;gt;&lt;br /&gt;
&amp;lt;using&amp;gt;&lt;br /&gt;
&amp;lt;resource&amp;gt;&lt;br /&gt;
&amp;lt;var name="responseStream"&amp;gt;&lt;br /&gt;
&amp;lt;initialize&amp;gt;&lt;br /&gt;
&amp;lt;invoke&amp;gt;&lt;br /&gt;
&amp;lt;method-ref name="GetResponseStream"&amp;gt;&lt;br /&gt;
&amp;lt;var-ref name="response"/&amp;gt;&lt;br /&gt;
&amp;lt;/method-ref&amp;gt;&lt;br /&gt;
&amp;lt;/invoke&amp;gt;&lt;br /&gt;
&amp;lt;/initialize&amp;gt;&lt;br /&gt;
&amp;lt;/var&amp;gt;&lt;br /&gt;
&amp;lt;/resource&amp;gt;&lt;br /&gt;
&amp;lt;expression&amp;gt;&lt;br /&gt;
&lt;span style="font-weight: bold"&gt;&amp;lt;await&amp;gt;&lt;/span&gt;
&lt;br /&gt;
&amp;lt;invoke&amp;gt;&lt;br /&gt;
&amp;lt;method-ref name="CopyToAsync"&amp;gt;&lt;br /&gt;
&amp;lt;var-ref name="responseStream"/&amp;gt;&lt;br /&gt;
&amp;lt;/method-ref&amp;gt;&lt;br /&gt;
&amp;lt;arguments&amp;gt;&lt;br /&gt;
&amp;lt;var-ref name="content"/&amp;gt;&lt;br /&gt;
&amp;lt;/arguments&amp;gt;&lt;br /&gt;
&amp;lt;/invoke&amp;gt;&lt;br /&gt;
&lt;span style="font-weight: bold"&gt;&amp;lt;/await&amp;gt;&lt;/span&gt;
&lt;br /&gt;
&amp;lt;/expression&amp;gt;&lt;br /&gt;
&amp;lt;/using&amp;gt;&lt;br /&gt;
&amp;lt;/using&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;return&amp;gt;&lt;br /&gt;
&amp;lt;invoke&amp;gt;&lt;br /&gt;
&amp;lt;method-ref name="ToArray"&amp;gt;&lt;br /&gt;
&amp;lt;var-ref name="content"/&amp;gt;&lt;br /&gt;
&amp;lt;/method-ref&amp;gt;&lt;br /&gt;
&amp;lt;/invoke&amp;gt;&lt;br /&gt;
&amp;lt;/return&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/method&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=19c9c7e3-4b24-4407-806a-b118460873e3" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,19c9c7e3-4b24-4407-806a-b118460873e3.aspx</comments>
      <category>.NET</category>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=a23cc7e7-d76b-4f52-9471-abd9beeaa151</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,a23cc7e7-d76b-4f52-9471-abd9beeaa151.aspx</pingback:target>
      <dc:creator>Arthur Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,a23cc7e7-d76b-4f52-9471-abd9beeaa151.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=a23cc7e7-d76b-4f52-9471-abd9beeaa151</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Some time ago our younger brother Aleksander had started studying of <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a23cc7e7-d76b-4f52-9471-abd9beeaa151&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f05%2f05%2fCinematography.aspx">cinematography</a>.
</p>
        <p>
Few days ago he started his own <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a23cc7e7-d76b-4f52-9471-abd9beeaa151&amp;url=http%3a%2f%2fwww.wix.com%2faleksan86%2fnesta" target="_blank">"multimedia"
blog</a> (you'll better understand me when you'll see it), where you can see his portfolio.
Aleksander's latest work was made with cooperation with Ilan Lahov, see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a23cc7e7-d76b-4f52-9471-abd9beeaa151&amp;url=http%3a%2f%2fwww.wix.com%2faleksan86%2fnesta%23!__bar-mitzvah" target="_blank">"Bar
mitzvah"</a>. This work demonstrates Aleksander's progress in this field.
</p>
        <p>
Our congratulations to <a href="mailto:aleksander@nesterovsky-bros.com">Aleksander</a>!
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=a23cc7e7-d76b-4f52-9471-abd9beeaa151" />
      </body>
      <title>Again about cinematography.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,a23cc7e7-d76b-4f52-9471-abd9beeaa151.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2012/01/25/AgainAboutCinematography.aspx</link>
      <pubDate>Wed, 25 Jan 2012 20:57:35 GMT</pubDate>
      <description>&lt;p&gt;
Some time ago our younger brother Aleksander had started studying of &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a23cc7e7-d76b-4f52-9471-abd9beeaa151&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f05%2f05%2fCinematography.aspx"&gt;cinematography&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Few days ago he started his own &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a23cc7e7-d76b-4f52-9471-abd9beeaa151&amp;amp;url=http%3a%2f%2fwww.wix.com%2faleksan86%2fnesta" target="_blank"&gt;"multimedia"
blog&lt;/a&gt; (you'll better understand me when you'll see it), where you can see his portfolio.
Aleksander's latest work was made with cooperation with Ilan Lahov, see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a23cc7e7-d76b-4f52-9471-abd9beeaa151&amp;amp;url=http%3a%2f%2fwww.wix.com%2faleksan86%2fnesta%23!__bar-mitzvah" target="_blank"&gt;"Bar
mitzvah"&lt;/a&gt;. This work demonstrates Aleksander's progress in this field.
&lt;/p&gt;
&lt;p&gt;
Our congratulations to &lt;a href="mailto:aleksander@nesterovsky-bros.com"&gt;Aleksander&lt;/a&gt;!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=a23cc7e7-d76b-4f52-9471-abd9beeaa151" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,a23cc7e7-d76b-4f52-9471-abd9beeaa151.aspx</comments>
      <category>Announce</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=9533804c-0be1-4e57-8cbc-764a1b66f53a</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,9533804c-0be1-4e57-8cbc-764a1b66f53a.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,9533804c-0be1-4e57-8cbc-764a1b66f53a.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=9533804c-0be1-4e57-8cbc-764a1b66f53a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Please welcome a new human being Masha Vladimirovna Nesterovsky!
</p>
        <p>
          <img alt="Masha" src="http://www.nesterovsky-bros.com/weblog/images/Masha.jpg" style="padding: 2px; border: 1px solid red" />
        </p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=9533804c-0be1-4e57-8cbc-764a1b66f53a" />
      </body>
      <title>Masha</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,9533804c-0be1-4e57-8cbc-764a1b66f53a.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2011/08/29/Masha.aspx</link>
      <pubDate>Mon, 29 Aug 2011 13:54:22 GMT</pubDate>
      <description>&lt;p&gt;
Please welcome a new human being Masha Vladimirovna Nesterovsky!
&lt;/p&gt;
&lt;p&gt;
&lt;img alt="Masha" src="http://www.nesterovsky-bros.com/weblog/images/Masha.jpg" style="padding: 2px; border: 1px solid red" /&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=9533804c-0be1-4e57-8cbc-764a1b66f53a" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,9533804c-0be1-4e57-8cbc-764a1b66f53a.aspx</comments>
      <category>Announce</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=a2345b18-13e4-4f60-b798-4b28587a18cb</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,a2345b18-13e4-4f60-b798-4b28587a18cb.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,a2345b18-13e4-4f60-b798-4b28587a18cb.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=a2345b18-13e4-4f60-b798-4b28587a18cb</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently one of users of <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f24%2fYieldReturnFeatureInJava.aspx">java
yield return annotation</a> has kindly informed us about some problem that happened
in his environment (see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f02%2f05%2fJavasYieldReturnAnnotationUpdate.aspx"> Java's
@Yield return annotation update</a>).
</p>
        <p>
Incidentally we have never noticed the problem earlier. Along with this issue we have
found that eclipse compiler has changed in the Indigo in a way that we had to recompile
the source. Well, that's a price you have to pay when you access internal API.
</p>
        <p>
Updated sources can be found at <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.zip">Yield.zip</a>,
and compiled jars at <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.jar">Yield.jar</a> (pre-Indigo),
and <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.3.7.jar"> Yield.3.7.jar</a> (Indigo
and probably higher).
</p>
        <p>
See also: 
</p>
        <p>
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f24%2fYieldReturnFeatureInJava.aspx"> Yield
return feature in java</a>
          <br />
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f27%2fWhyYieldIteratorShouldBeCloseable.aspx"> Why
@Yield iterator should be Closeable</a>
          <br />
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f09%2f05%2fWhatYouCanDoWithJxom.aspx"> What
you can do with jxom.</a>
        </p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb" />
      </body>
      <title>Yield return update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,a2345b18-13e4-4f60-b798-4b28587a18cb.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2011/08/28/YieldReturnUpdate.aspx</link>
      <pubDate>Sun, 28 Aug 2011 19:11:45 GMT</pubDate>
      <description>&lt;p&gt;
Recently one of users of &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f24%2fYieldReturnFeatureInJava.aspx"&gt;java
yield return annotation&lt;/a&gt; has kindly informed us about some problem that happened
in his environment (see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f02%2f05%2fJavasYieldReturnAnnotationUpdate.aspx"&gt; Java&amp;#39;s
@Yield return annotation update&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
Incidentally we have never noticed the problem earlier. Along with this issue we have
found that eclipse compiler has changed in the Indigo in a way that we had to recompile
the source. Well, that&amp;#39;s a price you have to pay when you access internal API.
&lt;/p&gt;
&lt;p&gt;
Updated sources can be found at &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.zip"&gt;Yield.zip&lt;/a&gt;,
and compiled jars at &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.jar"&gt;Yield.jar&lt;/a&gt; (pre-Indigo),
and &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.3.7.jar"&gt; Yield.3.7.jar&lt;/a&gt; (Indigo
and probably higher).
&lt;/p&gt;
&lt;p&gt;
See also: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f24%2fYieldReturnFeatureInJava.aspx"&gt; Yield
return feature in java&lt;/a&gt;
&lt;br /&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f27%2fWhyYieldIteratorShouldBeCloseable.aspx"&gt; Why
@Yield iterator should be Closeable&lt;/a&gt;
&lt;br /&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f09%2f05%2fWhatYouCanDoWithJxom.aspx"&gt; What
you can do with jxom.&lt;/a&gt; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=a2345b18-13e4-4f60-b798-4b28587a18cb" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,a2345b18-13e4-4f60-b798-4b28587a18cb.aspx</comments>
      <category>Announce</category>
      <category>Java</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=c8b061fa-7471-4601-8b19-2c5bf55ce9ea</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,c8b061fa-7471-4601-8b19-2c5bf55ce9ea.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,c8b061fa-7471-4601-8b19-2c5bf55ce9ea.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=c8b061fa-7471-4601-8b19-2c5bf55ce9ea</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We did not update <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c8b061fa-7471-4601-8b19-2c5bf55ce9ea&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"> languages-xom</a> already
for many monthes but now we have found a severe bug in the jxom's algorithm for eliminating
unreachable code. The marked line were considered as unreachable:
</p>
        <p style="padding-left: 1em">
          <code>check:<br />
if (condition)<br />
{<br />
break check;<br />
}<br />
else<br />
{<br />
return;<br />
}<br /><br />
// due to bug the following was considered unreachable<br /><span style="color: red; font-weight: bold">expression;</span></code>
        </p>
        <p>
Bug is fixed.
</p>
        <p>
Current update contains other cosmetic fixes. 
</p>
        <p>
Please download xslt sources from <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c8b061fa-7471-4601-8b19-2c5bf55ce9ea&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">languages-xom.zip</a>.
</p>
        <p>
Summary
</p>
        <p>
Languages XOM is a set of xml schemas and xslt stylesheets that allows:
</p>
        <ul>
          <li>
to define programs in xml form;</li>
          <li>
to perform transformations over code in xml form;</li>
          <li>
to generate sources.</li>
        </ul>
        <p>
Languages XOM includes:
</p>
        <ul>
          <li>
jxom - Java Xml Object model;</li>
          <li>
csharpxom - C# Xml Object Model;</li>
          <li>
cobolxom - COBOL Xml Object Model;</li>
          <li>
sqlxom - SQL Xml Object Model (including several sql dialects);</li>
          <li>
aspx - ASP.NET Object Model;</li>
        </ul>
        <p>
A proprietary part of languages XOM also includes XML Object Model for a language
named Cool:GEN. In fact the original purpose for this API was a generation of java/C#/COBOL
from Cool:GEN. For more details about Cool:GEN conversion please see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c8b061fa-7471-4601-8b19-2c5bf55ce9ea&amp;url=http%3a%2f%2fwww.bphx.com%2fen%2fSolutions%2fApplicationModernization%2fPages%2fCooLGen.aspx"> here</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=c8b061fa-7471-4601-8b19-2c5bf55ce9ea" />
      </body>
      <title>Languages-XOM update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,c8b061fa-7471-4601-8b19-2c5bf55ce9ea.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2011/05/26/LanguagesXOMUpdate.aspx</link>
      <pubDate>Thu, 26 May 2011 05:15:11 GMT</pubDate>
      <description>&lt;p&gt;
We did not update &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c8b061fa-7471-4601-8b19-2c5bf55ce9ea&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt; languages-xom&lt;/a&gt; already
for many monthes but now we have found a severe bug in the jxom's algorithm for eliminating
unreachable code. The marked line were considered as unreachable:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;check:&lt;br /&gt;
if (condition)&lt;br /&gt;
{&lt;br /&gt;
break check;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// due to bug the following was considered unreachable&lt;br /&gt;
&lt;span style="color: red; font-weight: bold"&gt;expression;&lt;/span&gt; &lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
Bug is fixed.
&lt;/p&gt;
&lt;p&gt;
Current update contains other cosmetic fixes. 
&lt;/p&gt;
&lt;p&gt;
Please download xslt sources from &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c8b061fa-7471-4601-8b19-2c5bf55ce9ea&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt;languages-xom.zip&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Summary
&lt;/p&gt;
&lt;p&gt;
Languages XOM is a set of xml schemas and xslt stylesheets that allows:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
to define programs in xml form;&lt;/li&gt;
&lt;li&gt;
to perform transformations over code in xml form;&lt;/li&gt;
&lt;li&gt;
to generate sources.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Languages XOM includes:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
jxom - Java Xml Object model;&lt;/li&gt;
&lt;li&gt;
csharpxom - C# Xml Object Model;&lt;/li&gt;
&lt;li&gt;
cobolxom - COBOL Xml Object Model;&lt;/li&gt;
&lt;li&gt;
sqlxom - SQL Xml Object Model (including several sql dialects);&lt;/li&gt;
&lt;li&gt;
aspx - ASP.NET Object Model;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
A proprietary part of languages XOM also includes XML Object Model for a language
named Cool:GEN. In fact the original purpose for this API was a generation of java/C#/COBOL
from Cool:GEN. For more details about Cool:GEN conversion please see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c8b061fa-7471-4601-8b19-2c5bf55ce9ea&amp;amp;url=http%3a%2f%2fwww.bphx.com%2fen%2fSolutions%2fApplicationModernization%2fPages%2fCooLGen.aspx"&gt; here&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=c8b061fa-7471-4601-8b19-2c5bf55ce9ea" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,c8b061fa-7471-4601-8b19-2c5bf55ce9ea.aspx</comments>
      <category>Announce</category>
      <category>Java</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=13a3c6de-2c88-4d27-b4ef-779921588466</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,13a3c6de-2c88-4d27-b4ef-779921588466.aspx</pingback:target>
      <dc:creator>Arthur Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,13a3c6de-2c88-4d27-b4ef-779921588466.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=13a3c6de-2c88-4d27-b4ef-779921588466</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Ladies and gentlemen!
</p>
        <p>
We are proud and would like to announce <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=13a3c6de-2c88-4d27-b4ef-779921588466&amp;url=http%3a%2f%2fwww.youtube.com%2fuser%2fNesterovskychess" target="_blank">few
works</a> of our younger brother Aleksander, who studies cinematography now.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=13a3c6de-2c88-4d27-b4ef-779921588466" />
      </body>
      <title>Cinematography</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,13a3c6de-2c88-4d27-b4ef-779921588466.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2011/05/05/Cinematography.aspx</link>
      <pubDate>Thu, 05 May 2011 09:21:54 GMT</pubDate>
      <description>&lt;p&gt;
Ladies and gentlemen!
&lt;/p&gt;
&lt;p&gt;
We are proud and would like to announce &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=13a3c6de-2c88-4d27-b4ef-779921588466&amp;amp;url=http%3a%2f%2fwww.youtube.com%2fuser%2fNesterovskychess" target=_blank&gt;few
works&lt;/a&gt; of our younger brother Aleksander, who studies cinematography now.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=13a3c6de-2c88-4d27-b4ef-779921588466" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,13a3c6de-2c88-4d27-b4ef-779921588466.aspx</comments>
      <category>Announce</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,5ed4531a-dbbb-48b5-89d2-b58d1ed78df8.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,5ed4531a-dbbb-48b5-89d2-b58d1ed78df8.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We have updated <code>@Yield</code> annotation processor to support better debug info.
</p>
        <p>
Annotation processor can be downloaded from <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.zip">Yield.zip</a> or <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.jar">Yield.jar</a>.
</p>
        <p>
We also decided to consider jxom's state machine refactoring as obsolete as <code>@Yield</code> annotation
allows to achieve the same effect but with more clear code.
</p>
        <p>
JXOM can be downloaded from <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"> languages-xom.zip</a></p>
        <p>
See also: 
</p>
        <p>
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f24%2fYieldReturnFeatureInJava.aspx">Yield
return feature in java</a>
          <br />
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f27%2fWhyYieldIteratorShouldBeCloseable.aspx">Why
@Yield iterator should be Closeable</a>
          <br />
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f09%2f05%2fWhatYouCanDoWithJxom.aspx">What
you can do with jxom.</a>
        </p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8" />
      </body>
      <title>Java's @Yield return annotation update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,5ed4531a-dbbb-48b5-89d2-b58d1ed78df8.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2011/02/05/JavasYieldReturnAnnotationUpdate.aspx</link>
      <pubDate>Sat, 05 Feb 2011 21:12:05 GMT</pubDate>
      <description>&lt;p&gt;
We have updated &lt;code&gt;@Yield&lt;/code&gt; annotation processor to support better debug info.
&lt;/p&gt;
&lt;p&gt;
Annotation processor can be downloaded from &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.zip"&gt;Yield.zip&lt;/a&gt; or &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.jar"&gt;Yield.jar&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
We also decided to consider jxom&amp;#39;s state machine refactoring as obsolete as &lt;code&gt;@Yield&lt;/code&gt; annotation
allows to achieve the same effect but with more clear code.
&lt;/p&gt;
&lt;p&gt;
JXOM can be downloaded from &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt; languages-xom.zip&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
See also: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f24%2fYieldReturnFeatureInJava.aspx"&gt;Yield
return feature in java&lt;/a&gt;
&lt;br /&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f27%2fWhyYieldIteratorShouldBeCloseable.aspx"&gt;Why
@Yield iterator should be Closeable&lt;/a&gt;
&lt;br /&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f09%2f05%2fWhatYouCanDoWithJxom.aspx"&gt;What
you can do with jxom.&lt;/a&gt; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=5ed4531a-dbbb-48b5-89d2-b58d1ed78df8" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,5ed4531a-dbbb-48b5-89d2-b58d1ed78df8.aspx</comments>
      <category>Announce</category>
      <category>Java</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=0525e835-90bf-4889-8706-6b0432624e57</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0525e835-90bf-4889-8706-6b0432624e57.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0525e835-90bf-4889-8706-6b0432624e57.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=0525e835-90bf-4889-8706-6b0432624e57</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We're happy to announce that we have implemented <code>@Yield</code> annotation
both in javac and in eclipse compilers.
</p>
        <p>
This way you get built-in IDE support for the feature!
</p>
        <p>
To download yield annotation processor please use the following link: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0525e835-90bf-4889-8706-6b0432624e57&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.zip">Yield.zip</a></p>
        <p>
It contains both yield annotation processor, and a test project.
</p>
        <p>
If you do not want to compile the sources, you can download <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0525e835-90bf-4889-8706-6b0432624e57&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.jar">Yield.jar</a></p>
        <p>
        </p>
        <p>
We would like to reiterate on how <code>@Yield</code> annotation works:
</p>
        <ol>
          <li>
A developer defines a method that returns either <code>Iterator&lt;T&gt;</code> or <code>Iterable&lt;T&gt;</code> instance
and marks it with <code>@Yield</code> annotation.</li>
          <li>
A developer implements iteration logic following the pattern:<br /><ul><li>
declare a variable to accumulate results:<br /><code>ArrayList&lt;T&gt; items = new ArrayList&lt;T&gt;();</code></li><li>
use the following statement to add item to result:<br /><code>items.add(...);</code></li><li>
use<br /><code>return items;</code><br />
or<br /><code>return items.iterator();<br /></code>to return result;</li><li>
mark method's params, if any, as final.</li></ul></li>
          <li>
A devoloper ensures that yield annotation processor is available during compilation
(see details below).</li>
          <li>
            <code>YieldProcessor</code> rewrites method into a state machine at compilation time.</li>
        </ol>
        <p>
The following is an example of such a method:
</p>
        <p style="PADDING-LEFT: 1em">
          <code>@Yield<br />
public static Iterable&lt;Integer&gt; generate(final int from, final int to)<br />
{<br />
ArrayList&lt;Integer&gt; items = new ArrayList&lt;Integer&gt;();<br /><br />
for(int i = from; i &lt; to; ++i)<br />
{<br />
items.add(i);<br />
}<br /><br />
return items;<br />
}</code>
        </p>
        <p>
The use is like this:
</p>
        <p style="PADDING-LEFT: 1em">
          <code>for(int value: generate(7, 20))<br />
{<br />
System.out.println("generator: " + value);<br />
} </code>
        </p>
        <p>
Notice that method's implementation still will be correct in absence of <code> YieldProcessor</code>.
</p>
        <p>
Other important feature is that the state machine returned after the yield processor
is closeable.
</p>
        <p>
This means that if you're breaking the iteration before the end is reached you
can release resources acquired during the iteration.
</p>
        <p>
Consider the example where break exits iteration:
</p>
        <p style="PADDING-LEFT: 1em">
          <code>@Yield<br />
public static Iterable&lt;String&gt; resourceIteration()<br />
{<br />
ArrayList&lt;String&gt; items = new ArrayList&lt;String&gt;();<br /><br />
acquire();<br /><br />
try<br />
{<br />
for(int i = 0; i &lt; 100; ++i)<br />
{<br />
items.add(String.valueOf(i));<br />
}<br />
}<br />
finally<br />
{<br />
release();<br />
}<br /><br />
return items;<br />
}</code>
        </p>
        <p>
and the use
</p>
        <p style="PADDING-LEFT: 1em">
          <code>int i = 0;<br />
Iterable&lt;String&gt; iterator = resourceIteration();<br /><br />
try<br />
{<br />
for(String item: iterator)<br />
{<br />
System.out.println("item " + i + ":" + item);<br /><br />
if (i++ &gt; 30)<br />
{<br /><b>break</b>;<br />
}<br />
}<br />
}<br />
finally<br />
{<br />
close(iterator);<br />
}<br /><br />
...<br /><br />
private static &lt;T&gt; void close(T value)<br />
throws IOException<br />
{<br />
if (value instanceof Closeable)<br />
{<br />
Closeable closeable = (Closeable)value;<br /><br />
closeable.close();<br />
}<br />
} </code>
        </p>
        <p>
Close will execute all required finally blocks. This way resources will be released.
</p>
        <p>
        </p>
        <p>
To configure yield processor a developer needs to refer Yield.jar in build path, as
it contains <code>@Yield</code> annotation. For javac it's enough, as compiler
will find annotation processor automatically.
</p>
        <p>
Eclipse users need to open project properties and:
</p>
        <ul>
          <li>
go to the "Java Compiler"/"Annotation Processing" 
</li>
          <li>
mark "Enable project specific settings"</li>
          <li>
select "Java Compiler"/"Annotation Processing"/"Factory Path"</li>
          <li>
mark "Enable project specific settings"</li>
          <li>
add Yield.jar to the list of "plug-ins and JARs that contain annotation processors".</li>
        </ul>
        <p>
        </p>
        <p>
At the end we want to point that <code>@Yield</code> annotation is a syntactic suggar,
but it's important the way the foreach statement is important, as it helps to
write concise and an error free code.
</p>
        <p>
See also<br /><a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0525e835-90bf-4889-8706-6b0432624e57&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f11%2fYieldFeatureInJavaImplemented.aspx">Yield
feature in java implemented!</a><br /><a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0525e835-90bf-4889-8706-6b0432624e57&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f12%2f20%2fYieldFeatureInJava.aspx">Yield
feature in java</a></p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0525e835-90bf-4889-8706-6b0432624e57" />
      </body>
      <title>Yield return feature in java</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0525e835-90bf-4889-8706-6b0432624e57.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2011/01/24/YieldReturnFeatureInJava.aspx</link>
      <pubDate>Mon, 24 Jan 2011 10:23:53 GMT</pubDate>
      <description>&lt;p&gt;
We&amp;#39;re happy to announce that we have implemented &lt;code&gt;@Yield&lt;/code&gt; annotation
both in javac and in eclipse compilers.
&lt;/p&gt;
&lt;p&gt;
This way you get built-in IDE support for the feature!
&lt;/p&gt;
&lt;p&gt;
To download yield annotation processor please use the following link: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0525e835-90bf-4889-8706-6b0432624e57&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.zip"&gt;Yield.zip&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
It contains both yield annotation processor, and a test project.
&lt;/p&gt;
&lt;p&gt;
If you do not want to compile the sources, you can download &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0525e835-90bf-4889-8706-6b0432624e57&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.jar"&gt;Yield.jar&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
We would like to reiterate on how &lt;code&gt;@Yield&lt;/code&gt; annotation works:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
A developer defines a method that returns either &lt;code&gt;Iterator&amp;lt;T&amp;gt;&lt;/code&gt; or &lt;code&gt;Iterable&amp;lt;T&amp;gt;&lt;/code&gt; instance
and marks it with &lt;code&gt;@Yield&lt;/code&gt; annotation.&lt;/li&gt;
&lt;li&gt;
A developer implements iteration logic following the pattern:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;
declare a variable to accumulate results:&lt;br /&gt;
&lt;code&gt;ArrayList&amp;lt;T&amp;gt; items = new ArrayList&amp;lt;T&amp;gt;();&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
use the following statement to add item to result:&lt;br /&gt;
&lt;code&gt;items.add(...);&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
use&lt;br /&gt;
&lt;code&gt;return items;&lt;/code&gt; 
&lt;br /&gt;
or&lt;br /&gt;
&lt;code&gt;return items.iterator();&lt;br /&gt;
&lt;/code&gt;to return result;&lt;/li&gt;
&lt;li&gt;
mark method&amp;#39;s params, if any, as final.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
A devoloper ensures that yield annotation processor is available during compilation
(see details below).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;YieldProcessor&lt;/code&gt; rewrites method into a state machine at compilation time.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
The following is an example of such a method:
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em"&gt;
&lt;code&gt;@Yield&lt;br /&gt;
public static Iterable&amp;lt;Integer&amp;gt; generate(final int from, final int to)&lt;br /&gt;
{&lt;br /&gt;
ArrayList&amp;lt;Integer&amp;gt; items = new ArrayList&amp;lt;Integer&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
for(int i = from; i &amp;lt; to; ++i)&lt;br /&gt;
{&lt;br /&gt;
items.add(i);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return items;&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
The use is like this:
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em"&gt;
&lt;code&gt;for(int value: generate(7, 20))&lt;br /&gt;
{&lt;br /&gt;
System.out.println(&amp;quot;generator: &amp;quot; + value);&lt;br /&gt;
} &lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
Notice that method&amp;#39;s implementation still will be correct in absence of &lt;code&gt; YieldProcessor&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
Other important feature is that the state machine returned after the yield processor
is closeable.
&lt;/p&gt;
&lt;p&gt;
This means that if you&amp;#39;re breaking the iteration before the end is reached you
can release resources acquired during the iteration.
&lt;/p&gt;
&lt;p&gt;
Consider the example where break exits iteration:
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em"&gt;
&lt;code&gt;@Yield&lt;br /&gt;
public static Iterable&amp;lt;String&amp;gt; resourceIteration()&lt;br /&gt;
{&lt;br /&gt;
ArrayList&amp;lt;String&amp;gt; items = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
acquire();&lt;br /&gt;
&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
for(int i = 0; i &amp;lt; 100; ++i)&lt;br /&gt;
{&lt;br /&gt;
items.add(String.valueOf(i));&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
finally&lt;br /&gt;
{&lt;br /&gt;
release();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return items;&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
and the use
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em"&gt;
&lt;code&gt;int i = 0;&lt;br /&gt;
Iterable&amp;lt;String&amp;gt; iterator = resourceIteration();&lt;br /&gt;
&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
for(String item: iterator)&lt;br /&gt;
{&lt;br /&gt;
System.out.println(&amp;quot;item &amp;quot; + i + &amp;quot;:&amp;quot; + item);&lt;br /&gt;
&lt;br /&gt;
if (i++ &amp;gt; 30)&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;break&lt;/b&gt;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
finally&lt;br /&gt;
{&lt;br /&gt;
close(iterator);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
private static &amp;lt;T&amp;gt; void close(T value)&lt;br /&gt;
throws IOException&lt;br /&gt;
{&lt;br /&gt;
if (value instanceof Closeable)&lt;br /&gt;
{&lt;br /&gt;
Closeable closeable = (Closeable)value;&lt;br /&gt;
&lt;br /&gt;
closeable.close();&lt;br /&gt;
}&lt;br /&gt;
} &lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
Close will execute all required finally blocks. This way resources will be released.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
To configure yield processor a developer needs to refer Yield.jar in build path, as
it contains &lt;code&gt;@Yield&lt;/code&gt; annotation. For javac it&amp;#39;s enough, as compiler
will find annotation processor automatically.
&lt;/p&gt;
&lt;p&gt;
Eclipse users need to open project properties and:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
go to the &amp;quot;Java Compiler&amp;quot;/&amp;quot;Annotation Processing&amp;quot; 
&lt;/li&gt;
&lt;li&gt;
mark &amp;quot;Enable project specific settings&amp;quot;&lt;/li&gt;
&lt;li&gt;
select &amp;quot;Java Compiler&amp;quot;/&amp;quot;Annotation Processing&amp;quot;/&amp;quot;Factory Path&amp;quot;&lt;/li&gt;
&lt;li&gt;
mark &amp;quot;Enable project specific settings&amp;quot;&lt;/li&gt;
&lt;li&gt;
add Yield.jar to the list of &amp;quot;plug-ins and JARs that contain annotation processors&amp;quot;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
At the end we want to point that &lt;code&gt;@Yield&lt;/code&gt; annotation is a syntactic suggar,
but it&amp;#39;s important the way the foreach statement is important, as it helps to
write concise and an error free code.
&lt;/p&gt;
&lt;p&gt;
See also&lt;br /&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0525e835-90bf-4889-8706-6b0432624e57&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2011%2f01%2f11%2fYieldFeatureInJavaImplemented.aspx"&gt;Yield
feature in java implemented!&lt;/a&gt;
&lt;br /&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0525e835-90bf-4889-8706-6b0432624e57&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f12%2f20%2fYieldFeatureInJava.aspx"&gt;Yield
feature in java&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0525e835-90bf-4889-8706-6b0432624e57" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0525e835-90bf-4889-8706-6b0432624e57.aspx</comments>
      <category>Announce</category>
      <category>Java</category>
      <category>Thinking aloud</category>
      <category>Tips and tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=280d6e0d-1389-4566-9e0f-badef8530578</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,280d6e0d-1389-4566-9e0f-badef8530578.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,280d6e0d-1389-4566-9e0f-badef8530578.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=280d6e0d-1389-4566-9e0f-badef8530578</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
For some reason we never knew about instance initializer in java; on the other hand
static initializer is well known.
</p>
        <p style="padding-left: 1em;">
          <code> class A<br />
{<br />
int x;<br />
static int y;<br /><br />
// This is an instance initializer.<br />
{<br />
x = 1;<br />
}<br /><br />
// This is a static initializer.<br />
static<br />
{<br />
y = 2;<br />
}<br />
}</code>
        </p>
        <p>
Worse, we have missed it in the java grammar when we were building jxom. This way
jxom was missing the feature.
</p>
        <p>
Today we fix the miss and introduce a schema element:
</p>
        <p style="padding-left: 1em">
          <code>&lt;class-initializer static="boolean"&gt;<br />
&lt;block&gt;<br />
...<br />
&lt;/block&gt;<br />
&lt;/class-initializer&gt;</code>
        </p>
        <p>
It superseeds:
</p>
        <p style="padding-left: 1em">
          <code>&lt;static&gt;<br />
&lt;block&gt;<br />
...<br />
&lt;/block&gt;<br />
&lt;/static&gt;</code>
        </p>
        <p>
that supported static initializers alone.
</p>
        <p>
Please update <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=280d6e0d-1389-4566-9e0f-badef8530578&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"> languages-xom
xslt stylesheets</a>.
</p>
        <p>
P.S. Out of curiosity, did you ever see any use of instance initializers?
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=280d6e0d-1389-4566-9e0f-badef8530578" />
      </body>
      <title>Java XML Object Model Update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,280d6e0d-1389-4566-9e0f-badef8530578.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2011/01/14/JavaXMLObjectModelUpdate.aspx</link>
      <pubDate>Fri, 14 Jan 2011 21:29:04 GMT</pubDate>
      <description>&lt;p&gt;
For some reason we never knew about instance initializer in java; on the other hand
static initializer is well known.
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt; class A&lt;br /&gt;
{&lt;br /&gt;
int x;&lt;br /&gt;
static int y;&lt;br /&gt;
&lt;br /&gt;
// This is an instance initializer.&lt;br /&gt;
{&lt;br /&gt;
x = 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// This is a static initializer.&lt;br /&gt;
static&lt;br /&gt;
{&lt;br /&gt;
y = 2;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Worse, we have missed it in the java grammar when we were building jxom. This way
jxom was missing the feature.
&lt;/p&gt;
&lt;p&gt;
Today we fix the miss and introduce a schema element:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;&amp;lt;class-initializer static=&amp;quot;boolean&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;block&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/class-initializer&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
It superseeds:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;&amp;lt;static&amp;gt;&lt;br /&gt;
&amp;lt;block&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/static&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
that supported static initializers alone.
&lt;/p&gt;
&lt;p&gt;
Please update &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=280d6e0d-1389-4566-9e0f-badef8530578&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt; languages-xom
xslt stylesheets&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
P.S. Out of curiosity, did you ever see any use of instance initializers?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=280d6e0d-1389-4566-9e0f-badef8530578" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,280d6e0d-1389-4566-9e0f-badef8530578.aspx</comments>
      <category>Announce</category>
      <category>Java</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=ebd5185f-fc37-4e82-b2bb-006387635512</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,ebd5185f-fc37-4e82-b2bb-006387635512.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,ebd5185f-fc37-4e82-b2bb-006387635512.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=ebd5185f-fc37-4e82-b2bb-006387635512</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We could not stand the temptation to implement the <code>@Yield</code> annotation
that we described <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ebd5185f-fc37-4e82-b2bb-006387635512&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f12%2f20%2fYieldFeatureInJava.aspx">earlier</a>.
</p>
        <p>
Idea is rather clear but people are saying that it's not an easy task to update
the sources.
</p>
        <p>
They were right!
</p>
        <p>
Implementation has its price, as we were forced to access JDK's classes of javac
compiler. As result, at present, we don't support other compilers such as EclipseCompiler.
We shall look later what can be done in this area.
</p>
        <p>
At present, annotation processor works perfectly when you run javac either from the
command line, from ant, or from other build tool.
</p>
        <p>
Here is an example of how method is refactored:
</p>
        <p style="padding-left: 1em">
          <code>@Yield<br />
public static Iterable&lt;Long&gt; fibonachi()<br />
{<br />
ArrayList&lt;Long&gt; items = new ArrayList&lt;Long&gt;();<br /><br />
long Ti = 0;<br />
long Ti1 = 1;<br /><br />
while(true)<br />
{<br />
items.add(Ti);<br /><br />
long value = Ti + Ti1;<br /><br />
Ti = Ti1;<br />
Ti1 = value;<br />
}<br />
}</code>
        </p>
        <p>
And that's how we transform it:
</p>
        <p style="padding-left: 1em">
          <code>@Yield()<br />
public static Iterable&lt;Long&gt; fibonachi() {<br />
assert (java.util.ArrayList&lt;Long&gt;)(ArrayList&lt;Long&gt;)null == null : null;<br /><br />
class $state$ implements java.lang.Iterable&lt;Long&gt;, java.util.Iterator&lt;Long&gt;,
java.io.Closeable {<br /><br />
public java.util.Iterator&lt;Long&gt; iterator() {<br />
if ($state$id == 0) {<br />
$state$id = 1;<br />
return this;<br />
} else return new $state$();<br />
}<br /><br />
public boolean hasNext() {<br />
if (!$state$nextDefined) {<br />
$state$hasNext = $state$next();<br />
$state$nextDefined = true;<br />
}<br /><br />
return $state$hasNext;<br />
}<br /><br />
public Long next() {<br />
if (!hasNext()) throw new java.util.NoSuchElementException();<br /><br />
$state$nextDefined = false;<br /><br />
return $state$next;<br />
}<br /><br />
public void remove() {<br />
throw new java.lang.UnsupportedOperationException();<br />
}<br /><br />
public void close() {<br />
$state$id = 5;<br />
}<br /><br />
private boolean $state$next() {<br />
while (true) switch ($state$id) {<br />
case 0:<br />
$state$id = 1;<br />
case 1:<br />
Ti = 0;<br />
Ti1 = 1;<br />
case 2: 
<br />
if (!true) {<br />
$state$id = 4;<br />
break;<br />
}<br /><br />
$state$next = Ti;<br />
$state$id = 3;<br /><br />
return true;<br />
case 3: 
<br />
value = Ti + Ti1;<br />
Ti = Ti1;<br />
Ti1 = value;<br />
$state$id = 2;<br /><br />
break;<br />
case 4: 
<br />
case 5: 
<br />
default: 
<br />
$state$id = 5;<br /><br />
return false;<br />
}<br />
}<br /><br />
private long Ti;<br />
private long Ti1;<br />
private long value;<br />
private int $state$id;<br />
private boolean $state$hasNext;<br />
private boolean $state$nextDefined;<br />
private Long $state$next;<br />
}<br /><br />
return new $state$();<br />
}</code>
        </p>
        <p>
Formatting is automatic, sorry, but anyway it's for diagnostics only. You will
never see this code.
</p>
        <p>
It's iteresting to say that this implementation is very precisely mimics <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ebd5185f-fc37-4e82-b2bb-006387635512&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f09%2f05%2fWhatYouCanDoWithJxom.aspx"> xslt
state machine implementation</a> we have done back in 2008.
</p>
        <p>
You can <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ebd5185f-fc37-4e82-b2bb-006387635512&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.zip"> download
YieldProcessor here</a>. We hope that someone will find our solution very interesting.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=ebd5185f-fc37-4e82-b2bb-006387635512" />
      </body>
      <title>Yield feature in java implemented!</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,ebd5185f-fc37-4e82-b2bb-006387635512.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2011/01/11/YieldFeatureInJavaImplemented.aspx</link>
      <pubDate>Tue, 11 Jan 2011 16:08:41 GMT</pubDate>
      <description>&lt;p&gt;
We could not stand the temptation to implement the &lt;code&gt;@Yield&lt;/code&gt; annotation
that we described &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ebd5185f-fc37-4e82-b2bb-006387635512&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f12%2f20%2fYieldFeatureInJava.aspx"&gt;earlier&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Idea is rather clear but people are saying that it&amp;#39;s not an easy task to update
the sources.
&lt;/p&gt;
&lt;p&gt;
They were right!
&lt;/p&gt;
&lt;p&gt;
Implementation has its price, as we were forced to access JDK&amp;#39;s classes of javac
compiler. As result, at present, we don&amp;#39;t support other compilers such as EclipseCompiler.
We shall look later what can be done in this area.
&lt;/p&gt;
&lt;p&gt;
At present, annotation processor works perfectly when you run javac either from the
command line, from ant, or from other build tool.
&lt;/p&gt;
&lt;p&gt;
Here is an example of how method is refactored:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;@Yield&lt;br /&gt;
public static Iterable&amp;lt;Long&amp;gt; fibonachi()&lt;br /&gt;
{&lt;br /&gt;
ArrayList&amp;lt;Long&amp;gt; items = new ArrayList&amp;lt;Long&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
long Ti = 0;&lt;br /&gt;
long Ti1 = 1;&lt;br /&gt;
&lt;br /&gt;
while(true)&lt;br /&gt;
{&lt;br /&gt;
items.add(Ti);&lt;br /&gt;
&lt;br /&gt;
long value = Ti + Ti1;&lt;br /&gt;
&lt;br /&gt;
Ti = Ti1;&lt;br /&gt;
Ti1 = value;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
And that&amp;#39;s how we transform it:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;@Yield()&lt;br /&gt;
public static Iterable&amp;lt;Long&amp;gt; fibonachi() {&lt;br /&gt;
assert (java.util.ArrayList&amp;lt;Long&amp;gt;)(ArrayList&amp;lt;Long&amp;gt;)null == null : null;&lt;br /&gt;
&lt;br /&gt;
class $state$ implements java.lang.Iterable&amp;lt;Long&amp;gt;, java.util.Iterator&amp;lt;Long&amp;gt;,
java.io.Closeable {&lt;br /&gt;
&lt;br /&gt;
public java.util.Iterator&amp;lt;Long&amp;gt; iterator() {&lt;br /&gt;
if ($state$id == 0) {&lt;br /&gt;
$state$id = 1;&lt;br /&gt;
return this;&lt;br /&gt;
} else return new $state$();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public boolean hasNext() {&lt;br /&gt;
if (!$state$nextDefined) {&lt;br /&gt;
$state$hasNext = $state$next();&lt;br /&gt;
$state$nextDefined = true;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return $state$hasNext;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public Long next() {&lt;br /&gt;
if (!hasNext()) throw new java.util.NoSuchElementException();&lt;br /&gt;
&lt;br /&gt;
$state$nextDefined = false;&lt;br /&gt;
&lt;br /&gt;
return $state$next;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void remove() {&lt;br /&gt;
throw new java.lang.UnsupportedOperationException();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void close() {&lt;br /&gt;
$state$id = 5;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
private boolean $state$next() {&lt;br /&gt;
while (true) switch ($state$id) {&lt;br /&gt;
case 0:&lt;br /&gt;
$state$id = 1;&lt;br /&gt;
case 1:&lt;br /&gt;
Ti = 0;&lt;br /&gt;
Ti1 = 1;&lt;br /&gt;
case 2: 
&lt;br /&gt;
if (!true) {&lt;br /&gt;
$state$id = 4;&lt;br /&gt;
break;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$state$next = Ti;&lt;br /&gt;
$state$id = 3;&lt;br /&gt;
&lt;br /&gt;
return true;&lt;br /&gt;
case 3: 
&lt;br /&gt;
value = Ti + Ti1;&lt;br /&gt;
Ti = Ti1;&lt;br /&gt;
Ti1 = value;&lt;br /&gt;
$state$id = 2;&lt;br /&gt;
&lt;br /&gt;
break;&lt;br /&gt;
case 4: 
&lt;br /&gt;
case 5: 
&lt;br /&gt;
default: 
&lt;br /&gt;
$state$id = 5;&lt;br /&gt;
&lt;br /&gt;
return false;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
private long Ti;&lt;br /&gt;
private long Ti1;&lt;br /&gt;
private long value;&lt;br /&gt;
private int $state$id;&lt;br /&gt;
private boolean $state$hasNext;&lt;br /&gt;
private boolean $state$nextDefined;&lt;br /&gt;
private Long $state$next;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return new $state$();&lt;br /&gt;
}&lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
Formatting is automatic, sorry, but anyway it&amp;#39;s for diagnostics only. You will
never see this code.
&lt;/p&gt;
&lt;p&gt;
It&amp;#39;s iteresting to say that this implementation is very precisely mimics &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ebd5185f-fc37-4e82-b2bb-006387635512&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f09%2f05%2fWhatYouCanDoWithJxom.aspx"&gt; xslt
state machine implementation&lt;/a&gt; we have done back in 2008.
&lt;/p&gt;
&lt;p&gt;
You can &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ebd5185f-fc37-4e82-b2bb-006387635512&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjava%2fYield.zip"&gt; download
YieldProcessor here&lt;/a&gt;. We hope that someone will find our solution very interesting.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=ebd5185f-fc37-4e82-b2bb-006387635512" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,ebd5185f-fc37-4e82-b2bb-006387635512.aspx</comments>
      <category>Announce</category>
      <category>Thinking aloud</category>
      <category>Tips and tricks</category>
      <category>xslt</category>
      <category>Java</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=0ec082bb-83b9-4c85-9011-8e00fcf1f9ca</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0ec082bb-83b9-4c85-9011-8e00fcf1f9ca.aspx</pingback:target>
      <dc:creator>Arthur Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0ec082bb-83b9-4c85-9011-8e00fcf1f9ca.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=0ec082bb-83b9-4c85-9011-8e00fcf1f9ca</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
You might be interested in the following article that was written in form of a little
guide. It can educate about new ways to learn SQL and hopefully may help someone to
get a job. See <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0ec082bb-83b9-4c85-9011-8e00fcf1f9ca&amp;url=http%3a%2f%2fwww.sqlcertification.net%2fms-sql-server-certification" target="_blank">"How
to get MS SQL certification"</a> that was written by Michele Rouse.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0ec082bb-83b9-4c85-9011-8e00fcf1f9ca" />
      </body>
      <title>A guest article about DB certification</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0ec082bb-83b9-4c85-9011-8e00fcf1f9ca.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/12/22/AGuestArticleAboutDBCertification.aspx</link>
      <pubDate>Wed, 22 Dec 2010 13:16:49 GMT</pubDate>
      <description>&lt;p&gt;
You might be interested in the following article that was written in form of a little
guide. It can educate about new ways to learn SQL and hopefully may help someone to
get a job. See &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0ec082bb-83b9-4c85-9011-8e00fcf1f9ca&amp;amp;url=http%3a%2f%2fwww.sqlcertification.net%2fms-sql-server-certification" target=_blank&gt;"How
to get MS SQL certification"&lt;/a&gt; that was written by Michele Rouse.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0ec082bb-83b9-4c85-9011-8e00fcf1f9ca" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0ec082bb-83b9-4c85-9011-8e00fcf1f9ca.aspx</comments>
      <category>Announce</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=0fdc7420-9599-4b14-979f-5b95ec6df7c9</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0fdc7420-9599-4b14-979f-5b95ec6df7c9.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0fdc7420-9599-4b14-979f-5b95ec6df7c9.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=0fdc7420-9599-4b14-979f-5b95ec6df7c9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Historically <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d0fdc7420-9599-4b14-979f-5b95ec6df7c9%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252flanguages-xom.zip"> jxom</a> was
developed first, and as such exhibited some imperfectness in its xml schema. <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d0fdc7420-9599-4b14-979f-5b95ec6df7c9%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252flanguages-xom.zip"> csharpxom</a> has
taken into an account jxom's problems.
</p>
        <p>
Unfortunately we could not easily fix jxom as a great amount of code already uses
it. In this refactoring we tried to be conservative, and have changed only <code>"type"</code> and <code>"import"</code> xml
schema elements in java.xsd.
</p>
        <p>
Consider type reference and package import constructs in the old schema:
</p>
        <p style="PADDING-LEFT: 1em">
          <code>&lt;!-- import java.util.ArrayList; --&gt;<br />
&lt;import name="java.util.ArrayList"/&gt;<br /><br />
&lt;!-- java.util.ArrayList&lt;java.math.BigDecimal&gt; --&gt;<br />
&lt;type package="java.util"&gt;<br />
&lt;part name="ArrayList"&gt;<br />
&lt;argument&gt;<br />
&lt;type name="BigDecimal" package="java.math"&gt;<br />
&lt;/argument&gt;<br />
&lt;/part&gt;<br />
&lt;/type&gt;<br /><br />
&lt;!-- my.Parent.Nested --&gt;<br />
&lt;type package="my"&gt;<br />
&lt;part name="Parent"/&gt;<br />
&lt;part name="Nested"/&gt;<br />
&lt;type&gt;</code>
        </p>
        <p>
Here we can observe that:
</p>
        <ul>
          <li>
type is referred by a qualified name in import element;</li>
          <li>
type has two forms: simple (see BigDecimal), and other for nested or generic type
(see ArrayList).</li>
        </ul>
        <p>
We have made it more consistent in the updated jxom:
</p>
        <p style="PADDING-LEFT: 1em">
          <code>&lt;!-- import java.util.ArrayList; --&gt;<br />
&lt;import&gt;<br />
&lt;type name="ArrayList" package="java.util"/&gt;<br />
&lt;/import&gt;<br /><br />
&lt;!-- java.util.ArrayList&lt;java.math.BigDecimal&gt; --&gt;<br />
&lt;type name="ArrayList" package="java.util"&gt;<br />
&lt;argument&gt;<br />
&lt;type name="BigDecimal" package="java.math"&gt;<br />
&lt;/argument&gt;<br />
&lt;/type&gt;<br /><br />
&lt;!-- my.Parent.Nested --&gt;<br />
&lt;type name="Nested"&gt;<br />
&lt;type name="Parent" package="my"/&gt;<br />
&lt;type&gt;</code>
        </p>
        <p>
We hope that you will not be impacted very much by this fix.
</p>
        <p>
Please refresh Languages XOM from <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d0fdc7420-9599-4b14-979f-5b95ec6df7c9%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252flanguages-xom.zip"> languages-xom.zip</a>.
</p>
        <p>
P.S. we have also included xml schema and xslt api to generate ASPX (see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d0fdc7420-9599-4b14-979f-5b95ec6df7c9%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fweblog%252f2010%252f06%252f22%252fXsltSerializerForASPXOutput.aspx"> Xslt
serializer for ASPX output</a>). We, in fact, in our projects, generate aspx documents
with embedded csharpxom, and then pass it through two stage transformation.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9" />
      </body>
      <title>Languages xom update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0fdc7420-9599-4b14-979f-5b95ec6df7c9.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/11/01/LanguagesXomUpdate.aspx</link>
      <pubDate>Mon, 01 Nov 2010 15:48:19 GMT</pubDate>
      <description>  &lt;p&gt;
Historically &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d0fdc7420-9599-4b14-979f-5b95ec6df7c9%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252flanguages-xom.zip"&gt; jxom&lt;/a&gt; was
developed first, and as such exhibited some imperfectness in its xml schema. &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d0fdc7420-9599-4b14-979f-5b95ec6df7c9%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252flanguages-xom.zip"&gt; csharpxom&lt;/a&gt; has
taken into an account jxom&amp;#39;s problems.
&lt;/p&gt;
&lt;p&gt;
Unfortunately we could not easily fix jxom as a great amount of code already uses
it. In this refactoring we tried to be conservative, and have changed only &lt;code&gt;&amp;quot;type&amp;quot;&lt;/code&gt; and &lt;code&gt;&amp;quot;import&amp;quot;&lt;/code&gt; xml
schema elements in java.xsd.
&lt;/p&gt;
&lt;p&gt;
Consider type reference and package import constructs in the old schema:
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em"&gt;
&lt;code&gt;&amp;lt;!-- import java.util.ArrayList; --&amp;gt;&lt;br /&gt;
&amp;lt;import name=&amp;quot;java.util.ArrayList&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- java.util.ArrayList&amp;lt;java.math.BigDecimal&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;type package=&amp;quot;java.util&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;part name=&amp;quot;ArrayList&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;argument&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;BigDecimal&amp;quot; package=&amp;quot;java.math&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/argument&amp;gt;&lt;br /&gt;
&amp;lt;/part&amp;gt;&lt;br /&gt;
&amp;lt;/type&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- my.Parent.Nested --&amp;gt;&lt;br /&gt;
&amp;lt;type package=&amp;quot;my&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;part name=&amp;quot;Parent&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;part name=&amp;quot;Nested&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;type&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Here we can observe that:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
type is referred by a qualified name in import element;&lt;/li&gt;
&lt;li&gt;
type has two forms: simple (see BigDecimal), and other for nested or generic type
(see ArrayList).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
We have made it more consistent in the updated jxom:
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em"&gt;
&lt;code&gt;&amp;lt;!-- import java.util.ArrayList; --&amp;gt;&lt;br /&gt;
&amp;lt;import&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;ArrayList&amp;quot; package=&amp;quot;java.util&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/import&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- java.util.ArrayList&amp;lt;java.math.BigDecimal&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;ArrayList&amp;quot; package=&amp;quot;java.util&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;argument&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;BigDecimal&amp;quot; package=&amp;quot;java.math&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/argument&amp;gt;&lt;br /&gt;
&amp;lt;/type&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- my.Parent.Nested --&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;Nested&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;Parent&amp;quot; package=&amp;quot;my&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;type&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
We hope that you will not be impacted very much by this fix.
&lt;/p&gt;
&lt;p&gt;
Please refresh Languages XOM from &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d0fdc7420-9599-4b14-979f-5b95ec6df7c9%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252flanguages-xom.zip"&gt; languages-xom.zip&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
P.S. we have also included xml schema and xslt api to generate ASPX (see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d0fdc7420-9599-4b14-979f-5b95ec6df7c9%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fweblog%252f2010%252f06%252f22%252fXsltSerializerForASPXOutput.aspx"&gt; Xslt
serializer for ASPX output&lt;/a&gt;). We, in fact, in our projects, generate aspx documents
with embedded csharpxom, and then pass it through two stage transformation.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0fdc7420-9599-4b14-979f-5b95ec6df7c9" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0fdc7420-9599-4b14-979f-5b95ec6df7c9.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=8b73afea-b89b-417d-b61c-244eb46a8cb0</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,8b73afea-b89b-417d-b61c-244eb46a8cb0.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,8b73afea-b89b-417d-b61c-244eb46a8cb0.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=8b73afea-b89b-417d-b61c-244eb46a8cb0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f10%2f09%2fParseCOBOLIntoCobolxom.aspx">previous
post</a> we have announced an <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2fParser.sln">API
to parse a COBOL source into the cobolxom</a>.
</p>
        <p>
We exploited <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;url=http%3a%2f%2fsourceforge.net%2fprojects%2fincr-parser%2f">the
incremental parser</a> to build a grammar xml tree and then were planning to create
an xslt transformation to generate <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">cobolxom</a>.
</p>
        <p>
Now, we would like to declare that such xslt is ready.
</p>
        <p>
At present all standard COBOL constructs are supported, but more tests are required.
Preprocessor support is still in the todo list.
</p>
        <p>
You may peek into an examples of <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2fCobolTest%2fResources%2fKRFM428">COBOL</a>:
</p>
        <iframe src="https://incr-parser.svn.sourceforge.net/svnroot/incr-parser/Parser/branches/v2.VS2010/Parser/CobolTest/Resources/KRFM428" style="width: 100%; height: 15em;" scrolling="auto">
        </iframe>
        <p />
        <p>
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2fCobolTest%2fResources%2fcobol.xml">Cobol
grammar</a>:
</p>
        <iframe src="https://incr-parser.svn.sourceforge.net/svnroot/incr-parser/Parser/branches/v2.VS2010/Parser/CobolTest/Resources/cobol.xml" style="width: 100%; height: 15em;" scrolling="auto">
        </iframe>
        <p />
        <p>
And <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2fCobolTest%2fResources%2fcobolxom.xml">cobolxom</a>:
</p>
        <iframe src="https://incr-parser.svn.sourceforge.net/svnroot/incr-parser/Parser/branches/v2.VS2010/Parser/CobolTest/Resources/cobolxom.xml" style="width: 100%; height: 15em;" scrolling="auto">
        </iframe>
        <p>
While we were building a grammar to cobolxom stylesheet we asked ourselves whether
the COBOL parsing could be done entirely in xslt. The answer is yes, so who knows
it might be that we shall turn this task into pure xslt one. :-)
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0" />
      </body>
      <title>Parse COBOL into cobolxom, #2</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,8b73afea-b89b-417d-b61c-244eb46a8cb0.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/10/22/ParseCOBOLIntoCobolxom2.aspx</link>
      <pubDate>Fri, 22 Oct 2010 13:24:31 GMT</pubDate>
      <description>&lt;p&gt;
In the &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f10%2f09%2fParseCOBOLIntoCobolxom.aspx"&gt;previous
post&lt;/a&gt; we have announced an &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2fParser.sln"&gt;API
to parse a COBOL source into the cobolxom&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
We exploited &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;amp;url=http%3a%2f%2fsourceforge.net%2fprojects%2fincr-parser%2f"&gt;the
incremental parser&lt;/a&gt; to build a grammar xml tree and then were planning to create
an xslt transformation to generate &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt;cobolxom&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Now, we would like to declare that such xslt is ready.
&lt;/p&gt;
&lt;p&gt;
At present all standard COBOL constructs are supported, but more tests are required.
Preprocessor support is still in the todo list.
&lt;/p&gt;
&lt;p&gt;
You may peek into an examples of &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2fCobolTest%2fResources%2fKRFM428"&gt;COBOL&lt;/a&gt;:
&lt;/p&gt;
&lt;iframe src="https://incr-parser.svn.sourceforge.net/svnroot/incr-parser/Parser/branches/v2.VS2010/Parser/CobolTest/Resources/KRFM428" style="width: 100%; height: 15em;" scrolling="auto"&gt;
&lt;/iframe&gt;
&lt;p /&gt;
&lt;p&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2fCobolTest%2fResources%2fcobol.xml"&gt;Cobol
grammar&lt;/a&gt;:
&lt;/p&gt;
&lt;iframe src="https://incr-parser.svn.sourceforge.net/svnroot/incr-parser/Parser/branches/v2.VS2010/Parser/CobolTest/Resources/cobol.xml" style="width: 100%; height: 15em;" scrolling="auto"&gt;
&lt;/iframe&gt;
&lt;p /&gt;
&lt;p&gt;
And &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0&amp;amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2fCobolTest%2fResources%2fcobolxom.xml"&gt;cobolxom&lt;/a&gt;:
&lt;/p&gt;
&lt;iframe src="https://incr-parser.svn.sourceforge.net/svnroot/incr-parser/Parser/branches/v2.VS2010/Parser/CobolTest/Resources/cobolxom.xml" style="width: 100%; height: 15em;" scrolling="auto"&gt;
&lt;/iframe&gt;
&lt;p&gt;
While we were building a grammar to cobolxom stylesheet we asked ourselves whether
the COBOL parsing could be done entirely in xslt. The answer is yes, so who knows
it might be that we shall turn this task into pure xslt one. :&amp;#x2d;)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=8b73afea-b89b-417d-b61c-244eb46a8cb0" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,8b73afea-b89b-417d-b61c-244eb46a8cb0.aspx</comments>
      <category>Announce</category>
      <category>Incremental Parser</category>
      <category>Thinking aloud</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=7f371b0a-d51c-4de6-ac88-32536e7d04e0</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,7f371b0a-d51c-4de6-ac88-32536e7d04e0.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,7f371b0a-d51c-4de6-ac88-32536e7d04e0.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=7f371b0a-d51c-4de6-ac88-32536e7d04e0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Once ago we have created an <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2009%2f03%2f08%2fIncrementalParser.aspx"> incremental
parser</a>, and now when we have decided to load COBOL sources directly into <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2009%2f12%2f27%2fAdditionToXOMFamily.aspx"> cobolxom
(XML Object Model for a COBOL)</a> the parser did the job perfectly.
</p>
        <p>
The good point about incremental parser is that it easily handles COBOL's grammar.
</p>
        <p>
The whole process looks like this:
</p>
        <ol>
          <li>
incremental parser having a COBOL grammar builds a grammar tree;</li>
          <li>
we stream this tree into xml;</li>
          <li>
xslt to transform xml from previous step into <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">cobolxom</a> (TODO).</li>
        </ol>
        <p>
This is an example of a COBOL:
</p>
        <p style="PADDING-LEFT: 1em">
          <code>IDENTIFICATION DIVISION.<br />
PROGRAM-ID. FACTORIAL RECURSIVE.<br /><br />
DATA DIVISION.<br />
WORKING-STORAGE SECTION.<br />
01 NUMB PIC 9(4) VALUE IS 5.<br />
01 FACT PIC 9(8) VALUE IS 0.<br /><br />
LOCAL-STORAGE SECTION.<br />
01 NUM PIC 9(4).<br /><br />
PROCEDURE DIVISION.<br />
MOVE 'X' TO XXX<br />
MOVE NUMB TO NUM<br /><br />
IF NUMB = 0 THEN<br />
MOVE 1 TO FACT<br />
ELSE<br />
SUBTRACT 1 FROM NUMB<br />
CALL 'FACTORIAL'<br />
MULTIPLY NUM BY FACT<br />
END-IF<br /><br />
DISPLAY NUM '! = ' FACT<br /><br />
GOBACK.<br />
END PROGRAM FACTORIAL.</code>
        </p>
        <p>
And a grammar tree:
</p>
        <p style="PADDING-LEFT: 1em">
          <code>&lt;Program&gt;<br />
&lt;Name data="FACTORIAL"/&gt;<br />
&lt;Recursive/&gt;<br />
&lt;DataDivision&gt;<br />
&lt;WorkingStorageSection&gt;<br />
&lt;Data&gt;<br />
&lt;Level data="01"/&gt;<br />
&lt;Name data="NUMB"/&gt;<br />
&lt;Picture data="9(4)"/&gt;<br />
&lt;Value&gt;<br />
&lt;Numeric data="5"/&gt;<br />
&lt;/Value&gt;<br />
&lt;/Data&gt;<br />
&lt;Data&gt;<br />
&lt;Level data="01"/&gt;<br />
&lt;Name data="FACT"/&gt;<br />
&lt;Picture data="9(8)"/&gt;<br />
&lt;Value&gt;<br />
&lt;Numeric data="0"/&gt;<br />
&lt;/Value&gt;<br />
&lt;/Data&gt;<br />
&lt;/WorkingStorageSection&gt;<br />
&lt;LocalStorageSection&gt;<br />
&lt;Data&gt;<br />
&lt;Level data="01"/&gt;<br />
&lt;Name data="NUM"/&gt;<br />
&lt;Picture data="9(4)"/&gt;<br />
&lt;/Data&gt;<br />
&lt;/LocalStorageSection&gt;<br />
&lt;/DataDivision&gt;<br />
&lt;ProcedureDivision&gt;<br />
&lt;Sentence&gt;<br />
&lt;MoveStatement&gt;<br />
&lt;From&gt;<br />
&lt;String data="'X'"/&gt;<br />
&lt;/From&gt;<br />
&lt;To&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="XXX"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;/To&gt;<br />
&lt;/MoveStatement&gt;<br />
&lt;MoveStatement&gt;<br />
&lt;From&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="NUMB"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;/From&gt;<br />
&lt;To&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="NUM"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;/To&gt;<br />
&lt;/MoveStatement&gt;<br />
&lt;IfStatement&gt;<br />
&lt;Condition&gt;<br />
&lt;Relation&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="NUMB"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;Equal/&gt;<br />
&lt;Numeric data="0"/&gt;<br />
&lt;/Relation&gt;<br />
&lt;/Condition&gt;<br />
&lt;Then&gt;<br />
&lt;MoveStatement&gt;<br />
&lt;From&gt;<br />
&lt;Numeric data="1"/&gt;<br />
&lt;/From&gt;<br />
&lt;To&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="FACT"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;/To&gt;<br />
&lt;/MoveStatement&gt;<br />
&lt;/Then&gt;<br />
&lt;Else&gt;<br />
&lt;SubtractStatement&gt;<br />
&lt;Value&gt;<br />
&lt;Numeric data="1"/&gt;<br />
&lt;/Value&gt;<br />
&lt;From&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="NUMB"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;/From&gt;<br />
&lt;/SubtractStatement&gt;<br />
&lt;CallStatement&gt;<br />
&lt;Name&gt;<br />
&lt;String data="'FACTORIAL'"/&gt;<br />
&lt;/Name&gt;<br />
&lt;/CallStatement&gt;<br />
&lt;MultiplyStatement&gt;<br />
&lt;Value&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="NUM"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;/Value&gt;<br />
&lt;By&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="FACT"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;/By&gt;<br />
&lt;/MultiplyStatement&gt;<br />
&lt;/Else&gt;<br />
&lt;/IfStatement&gt;<br />
&lt;DisplayStatement&gt;<br />
&lt;Values&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="NUM"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;String data="'! = '"/&gt;<br />
&lt;Identifier&gt;<br />
&lt;DataName data="FACT"/&gt;<br />
&lt;/Identifier&gt;<br />
&lt;/Values&gt;<br />
&lt;/DisplayStatement&gt;<br />
&lt;GobackStatement/&gt;<br />
&lt;/Sentence&gt;<br />
&lt;/ProcedureDivision&gt;<br />
&lt;EndName data="FACTORIAL"/&gt;<br />
&lt;/Program&gt;</code>
        </p>
        <p>
The last step is to transform tree into cobolxom is in the TODO list.
</p>
        <p>
We have commited COBOL grammar in the same place at <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0&amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2f"> SourceForge</a> as
it was with XQuery grammar. Solution is now under the VS 2010.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0" />
      </body>
      <title>Parse COBOL into cobolxom</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,7f371b0a-d51c-4de6-ac88-32536e7d04e0.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/10/09/ParseCOBOLIntoCobolxom.aspx</link>
      <pubDate>Sat, 09 Oct 2010 08:26:23 GMT</pubDate>
      <description>  &lt;p&gt;
Once ago we have created an &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2009%2f03%2f08%2fIncrementalParser.aspx"&gt; incremental
parser&lt;/a&gt;, and now when we have decided to load COBOL sources directly into &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2009%2f12%2f27%2fAdditionToXOMFamily.aspx"&gt; cobolxom
(XML Object Model for a COBOL)&lt;/a&gt; the parser did the job perfectly.
&lt;/p&gt;
&lt;p&gt;
The good point about incremental parser is that it easily handles COBOL&amp;#39;s grammar.
&lt;/p&gt;
&lt;p&gt;
The whole process looks like this:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
incremental parser having a COBOL grammar builds a grammar tree;&lt;/li&gt;
&lt;li&gt;
we stream this tree into xml;&lt;/li&gt;
&lt;li&gt;
xslt to transform xml from previous step into &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt;cobolxom&lt;/a&gt; (TODO).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
This is an example of a COBOL:
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em"&gt;
&lt;code&gt;IDENTIFICATION DIVISION.&lt;br /&gt;
PROGRAM-ID. FACTORIAL RECURSIVE.&lt;br /&gt;
&lt;br /&gt;
DATA DIVISION.&lt;br /&gt;
WORKING-STORAGE SECTION.&lt;br /&gt;
01 NUMB PIC 9(4) VALUE IS 5.&lt;br /&gt;
01 FACT PIC 9(8) VALUE IS 0.&lt;br /&gt;
&lt;br /&gt;
LOCAL-STORAGE SECTION.&lt;br /&gt;
01 NUM PIC 9(4).&lt;br /&gt;
&lt;br /&gt;
PROCEDURE DIVISION.&lt;br /&gt;
MOVE &amp;#39;X&amp;#39; TO XXX&lt;br /&gt;
MOVE NUMB TO NUM&lt;br /&gt;
&lt;br /&gt;
IF NUMB = 0 THEN&lt;br /&gt;
MOVE 1 TO FACT&lt;br /&gt;
ELSE&lt;br /&gt;
SUBTRACT 1 FROM NUMB&lt;br /&gt;
CALL &amp;#39;FACTORIAL&amp;#39;&lt;br /&gt;
MULTIPLY NUM BY FACT&lt;br /&gt;
END-IF&lt;br /&gt;
&lt;br /&gt;
DISPLAY NUM &amp;#39;! = &amp;#39; FACT&lt;br /&gt;
&lt;br /&gt;
GOBACK.&lt;br /&gt;
END PROGRAM FACTORIAL.&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
And a grammar tree:
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em"&gt;
&lt;code&gt;&amp;lt;Program&amp;gt;&lt;br /&gt;
&amp;lt;Name data=&amp;quot;FACTORIAL&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Recursive/&amp;gt;&lt;br /&gt;
&amp;lt;DataDivision&amp;gt;&lt;br /&gt;
&amp;lt;WorkingStorageSection&amp;gt;&lt;br /&gt;
&amp;lt;Data&amp;gt;&lt;br /&gt;
&amp;lt;Level data=&amp;quot;01&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Name data=&amp;quot;NUMB&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Picture data=&amp;quot;9(4)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Value&amp;gt;&lt;br /&gt;
&amp;lt;Numeric data=&amp;quot;5&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Value&amp;gt;&lt;br /&gt;
&amp;lt;/Data&amp;gt;&lt;br /&gt;
&amp;lt;Data&amp;gt;&lt;br /&gt;
&amp;lt;Level data=&amp;quot;01&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Name data=&amp;quot;FACT&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Picture data=&amp;quot;9(8)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Value&amp;gt;&lt;br /&gt;
&amp;lt;Numeric data=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Value&amp;gt;&lt;br /&gt;
&amp;lt;/Data&amp;gt;&lt;br /&gt;
&amp;lt;/WorkingStorageSection&amp;gt;&lt;br /&gt;
&amp;lt;LocalStorageSection&amp;gt;&lt;br /&gt;
&amp;lt;Data&amp;gt;&lt;br /&gt;
&amp;lt;Level data=&amp;quot;01&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Name data=&amp;quot;NUM&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Picture data=&amp;quot;9(4)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Data&amp;gt;&lt;br /&gt;
&amp;lt;/LocalStorageSection&amp;gt;&lt;br /&gt;
&amp;lt;/DataDivision&amp;gt;&lt;br /&gt;
&amp;lt;ProcedureDivision&amp;gt;&lt;br /&gt;
&amp;lt;Sentence&amp;gt;&lt;br /&gt;
&amp;lt;MoveStatement&amp;gt;&lt;br /&gt;
&amp;lt;From&amp;gt;&lt;br /&gt;
&amp;lt;String data=&amp;quot;&amp;#39;X&amp;#39;&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/From&amp;gt;&lt;br /&gt;
&amp;lt;To&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;XXX&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;/To&amp;gt;&lt;br /&gt;
&amp;lt;/MoveStatement&amp;gt;&lt;br /&gt;
&amp;lt;MoveStatement&amp;gt;&lt;br /&gt;
&amp;lt;From&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;NUMB&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;/From&amp;gt;&lt;br /&gt;
&amp;lt;To&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;NUM&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;/To&amp;gt;&lt;br /&gt;
&amp;lt;/MoveStatement&amp;gt;&lt;br /&gt;
&amp;lt;IfStatement&amp;gt;&lt;br /&gt;
&amp;lt;Condition&amp;gt;&lt;br /&gt;
&amp;lt;Relation&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;NUMB&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;Equal/&amp;gt;&lt;br /&gt;
&amp;lt;Numeric data=&amp;quot;0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Relation&amp;gt;&lt;br /&gt;
&amp;lt;/Condition&amp;gt;&lt;br /&gt;
&amp;lt;Then&amp;gt;&lt;br /&gt;
&amp;lt;MoveStatement&amp;gt;&lt;br /&gt;
&amp;lt;From&amp;gt;&lt;br /&gt;
&amp;lt;Numeric data=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/From&amp;gt;&lt;br /&gt;
&amp;lt;To&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;FACT&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;/To&amp;gt;&lt;br /&gt;
&amp;lt;/MoveStatement&amp;gt;&lt;br /&gt;
&amp;lt;/Then&amp;gt;&lt;br /&gt;
&amp;lt;Else&amp;gt;&lt;br /&gt;
&amp;lt;SubtractStatement&amp;gt;&lt;br /&gt;
&amp;lt;Value&amp;gt;&lt;br /&gt;
&amp;lt;Numeric data=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Value&amp;gt;&lt;br /&gt;
&amp;lt;From&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;NUMB&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;/From&amp;gt;&lt;br /&gt;
&amp;lt;/SubtractStatement&amp;gt;&lt;br /&gt;
&amp;lt;CallStatement&amp;gt;&lt;br /&gt;
&amp;lt;Name&amp;gt;&lt;br /&gt;
&amp;lt;String data=&amp;quot;&amp;#39;FACTORIAL&amp;#39;&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Name&amp;gt;&lt;br /&gt;
&amp;lt;/CallStatement&amp;gt;&lt;br /&gt;
&amp;lt;MultiplyStatement&amp;gt;&lt;br /&gt;
&amp;lt;Value&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;NUM&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;/Value&amp;gt;&lt;br /&gt;
&amp;lt;By&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;FACT&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;/By&amp;gt;&lt;br /&gt;
&amp;lt;/MultiplyStatement&amp;gt;&lt;br /&gt;
&amp;lt;/Else&amp;gt;&lt;br /&gt;
&amp;lt;/IfStatement&amp;gt;&lt;br /&gt;
&amp;lt;DisplayStatement&amp;gt;&lt;br /&gt;
&amp;lt;Values&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;NUM&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;String data=&amp;quot;&amp;#39;! = &amp;#39;&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;Identifier&amp;gt;&lt;br /&gt;
&amp;lt;DataName data=&amp;quot;FACT&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Identifier&amp;gt;&lt;br /&gt;
&amp;lt;/Values&amp;gt;&lt;br /&gt;
&amp;lt;/DisplayStatement&amp;gt;&lt;br /&gt;
&amp;lt;GobackStatement/&amp;gt;&lt;br /&gt;
&amp;lt;/Sentence&amp;gt;&lt;br /&gt;
&amp;lt;/ProcedureDivision&amp;gt;&lt;br /&gt;
&amp;lt;EndName data=&amp;quot;FACTORIAL&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/Program&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
The last step is to transform tree into cobolxom is in the TODO list.
&lt;/p&gt;
&lt;p&gt;
We have commited COBOL grammar in the same place at &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0&amp;amp;url=https%3a%2f%2fincr-parser.svn.sourceforge.net%2fsvnroot%2fincr-parser%2fParser%2fbranches%2fv2.VS2010%2fParser%2f"&gt; SourceForge&lt;/a&gt; as
it was with XQuery grammar. Solution is now under the VS 2010.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=7f371b0a-d51c-4de6-ac88-32536e7d04e0" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,7f371b0a-d51c-4de6-ac88-32536e7d04e0.aspx</comments>
      <category>Announce</category>
      <category>Incremental Parser</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=c4aa3698-e8d1-4448-a523-67373417718a</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,c4aa3698-e8d1-4448-a523-67373417718a.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,c4aa3698-e8d1-4448-a523-67373417718a.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=c4aa3698-e8d1-4448-a523-67373417718a</wfw:commentRss>
      <title>C# XOM Update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,c4aa3698-e8d1-4448-a523-67373417718a.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/08/04/CXOMUpdate.aspx</link>
      <pubDate>Wed, 04 Aug 2010 14:00:26 GMT</pubDate>
      <description>&lt;p&gt;
We have updated C# XOM (csharpxom) to support C# 4.0 (in fact there are very few changes).
&lt;/p&gt;
&lt;p&gt;
From the grammar perspective this includes:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Dynamic types;&lt;/li&gt;
&lt;li&gt;
Named and optional arguments;&lt;/li&gt;
&lt;li&gt;
Covariance and contravariance of generic parameters for interfaces and delegates.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Dynamic type, C#:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt; dynamic dyn = 1;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
C# XOM:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt; &amp;lt;var name=&amp;quot;dyn&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;dynamic&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;initialize&amp;gt;&lt;br /&gt;
&amp;lt;int value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/initialize&amp;gt;&lt;br /&gt;
&amp;lt;/var&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Named and Optional Arguments, C#:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt; int Increment(int value, int increment = 1)&lt;br /&gt;
{&lt;br /&gt;
return value + increment;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Test() 
&lt;br /&gt;
{&lt;br /&gt;
// Regular call.&lt;br /&gt;
Increment(7, 1);&lt;br /&gt;
&lt;br /&gt;
// Call with named parameter.&lt;br /&gt;
Increment(value: 7, increment: 1);&lt;br /&gt;
&lt;br /&gt;
// Call with default.&lt;br /&gt;
Increment(7); 
&lt;br /&gt;
}&lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
C# XOM:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt; &amp;lt;method name=&amp;quot;Increment&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;returns&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;int&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/returns&amp;gt;&lt;br /&gt;
&amp;lt;parameters&amp;gt;&lt;br /&gt;
&amp;lt;parameter name=&amp;quot;value&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;int&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/parameter&amp;gt;&lt;br /&gt;
&amp;lt;parameter name=&amp;quot;increment&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;int&amp;quot;/&amp;gt;&lt;br       &amp;lt;type name=&amp;quot;int&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;initialize&amp;gt;&lt;br /&gt;
&amp;lt;int value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/initialize&amp;gt;&lt;br /&gt;
&amp;lt;/parameter&amp;gt;&lt;br /&gt;
&amp;lt;/parameters&amp;gt;&lt;br /&gt;
&amp;lt;block&amp;gt;&lt;br /&gt;
&amp;lt;return&amp;gt;&lt;br /&gt;
&amp;lt;add&amp;gt;&lt;br /&gt;
&amp;lt;var-ref name=&amp;quot;value&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;var-ref name=&amp;quot;increment&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/add&amp;gt;&lt;br /&gt;
&amp;lt;/return&amp;gt; 
&lt;br /&gt;
&amp;lt;/block&amp;gt;&lt;br /&gt;
&amp;lt;/method&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;method name=&amp;quot;Test&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;block&amp;gt;&lt;br /&gt;
&amp;lt;expression&amp;gt;&lt;br /&gt;
&amp;lt;comment&amp;gt;Regular call.&amp;lt;/comment&amp;gt;&lt;br /&gt;
&amp;lt;invoke&amp;gt;&lt;br /&gt;
&amp;lt;method-ref name=&amp;quot;Increment&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arguments&amp;gt;&lt;br /&gt;
&amp;lt;int value=&amp;quot;7&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;int value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/arguments&amp;gt;&lt;br /&gt;
&amp;lt;/invoke&amp;gt;&lt;br /&gt;
&amp;lt;/expression&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;expression&amp;gt;&lt;br /&gt;
&amp;lt;comment&amp;gt;Call with named parameter.&amp;lt;/comment&amp;gt;&lt;br /&gt;
&amp;lt;invoke&amp;gt;&lt;br /&gt;
&amp;lt;method-ref name=&amp;quot;Increment&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arguments&amp;gt;&lt;br /&gt;
&amp;lt;argument name=&amp;quot;value&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;int value=&amp;quot;7&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/argument&amp;gt;&lt;br /&gt;
&amp;lt;argument name=&amp;quot;increment&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;int value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/argument&amp;gt;&lt;br /&gt;
&amp;lt;/arguments&amp;gt;&lt;br /&gt;
&amp;lt;/invoke&amp;gt;&lt;br /&gt;
&amp;lt;/expression&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;expression&amp;gt;&lt;br /&gt;
&amp;lt;comment&amp;gt;Call with default.&amp;lt;/comment&amp;gt;&lt;br /&gt;
&amp;lt;invoke&amp;gt;&lt;br /&gt;
&amp;lt;method-ref name=&amp;quot;Increment&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;arguments&amp;gt;&lt;br /&gt;
&amp;lt;int value=&amp;quot;7&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/arguments&amp;gt;&lt;br /&gt;
&amp;lt;/invoke&amp;gt;&lt;br /&gt;
&amp;lt;/expression&amp;gt;&lt;br /&gt;
&amp;lt;/block&amp;gt; 
&lt;br /&gt;
&amp;lt;/method&amp;gt;&lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
Covariance and contravariance, C#:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;public interface Variance&amp;lt;in T, out P, Q&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
P X(T t); 
&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
C# XOM:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt; &amp;lt;interface access=&amp;quot;public&amp;quot; name=&amp;quot;Variance&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;type-parameters&amp;gt;&lt;br /&gt;
&amp;lt;type-parameter name=&amp;quot;T&amp;quot; variance=&amp;quot;in&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;type-parameter name=&amp;quot;P&amp;quot; variance=&amp;quot;out&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;type-parameter name=&amp;quot;Q&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/type-parameters&amp;gt;&lt;br /&gt;
&amp;lt;method name=&amp;quot;X&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;returns&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;P&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/returns&amp;gt;&lt;br /&gt;
&amp;lt;parameters&amp;gt;&lt;br /&gt;
&amp;lt;parameter name=&amp;quot;t&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;type name=&amp;quot;T&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/parameter&amp;gt;&lt;br /&gt;
&amp;lt;/parameters&amp;gt;&lt;br /&gt;
&amp;lt;/method&amp;gt; 
&lt;br /&gt;
&amp;lt;/interface&amp;gt;&lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
Other cosmetic fixes were also introduced into Java XOM (jxom), COBOL XOM (cobolxom),
and into sql XOM (sqlxom).
&lt;/p&gt;
&lt;p&gt;
The new version is found at &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c4aa3698-e8d1-4448-a523-67373417718a&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt; languages-xom.zip&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
See also: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c4aa3698-e8d1-4448-a523-67373417718a&amp;amp;url=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fbb383815.aspx"&gt;What&amp;#39;s
New in Visual C# 2010&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=c4aa3698-e8d1-4448-a523-67373417718a" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,c4aa3698-e8d1-4448-a523-67373417718a.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=bd5a8c26-7bf7-4103-8f45-02e0a970efec</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,bd5a8c26-7bf7-4103-8f45-02e0a970efec.aspx</pingback:target>
      <dc:creator>Arthur Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,bd5a8c26-7bf7-4103-8f45-02e0a970efec.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=bd5a8c26-7bf7-4103-8f45-02e0a970efec</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently we were raising a <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;url=http%3a%2f%2fthread.gmane.org%2fgmane.text.xml.xsl.general.mulberrytech%2f80506">question
about serialization of ASPX output in xslt</a>.
</p>
        <p>
The question went like this:
</p>
        <p style="PADDING-LEFT: 1em; FONT-STYLE: italic">
What's the recommended way of ASPX page generation?<br />
E.g.:<br /><br />
------------------------<br />
 &lt;%@ Page AutoEventWireup="true"<br />
   CodeBehind="CurMainMenuP.aspx.cs"<br />
   EnableSessionState="True"<br />
   Inherits="Currency.CurMainMenuP"<br />
   Language="C#"<br />
   MaintainScrollPositionOnPostback="True"<br />
   MasterPageFile="Screen.Master" %&gt;<br /><br />
&lt;asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Title"&gt;CUR_MAIN_MENU_P&lt;/asp:Content&gt;<br /><br />
&lt;asp:Content ID="Content2" runat="server" ContentPlaceHolderID="Content"&gt;<br />
  &lt;span id="id1222146581" runat="server" 
<br />
    class="inputField system UpperCase" enableviewstate="false"&gt;<br />
    &lt;%# Dialog.Global.TranCode %&gt;<br />
  &lt;/span&gt;<br />
  ...<br />
------------------------<br /><br />
Notice aspx page directives, data binding expessions, and prefixed tag names without
namespace declarations.
</p>
        <p>
There was a whole range of expected answers. We, however, looked whether somebody
have already dealed with the task and has a ready solution at hands.
</p>
        <p>
In general it seems that xslt community is very angry about ASPX: both format and
technology. Well, put this aside.
</p>
        <p>
The task of producing ASPX, which is <b>almost</b> xml, is not solvable when you're
staying with pure xml serializer. Xslt's <code><a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;url=http%3a%2f%2fwww.w3.org%2fTR%2fxslt20%2f%23element-character-map">xsl:character-map</a></code> does
not work at all. In fact it looks as a childish attempt to address the problem, as
it does not support character escapes but only grabs characters and substitutes them
with strings.
</p>
        <p>
We have decided to create ASPX serializer API producing required output text. This
way you use <code>&lt;xsl:output method="text"/&gt;</code> to generate ASPX pages.
</p>
        <p>
With this goal in mind we have defined a little xml schema to describe ASPX irregularities
in xml form. These are:
</p>
        <ul>
          <li>
            <code>&lt;xs:element name="declared-prefix"&gt;</code> - to describe known prefixes,
which should not be declared; 
</li>
          <li>
            <code>&lt;xs:element name="directive"&gt;</code> - to describe directives like &lt;%@
Page %&gt;; 
</li>
          <li>
            <code>&lt;xs:element name="content"&gt;</code> - a transparent content wrapper; 
</li>
          <li>
            <code>&lt;xs:element name="entity"&gt;</code> - to issue xml entity; 
</li>
          <li>
            <code>&lt;xs:element name="expression"&gt;</code> - to describe aspx expression like
&lt;%# Eval("A") %&gt;; 
</li>
          <li>
            <code>&lt;xs:element name="attribute"&gt;</code> - to describe an attribute of the
parent element. 
</li>
        </ul>
        <p>
This approach greately simplified for us an ASPX generation process.
</p>
        <p>
The API includes:
</p>
        <ul>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fasp.net%2faspx.xsd">aspx.xsd</a> -
an xml schema for the ASPX elements; 
</li>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fasp.net%2faspx-serializer.xslt">aspx-serializer.xslt</a> -
a serializer API; 
</li>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fasp.net%2faspx-test.xslt">aspx-test.xslt</a> -
a test stylesheet (any xml input is used). 
</li>
        </ul>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec" />
      </body>
      <title>Xslt serializer for ASPX output</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,bd5a8c26-7bf7-4103-8f45-02e0a970efec.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/06/22/XsltSerializerForASPXOutput.aspx</link>
      <pubDate>Tue, 22 Jun 2010 10:25:41 GMT</pubDate>
      <description>&lt;p&gt;
Recently we were raising a &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;amp;url=http%3a%2f%2fthread.gmane.org%2fgmane.text.xml.xsl.general.mulberrytech%2f80506"&gt;question
about serialization of ASPX output in xslt&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
The question went like this:
&lt;/p&gt;
&lt;p style="PADDING-LEFT: 1em; FONT-STYLE: italic"&gt;
What's the recommended way of ASPX page generation?&lt;br&gt;
E.g.:&lt;br&gt;
&lt;br&gt;
------------------------&lt;br&gt;
&amp;nbsp;&amp;lt;%@ Page AutoEventWireup="true"&lt;br&gt;
&amp;nbsp;&amp;nbsp; CodeBehind="CurMainMenuP.aspx.cs"&lt;br&gt;
&amp;nbsp;&amp;nbsp; EnableSessionState="True"&lt;br&gt;
&amp;nbsp;&amp;nbsp; Inherits="Currency.CurMainMenuP"&lt;br&gt;
&amp;nbsp;&amp;nbsp; Language="C#"&lt;br&gt;
&amp;nbsp;&amp;nbsp; MaintainScrollPositionOnPostback="True"&lt;br&gt;
&amp;nbsp;&amp;nbsp; MasterPageFile="Screen.Master" %&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Title"&amp;gt;CUR_MAIN_MENU_P&amp;lt;/asp:Content&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;asp:Content ID="Content2" runat="server" ContentPlaceHolderID="Content"&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;span id="id1222146581" runat="server" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; class="inputField system UpperCase" enableviewstate="false"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;%# Dialog.Global.TranCode %&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/span&amp;gt;&lt;br&gt;
&amp;nbsp; ...&lt;br&gt;
------------------------&lt;br&gt;
&lt;br&gt;
Notice aspx page directives, data binding expessions, and prefixed tag names without
namespace declarations.
&lt;/p&gt;
&lt;p&gt;
There was a whole range of expected answers. We, however, looked whether somebody
have already dealed with the task and has a ready solution at hands.
&lt;/p&gt;
&lt;p&gt;
In general it seems that xslt community is very angry about ASPX: both format and
technology. Well, put this aside.
&lt;/p&gt;
&lt;p&gt;
The task of producing ASPX, which is &lt;b&gt;almost&lt;/b&gt; xml, is not solvable when you're
staying with pure xml serializer. Xslt's &lt;code&gt;&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;amp;url=http%3a%2f%2fwww.w3.org%2fTR%2fxslt20%2f%23element-character-map"&gt;xsl:character-map&lt;/a&gt;&lt;/code&gt; does
not work at all. In fact it looks as a childish attempt to address the problem, as
it does not support character escapes but only grabs characters and substitutes them
with strings.
&lt;/p&gt;
&lt;p&gt;
We have decided to create ASPX serializer API producing required output text. This
way you use &lt;code&gt;&amp;lt;xsl:output method="text"/&amp;gt;&lt;/code&gt; to generate ASPX pages.
&lt;/p&gt;
&lt;p&gt;
With this goal in mind we have defined a little xml schema to describe ASPX irregularities
in xml form. These are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;xs:element name="declared-prefix"&amp;gt;&lt;/code&gt; - to describe known prefixes,
which should not be declared; 
&lt;li&gt;
&lt;code&gt;&amp;lt;xs:element name="directive"&amp;gt;&lt;/code&gt; - to describe directives like &amp;lt;%@
Page %&amp;gt;; 
&lt;li&gt;
&lt;code&gt;&amp;lt;xs:element name="content"&amp;gt;&lt;/code&gt; - a transparent content wrapper; 
&lt;li&gt;
&lt;code&gt;&amp;lt;xs:element name="entity"&amp;gt;&lt;/code&gt; - to issue xml entity; 
&lt;li&gt;
&lt;code&gt;&amp;lt;xs:element name="expression"&amp;gt;&lt;/code&gt; - to describe aspx expression like
&amp;lt;%# Eval("A") %&amp;gt;; 
&lt;li&gt;
&lt;code&gt;&amp;lt;xs:element name="attribute"&amp;gt;&lt;/code&gt; - to describe an attribute of the
parent element. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
This approach greately simplified for us an ASPX generation process.
&lt;/p&gt;
&lt;p&gt;
The API includes:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fasp.net%2faspx.xsd"&gt;aspx.xsd&lt;/a&gt; -
an xml schema for the ASPX elements; 
&lt;li&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fasp.net%2faspx-serializer.xslt"&gt;aspx-serializer.xslt&lt;/a&gt; -
a serializer API; 
&lt;li&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fasp.net%2faspx-test.xslt"&gt;aspx-test.xslt&lt;/a&gt; -
a test stylesheet (any xml input is used). 
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=bd5a8c26-7bf7-4103-8f45-02e0a970efec" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,bd5a8c26-7bf7-4103-8f45-02e0a970efec.aspx</comments>
      <category>Announce</category>
      <category>ASP.NET</category>
      <category>Thinking aloud</category>
      <category>Tips and tricks</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We have implemented report parser in C#. Bacause things are spinned around C#, a schema
definition is changed.
</p>
        <p>
We have started from classes defining a report definition tree, annotated these classes
for xml serialization, and, finally, produced xml schema for such tree. So, at present,
it is not an xml schema with annotations but a separate xml schema.
</p>
        <p>
In addition we have defined APIs:
</p>
        <ul>
          <li>
to enumerate report data (having report definition and report data one can get <code>IEnumerable&lt;ViewValue&gt;</code> to
iterate report data in structured form);</li>
          <li>
to read report through <code>XmlReader</code>, which allows, for example, to have
report as input for an xslt tranformation.</li>
          <li>
to write report directly into <code>XmlWriter</code>.</li>
        </ul>
        <p>
An example of report definition as C# code is: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252freports%252fMyReport.cs.txt"> MyReport.cs</a>.
The very same report definition but serialized into xml is <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252freports%252fmy-report.xml"> my-report.xml</a>.
A generated xml schema for a report definition is: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252freports%252fschema0.xsd"> schema0.xsd</a>.
</p>
        <p>
The good point about this solution is that it's already flexible enough to describe
every report layout we have at hands, and it's extendable. Our measurments show
that report parsing is extremely fast and have very small memory footprint due to
forward only nature of report definitions.
</p>
        <p>
From the design point of view report definition is a view of original text data with
view info attached.
</p>
        <p>
At present we have defined following views:
</p>
        <ul>
          <li>
Element - a named view to generate output from a content view;</li>
          <li>
 Content - a view to aggregate other views together;</li>
          <li>
Choice - a view to produce output from one of content views;</li>
          <li>
Sequence - a view to sequence input view by key expressions, and to attach an index
to each sequence item;</li>
          <li>
Iterator - a view to generate output from input view while some condition is true,
and to attach an iteration index to each part of output view;</li>
          <li>
Page - a view to remove page headers and footers in the input view, and to attach
an index to each page;</li>
          <li>
Compute - a named view to produce result of evaluation of expression as output view;</li>
          <li>
 Data - a named view to produce output value from some bounds of input view,
and optionally to convert, validate and format the value.</li>
        </ul>
        <p>
To specify details of definitions there are:
</p>
        <ul>
          <li>
expressions to deal with integers: <code>Add</code>, <code>Div</code>, <code> Integer</code>, <code>MatchProperty</code>, <code>Max</code>, <code>Min</code>, <code>Mod</code>, <code>Mul</code>, <code>Neg</code>, <code>Null</code>, <code> Sub</code>, <code>VariableRef</code>, <code>ViewProperty</code>, <code>Case</code>; 
</li>
          <li>
conditions to deal with booleans: <code>And</code>, <code>EQ</code>, <code>GE</code>, <code>GT</code>, <code>IsMatch</code>, <code>LE</code>, <code>LT</code>, <code> NE</code>, <code>Not</code>, <code>Or</code>.</li>
        </ul>
        <p>
At present there is no a specification of a report definitions. Probably, it's
the most complex part to create such a spec for a user without deep knowledge. At
present, our idea is that one should use xml schema (we should polish generated schema)
for the report definition and schema aware editor to build report definitions. That's
very robust approach working perfectly with <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252flanguages-xom.zip"> languages
xom</a>.
</p>
        <p>
C# sources can be found at: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252freports%252fReportLayout.zip"> ReportLayout.zip</a> including
report definition classes and a sample report.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b" />
      </body>
      <title>Parsing Reports V2, C#</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/05/14/ParsingReportsV2C.aspx</link>
      <pubDate>Fri, 14 May 2010 12:45:42 GMT</pubDate>
      <description>  &lt;p&gt;
We have implemented report parser in C#. Bacause things are spinned around C#, a schema
definition is changed.
&lt;/p&gt;
&lt;p&gt;
We have started from classes defining a report definition tree, annotated these classes
for xml serialization, and, finally, produced xml schema for such tree. So, at present,
it is not an xml schema with annotations but a separate xml schema.
&lt;/p&gt;
&lt;p&gt;
In addition we have defined APIs:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
to enumerate report data (having report definition and report data one can get &lt;code&gt;IEnumerable&amp;lt;ViewValue&amp;gt;&lt;/code&gt; to
iterate report data in structured form);&lt;/li&gt;
&lt;li&gt;
to read report through &lt;code&gt;XmlReader&lt;/code&gt;, which allows, for example, to have
report as input for an xslt tranformation.&lt;/li&gt;
&lt;li&gt;
to write report directly into &lt;code&gt;XmlWriter&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
An example of report definition as C# code is: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252freports%252fMyReport.cs.txt"&gt; MyReport.cs&lt;/a&gt;.
The very same report definition but serialized into xml is &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252freports%252fmy-report.xml"&gt; my-report.xml&lt;/a&gt;.
A generated xml schema for a report definition is: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252freports%252fschema0.xsd"&gt; schema0.xsd&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
The good point about this solution is that it&amp;#39;s already flexible enough to describe
every report layout we have at hands, and it&amp;#39;s extendable. Our measurments show
that report parsing is extremely fast and have very small memory footprint due to
forward only nature of report definitions.
&lt;/p&gt;
&lt;p&gt;
From the design point of view report definition is a view of original text data with
view info attached.
&lt;/p&gt;
&lt;p&gt;
At present we have defined following views:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Element - a named view to generate output from a content view;&lt;/li&gt;
&lt;li&gt;
&amp;nbsp;Content - a view to aggregate other views together;&lt;/li&gt;
&lt;li&gt;
Choice - a view to produce output from one of content views;&lt;/li&gt;
&lt;li&gt;
Sequence - a view to sequence input view by key expressions, and to attach an index
to each sequence item;&lt;/li&gt;
&lt;li&gt;
Iterator - a view to generate output from input view while some condition is true,
and to attach an iteration index to each part of output view;&lt;/li&gt;
&lt;li&gt;
Page - a view to remove page headers and footers in the input view, and to attach
an index to each page;&lt;/li&gt;
&lt;li&gt;
Compute - a named view to produce result of evaluation of expression as output view;&lt;/li&gt;
&lt;li&gt;
&amp;nbsp;Data - a named view to produce output value from some bounds of input view,
and optionally to convert, validate and format the value.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
To specify details of definitions there are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
expressions to deal with integers: &lt;code&gt;Add&lt;/code&gt;, &lt;code&gt;Div&lt;/code&gt;, &lt;code&gt; Integer&lt;/code&gt;, &lt;code&gt;MatchProperty&lt;/code&gt;, &lt;code&gt;Max&lt;/code&gt;, &lt;code&gt;Min&lt;/code&gt;, &lt;code&gt;Mod&lt;/code&gt;, &lt;code&gt;Mul&lt;/code&gt;, &lt;code&gt;Neg&lt;/code&gt;, &lt;code&gt;Null&lt;/code&gt;, &lt;code&gt; Sub&lt;/code&gt;, &lt;code&gt;VariableRef&lt;/code&gt;, &lt;code&gt;ViewProperty&lt;/code&gt;, &lt;code&gt;Case&lt;/code&gt;; 
&lt;/li&gt;
&lt;li&gt;
conditions to deal with booleans: &lt;code&gt;And&lt;/code&gt;, &lt;code&gt;EQ&lt;/code&gt;, &lt;code&gt;GE&lt;/code&gt;, &lt;code&gt;GT&lt;/code&gt;, &lt;code&gt;IsMatch&lt;/code&gt;, &lt;code&gt;LE&lt;/code&gt;, &lt;code&gt;LT&lt;/code&gt;, &lt;code&gt; NE&lt;/code&gt;, &lt;code&gt;Not&lt;/code&gt;, &lt;code&gt;Or&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
At present there is no a specification of a report definitions. Probably, it&amp;#39;s
the most complex part to create such a spec for a user without deep knowledge. At
present, our idea is that one should use xml schema (we should polish generated schema)
for the report definition and schema aware editor to build report definitions. That&amp;#39;s
very robust approach working perfectly with &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252flanguages-xom.zip"&gt; languages
xom&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
C# sources can be found at: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2fct.ashx%3fid%3d4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b%26url%3dhttp%253a%252f%252fwww.nesterovsky-bros.com%252fdownload%252freports%252fReportLayout.zip"&gt; ReportLayout.zip&lt;/a&gt; including
report definition classes and a sample report.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,4bd12ef0-e5cb-47a3-a7af-d60bc3fddd2b.aspx</comments>
      <category>Announce</category>
      <category>Thinking aloud</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=997d3d31-cfc8-4555-99a9-0321a5e9bcf2</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,997d3d31-cfc8-4555-99a9-0321a5e9bcf2.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,997d3d31-cfc8-4555-99a9-0321a5e9bcf2.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=997d3d31-cfc8-4555-99a9-0321a5e9bcf2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <img src="http://www.nesterovsky-bros.com/images/Ribbon_of_Saint_George.png" title="Memory of our grand parents" alt="Ribbon of Saint George" style="float: right" />
        <p>
We're facing a task of parsing reports produced from legacy applications and converting
them into a structured form, e.g. into xml. These xml files can be processed further
with up to date tools to produce good looking reports.
</p>
        <p>
Reports at hands are of very different structure and of size: from a couple of KB
to a several GB. The good part is that they mostly have a tabular form, so it's
easy to think of specific parsers in case of each report type.
</p>
        <p>
Our goal is to create an environment where a less qualified person(s) could create
and manage such parsers, and only rarely to engage someone who will handle less untrivial
cases.
</p>
        <p>
Our analysis has shown that it's possible to write such parser in almost any language:
xslt, C#, java.
</p>
        <p>
Our approach was to create an xml schema annotations that from one side define a data
structure, and from the other map report layout. Then we're able to create an
xslt that will generate either xslt, C#, or java parser according to the schema definitions.
Because of <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=997d3d31-cfc8-4555-99a9-0321a5e9bcf2&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">languages
xom</a>, providing XML Object Model and serialization stylesheets for C# and java,
it does not really matter what we shall generate xslt or C#/java, as code will look
the same.
</p>
        <p>
The approach we're going to use to describe reports is not as powerfull as conventional
parsers. Its virtue, however, is simplicity of specification.
</p>
        <p>
Consider a report sample (a data to extract is in bold):
</p>
        <pre style="padding-left: 1em;">1 TITLE ...                    PAGE:            1
 BUSINESS DATE: <b>09/30/09</b> ...
RUN DATE: 02/23/10 CYCLE : ITD RUN: 001 ... RUN TIME: 09:22:39 CM BUS ... CO NBR FRM
FUNC ... ----- ----- ----- ----- <b>XXX</b><b>065</b><b>065</b><b>CLR</b> ... <b>YYY</b> ...
... 1 TITLE ... PAGE: 2 BUSINESS DATE: 09/30/09 ... RUN DATE: 02/23/10 CYCLE : ITD
RUN: 001 ... RUN TIME: 09:22:39 CM BUS ... CO NBR FRM FUNC ... ----- ----- ----- ----- <b>AAA</b><b>NNN</b><b>MMM</b><b>PPP</b> ... <b>BBB</b> ...
... * * * * * E N D O F R E P O R T * * * * *</pre>
        <p>
We're approaching to the report through a sequence of views (filters) of this
report. Each veiw localizes some report data either for the subsequent filterring
or for the extraction of final data.
</p>
        <p>
Looking into the example one can build following views of the report:
</p>
        <ol>
          <li>
View of data before the "E N D   O F   R E P O R T"
line.</li>
          <li>
View of remaining data without page headers and footers.</li>
          <li>
Views of table rows.</li>
          <li>
Views of cells.</li>
        </ol>
        <p>
A sequence of filters allows us to build a pipeline of transformations of original
text. This also allows us to generate a clean xslt, C# or java code to parse the data.
</p>
        <p>
At first, our favorite language for such parser was xslt. Unfortunatelly, we're
dealing with Saxon xslt implementation, which is not very strong in streaming processing.
Without a couple of extension functions to prevent caching, it tends to cache whole
input in the memory, which is not acceptable.
</p>
        <p>
At present we have decided to start from C# code, which is pure C# naturally. :-)
</p>
        <p>
Code still is in the development but at present we would like to share the xml schema
annotations describing report layout: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=997d3d31-cfc8-4555-99a9-0321a5e9bcf2&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2freports%2freport-mapping.xsd"> report-mapping.xsd</a>,
and a sample of report description: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=997d3d31-cfc8-4555-99a9-0321a5e9bcf2&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2freports%2ftest.xsd">test.xsd</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=997d3d31-cfc8-4555-99a9-0321a5e9bcf2" />
      </body>
      <title>Parsing reports</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,997d3d31-cfc8-4555-99a9-0321a5e9bcf2.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/05/09/ParsingReports.aspx</link>
      <pubDate>Sun, 09 May 2010 05:18:57 GMT</pubDate>
      <description>&lt;img src="http://www.nesterovsky-bros.com/images/Ribbon_of_Saint_George.png" title="Memory of our grand parents" alt="Ribbon of Saint George" style="float: right" /&gt; 
&lt;p&gt;
We&amp;#39;re facing a task of parsing reports produced from legacy applications and converting
them into a structured form, e.g. into xml. These xml files can be processed further
with up to date tools to produce good looking reports.
&lt;/p&gt;
&lt;p&gt;
Reports at hands are of very different structure and of size: from a couple of KB
to a several GB. The good part is that they mostly have a tabular form, so it&amp;#39;s
easy to think of specific parsers in case of each report type.
&lt;/p&gt;
&lt;p&gt;
Our goal is to create an environment where a less qualified person(s) could create
and manage such parsers, and only rarely to engage someone who will handle less untrivial
cases.
&lt;/p&gt;
&lt;p&gt;
Our analysis has shown that it&amp;#39;s possible to write such parser in almost any language:
xslt, C#, java.
&lt;/p&gt;
&lt;p&gt;
Our approach was to create an xml schema annotations that from one side define a data
structure, and from the other map report layout. Then we&amp;#39;re able to create an
xslt that will generate either xslt, C#, or java parser according to the schema definitions.
Because of &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=997d3d31-cfc8-4555-99a9-0321a5e9bcf2&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt;languages
xom&lt;/a&gt;, providing XML Object Model and serialization stylesheets for C# and java,
it does not really matter what we shall generate xslt or C#/java, as code will look
the same.
&lt;/p&gt;
&lt;p&gt;
The approach we&amp;#39;re going to use to describe reports is not as powerfull as conventional
parsers. Its virtue, however, is simplicity of specification.
&lt;/p&gt;
&lt;p&gt;
Consider a report sample (a data to extract is in bold):
&lt;/p&gt;
&lt;pre style="padding-left: 1em;"&gt;1 TITLE ...                    PAGE:            1
 BUSINESS DATE: &lt;b&gt;09/30/09&lt;/b&gt; ...
RUN DATE: 02/23/10 CYCLE : ITD RUN: 001 ... RUN TIME: 09:22:39 CM BUS ... CO NBR FRM
FUNC ... ----- ----- ----- ----- &lt;b&gt;XXX&lt;/b&gt; &lt;b&gt;065&lt;/b&gt; &lt;b&gt;065&lt;/b&gt; &lt;b&gt;CLR&lt;/b&gt; ... &lt;b&gt;YYY&lt;/b&gt; ...
... 1 TITLE ... PAGE: 2 BUSINESS DATE: 09/30/09 ... RUN DATE: 02/23/10 CYCLE : ITD
RUN: 001 ... RUN TIME: 09:22:39 CM BUS ... CO NBR FRM FUNC ... ----- ----- ----- ----- &lt;b&gt;AAA&lt;/b&gt; &lt;b&gt;NNN&lt;/b&gt; &lt;b&gt;MMM&lt;/b&gt; &lt;b&gt;PPP&lt;/b&gt; ... &lt;b&gt;BBB&lt;/b&gt; ...
... * * * * * E N D O F R E P O R T * * * * *&lt;/pre&gt;
&lt;p&gt;
We&amp;#39;re approaching to the report through a sequence of views (filters) of this
report. Each veiw localizes some report data either for the subsequent filterring
or for the extraction of final data.
&lt;/p&gt;
&lt;p&gt;
Looking into the example one can build following views of the report:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
View of data before the &amp;quot;E N D&amp;nbsp;&amp;nbsp; O F&amp;nbsp;&amp;nbsp; R E P O R T&amp;quot;
line.&lt;/li&gt;
&lt;li&gt;
View of remaining data without page headers and footers.&lt;/li&gt;
&lt;li&gt;
Views of table rows.&lt;/li&gt;
&lt;li&gt;
Views of cells.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
A sequence of filters allows us to build a pipeline of transformations of original
text. This also allows us to generate a clean xslt, C# or java code to parse the data.
&lt;/p&gt;
&lt;p&gt;
At first, our favorite language for such parser was xslt. Unfortunatelly, we&amp;#39;re
dealing with Saxon xslt implementation, which is not very strong in streaming processing.
Without a couple of extension functions to prevent caching, it tends to cache whole
input in the memory, which is not acceptable.
&lt;/p&gt;
&lt;p&gt;
At present we have decided to start from C# code, which is pure C# naturally. :-)
&lt;/p&gt;
&lt;p&gt;
Code still is in the development but at present we would like to share the xml schema
annotations describing report layout: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=997d3d31-cfc8-4555-99a9-0321a5e9bcf2&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2freports%2freport-mapping.xsd"&gt; report-mapping.xsd&lt;/a&gt;,
and a sample of report description: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=997d3d31-cfc8-4555-99a9-0321a5e9bcf2&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2freports%2ftest.xsd"&gt;test.xsd&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=997d3d31-cfc8-4555-99a9-0321a5e9bcf2" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,997d3d31-cfc8-4555-99a9-0321a5e9bcf2.aspx</comments>
      <category>Announce</category>
      <category>Thinking aloud</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=00dd8c3a-9063-4a09-b3fb-5dc55e98954c</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,00dd8c3a-9063-4a09-b3fb-5dc55e98954c.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,00dd8c3a-9063-4a09-b3fb-5dc55e98954c.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=00dd8c3a-9063-4a09-b3fb-5dc55e98954c</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A few little changes in streaming and in name normalization algorithms in jxom and
in csharpxom and the generation speed almost doubled (especially for big files).
</p>
        <p>
We suspect, however, that our xslt code is tuned for saxon engine. 
</p>
        <p>
It would be nice to know if anybody used languages XOM with other engines. Is anyone
using it at all (well, at least there are downloads)?
</p>
        <p>
Languages XOM (jxom, csharpxom, cobolxom, sqlxom) can be loaded from: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=00dd8c3a-9063-4a09-b3fb-5dc55e98954c&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"> languages-xom.zip</a></p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=00dd8c3a-9063-4a09-b3fb-5dc55e98954c" />
      </body>
      <title>Languages XOM update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,00dd8c3a-9063-4a09-b3fb-5dc55e98954c.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/05/05/LanguagesXOMUpdate.aspx</link>
      <pubDate>Wed, 05 May 2010 06:48:10 GMT</pubDate>
      <description>&lt;p&gt;
A few little changes in streaming and in name normalization algorithms in jxom and
in csharpxom and the generation speed almost doubled (especially for big files).
&lt;/p&gt;
&lt;p&gt;
We suspect, however, that our xslt code is tuned for saxon engine. 
&lt;/p&gt;
&lt;p&gt;
It would be nice to know if anybody used languages XOM with other engines. Is anyone
using it at all (well, at least there are downloads)?
&lt;/p&gt;
&lt;p&gt;
Languages XOM (jxom, csharpxom, cobolxom, sqlxom) can be loaded from: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=00dd8c3a-9063-4a09-b3fb-5dc55e98954c&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt; languages-xom.zip&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=00dd8c3a-9063-4a09-b3fb-5dc55e98954c" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,00dd8c3a-9063-4a09-b3fb-5dc55e98954c.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=ccb28496-2a41-45b4-92f5-195861912562</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,ccb28496-2a41-45b4-92f5-195861912562.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,ccb28496-2a41-45b4-92f5-195861912562.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=ccb28496-2a41-45b4-92f5-195861912562</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When time has come to process big xml log files we've decided to implement streamable
tree in saxon the very same way it was implemented in .net eight years ago (see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ccb28496-2a41-45b4-92f5-195861912562&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f04%2f04%2fHowWouldWeApproachToStreamingFacilityInXslt.aspx"> How
would we approach to streaming facility in xslt</a>).
</p>
        <p>
It's interesting enough that the implementation is similar to one of <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ccb28496-2a41-45b4-92f5-195861912562&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f04%2f08%2fComposableTreeModelInSaxon.aspx"> composable
tree</a>. There a node never stores a reference to a parent, while in the streamed
tree no references to children are stored. This way only a limited subview of tree
is available at any time. Implementation does not support preceding and preceding-sibling
axes. Also, one cannot navigate to a node that is out of scope.
</p>
        <p>
Implementation is external (there are no changes to saxon itself). To use it one needs
to create an instance of <code>DocumentInfo</code>, which pulls data from <code><a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ccb28496-2a41-45b4-92f5-195861912562&amp;url=http%3a%2f%2fjava.sun.com%2fjavase%2f6%2fdocs%2fapi%2fjavax%2fxml%2fstream%2fXMLStreamReader.html">XMLStreamReader</a></code>,
and to pass it as an input to a transformation:
</p>
        <p style="padding-left: 1em">
          <code>Controller controller = (Controller)transformer; 
<br />
XMLInputFactory factory = XMLInputFactory.newInstance();<br />
StreamSource inputSource = new StreamSource(new File(input)); 
<br />
XMLStreamReader reader = factory.createXMLStreamReader(inputSource);<br />
StaxBridge bridge = new StaxBridge(); 
<br /><br />
bridge.setPipelineConfiguration(<br />
  controller.makePipelineConfiguration());<br />
bridge.setXMLStreamReader(reader); 
<br />
inputSource = new DocumentImpl(bridge);<br /><br />
transformer.transform(inputSource, new StreamResult(output));</code>
        </p>
        <p>
This helped us to format an xml log file of arbitrary size. An xslt like this can
do the work:
</p>
        <p>
          <code> &lt;xsl:stylesheet version="2.0"<br />
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<br />
  xmlns:xs="http://www.w3.org/2001/XMLSchema"<br />
  xmlns="http://www.w3.org/1999/xhtml"<br />
  exclude-result-prefixes="xs"&gt;<br /><br />
  &lt;xsl:template match="/log"&gt;<br />
    &lt;html&gt;<br />
      &lt;head&gt;<br />
        &lt;title&gt;Log&lt;/title&gt;<br />
      &lt;/head&gt;<br />
      &lt;body&gt;<br />
        &lt;xsl:apply-templates/&gt; 
<br />
      &lt;/body&gt;<br />
    &lt;/html&gt;<br />
  &lt;/xsl:template&gt;<br /><br />
  &lt;xsl:template match="message"&gt;<br />
   ... 
<br />
  &lt;/xsl:template&gt;<br /><br />
  &lt;xsl:template match="message[@error]"&gt;<br />
    ... 
<br />
  &lt;/xsl:template&gt; 
<br /><br />
  ... 
<br /><br />
&lt;/xsl:stylesheet&gt;</code>
        </p>
        <p>
Implementation can be found at: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ccb28496-2a41-45b4-92f5-195861912562&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon%2fstreamedtree.zip"> streamedtree.zip</a></p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=ccb28496-2a41-45b4-92f5-195861912562" />
      </body>
      <title>Streamed tree</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,ccb28496-2a41-45b4-92f5-195861912562.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/04/21/StreamedTree.aspx</link>
      <pubDate>Wed, 21 Apr 2010 07:10:34 GMT</pubDate>
      <description>&lt;p&gt;
When time has come to process big xml log files we&amp;#39;ve decided to implement streamable
tree in saxon the very same way it was implemented in .net eight years ago (see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ccb28496-2a41-45b4-92f5-195861912562&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f04%2f04%2fHowWouldWeApproachToStreamingFacilityInXslt.aspx"&gt; How
would we approach to streaming facility in xslt&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
It&amp;#39;s interesting enough that the implementation is similar to one of &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ccb28496-2a41-45b4-92f5-195861912562&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f04%2f08%2fComposableTreeModelInSaxon.aspx"&gt; composable
tree&lt;/a&gt;. There a node never stores a reference to a parent, while in the streamed
tree no references to children are stored. This way only a limited subview of tree
is available at any time. Implementation does not support preceding and preceding-sibling
axes. Also, one cannot navigate to a node that is out of scope.
&lt;/p&gt;
&lt;p&gt;
Implementation is external (there are no changes to saxon itself). To use it one needs
to create an instance of &lt;code&gt;DocumentInfo&lt;/code&gt;, which pulls data from &lt;code&gt; &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ccb28496-2a41-45b4-92f5-195861912562&amp;amp;url=http%3a%2f%2fjava.sun.com%2fjavase%2f6%2fdocs%2fapi%2fjavax%2fxml%2fstream%2fXMLStreamReader.html"&gt;XMLStreamReader&lt;/a&gt;&lt;/code&gt;,
and to pass it as an input to a transformation:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;Controller controller = (Controller)transformer; 
&lt;br /&gt;
XMLInputFactory factory = XMLInputFactory.newInstance();&lt;br /&gt;
StreamSource inputSource = new StreamSource(new File(input)); 
&lt;br /&gt;
XMLStreamReader reader = factory.createXMLStreamReader(inputSource);&lt;br /&gt;
StaxBridge bridge = new StaxBridge(); 
&lt;br /&gt;
&lt;br /&gt;
bridge.setPipelineConfiguration(&lt;br /&gt;
&amp;nbsp; controller.makePipelineConfiguration());&lt;br /&gt;
bridge.setXMLStreamReader(reader); 
&lt;br /&gt;
inputSource = new DocumentImpl(bridge);&lt;br /&gt;
&lt;br /&gt;
transformer.transform(inputSource, new StreamResult(output));&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
This helped us to format an xml log file of arbitrary size. An xslt like this can
do the work:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt; &amp;lt;xsl:stylesheet version=&amp;quot;2.0&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;br /&gt;
&amp;nbsp; exclude-result-prefixes=&amp;quot;xs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:template match=&amp;quot;/log&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;html&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;head&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;Log&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;body&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:apply-templates/&amp;gt; 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:template match=&amp;quot;message&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; ... 
&lt;br /&gt;
&amp;nbsp; &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:template match=&amp;quot;message[@error]&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ... 
&lt;br /&gt;
&amp;nbsp; &amp;lt;/xsl:template&amp;gt; 
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; ... 
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Implementation can be found at: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ccb28496-2a41-45b4-92f5-195861912562&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon%2fstreamedtree.zip"&gt; streamedtree.zip&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=ccb28496-2a41-45b4-92f5-195861912562" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,ccb28496-2a41-45b4-92f5-195861912562.aspx</comments>
      <category>Announce</category>
      <category>Thinking aloud</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Earlier, in the entry "<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f03%2f22%2fInlineFunctionsInXslt21.aspx">Inline
functions in xslt 2.1</a>" we've described an implementation of xml tree model
that may share subtrees among different trees.
</p>
        <p>
This way, in a code:
</p>
        <p style="padding-left: 1em">
          <code>&lt;xsl:variable name="elements" as="element()*" select="..."/&gt;<br /><br />
&lt;xsl:variable name="result" as="element()"&gt;<br />
  &lt;result&gt;<br />
    &lt;xsl:sequence select="$elements"/&gt;<br />
  &lt;/result&gt;<br />
&lt;/xsl:variable&gt;</code>
        </p>
        <p>
the implementation shares internal representation among <code>$elements</code> and
subtree of <code>$result</code>. From the perspective of xslt it looks as completely
different subtrees with different node identities, which is in the accordance with
its view of the world.
</p>
        <p>
After a short study we've decided to create a research implementation of this tree
model in saxon. It's took only a couple of days to introduce a minimal changes to
engine, to refactor linked tree into a new composable tree, and to perform some tests.
</p>
        <p>
In many cases saxon has benefited immediately from this new tree model, in some other
cases more tunings are required.
</p>
        <p>
Our tests've showed that this new tree performed better than linked tree, but a little
bit worser than tiny tree. On the other hand, it's obvious that conventional code
patterns avoid subtree copying, assuming it's expensive operation, thus one should
rethink some code practices to benefit from composable tree.
</p>
        <p>
Implementation can be downloaded at: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.composabletree.zip"> saxon.composabletree.zip</a></p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a" />
      </body>
      <title>Composable tree model in saxon</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2010/04/08/ComposableTreeModelInSaxon.aspx</link>
      <pubDate>Thu, 08 Apr 2010 06:26:02 GMT</pubDate>
      <description>&lt;p&gt;
Earlier, in the entry &amp;quot;&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f03%2f22%2fInlineFunctionsInXslt21.aspx"&gt;Inline
functions in xslt 2.1&lt;/a&gt;&amp;quot; we've described an implementation of xml tree model
that may share subtrees among different trees.
&lt;/p&gt;
&lt;p&gt;
This way, in a code:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;&amp;lt;xsl:variable name=&amp;quot;elements&amp;quot; as=&amp;quot;element()*&amp;quot; select=&amp;quot;...&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:variable name=&amp;quot;result&amp;quot; as=&amp;quot;element()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;result&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;$elements&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/result&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:variable&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
the implementation shares internal representation among &lt;code&gt;$elements&lt;/code&gt; and
subtree of &lt;code&gt;$result&lt;/code&gt;. From the perspective of xslt it looks as completely
different subtrees with different node identities, which is in the accordance with
its view of the world.
&lt;/p&gt;
&lt;p&gt;
After a short study we've decided to create a research implementation of this tree
model in saxon. It's took only a couple of days to introduce a minimal changes to
engine, to refactor linked tree into a new composable tree, and to perform some tests.
&lt;/p&gt;
&lt;p&gt;
In many cases saxon has benefited immediately from this new tree model, in some other
cases more tunings are required.
&lt;/p&gt;
&lt;p&gt;
Our tests've showed that this new tree performed better than linked tree, but a little
bit worser than tiny tree. On the other hand, it&amp;#39;s obvious that conventional code
patterns avoid subtree copying, assuming it&amp;#39;s expensive operation, thus one should
rethink some code practices to benefit from composable tree.
&lt;/p&gt;
&lt;p&gt;
Implementation can be downloaded at: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.composabletree.zip"&gt; saxon.composabletree.zip&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,2a70d16f-cdd5-41c1-8fe3-ce5b58362d2a.aspx</comments>
      <category>Announce</category>
      <category>Thinking aloud</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=dd5835dd-7622-44ff-9059-b44dcf3e414c</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,dd5835dd-7622-44ff-9059-b44dcf3e414c.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,dd5835dd-7622-44ff-9059-b44dcf3e414c.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=dd5835dd-7622-44ff-9059-b44dcf3e414c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We've added a new language to the set of Xml Object Model schemas and stylesheets. 
</p>
        <p>
The newcomer is COBOL! No jokes. It's not a whim, really. Believe it or not but COBOL
is still alive and we need to generate it (mainly different sorts of proxies).
</p>
        <p>
We've used <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=dd5835dd-7622-44ff-9059-b44dcf3e414c&amp;url=http%3a%2f%2fwww.few.vu.nl%2f%7ex%2fgrammars%2fvs-cobol-ii%2findex.html" name="Top">VS
COBOL II grammar Version 1.0.3</a> as a reference. Implemented grammar is complete
but without preprocessor statements. On the other hand it defines COPY and EXEC SQL
constructs. 
</p>
        <p>
Definitely, it'll take a time for the xml schema and xslt implementation to become
mature.
</p>
        <p>
Now language XOM is:
</p>
        <ul>
          <li>
jxom - for java;</li>
          <li>
csharpxom - for C#;</li>
          <li>
cobolxom - for COBOL.</li>
        </ul>
        <p>
Sources can be found at <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=dd5835dd-7622-44ff-9059-b44dcf3e414c&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"> languages-xom</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=dd5835dd-7622-44ff-9059-b44dcf3e414c" />
      </body>
      <title>Addition to XOM Family</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,dd5835dd-7622-44ff-9059-b44dcf3e414c.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2009/12/27/AdditionToXOMFamily.aspx</link>
      <pubDate>Sun, 27 Dec 2009 17:00:07 GMT</pubDate>
      <description>&lt;p&gt;
We've added a new language to the set of Xml Object Model schemas and stylesheets. 
&lt;/p&gt;
&lt;p&gt;
The newcomer is COBOL! No jokes. It's not a whim, really. Believe it or not but COBOL
is still alive and we need to generate it (mainly different sorts of proxies).
&lt;/p&gt;
&lt;p&gt;
We've used &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=dd5835dd-7622-44ff-9059-b44dcf3e414c&amp;amp;url=http%3a%2f%2fwww.few.vu.nl%2f%7ex%2fgrammars%2fvs-cobol-ii%2findex.html" name="Top"&gt;VS
COBOL II grammar Version 1.0.3&lt;/a&gt; as a reference. Implemented grammar is complete
but without preprocessor statements. On the other hand it defines COPY and EXEC SQL
constructs. 
&lt;/p&gt;
&lt;p&gt;
Definitely, it'll take a time for the xml schema and xslt implementation to become
mature.
&lt;/p&gt;
&lt;p&gt;
Now language XOM is:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
jxom - for java;&lt;/li&gt;
&lt;li&gt;
csharpxom - for C#;&lt;/li&gt;
&lt;li&gt;
cobolxom - for COBOL.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Sources can be found at &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=dd5835dd-7622-44ff-9059-b44dcf3e414c&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt; languages-xom&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=dd5835dd-7622-44ff-9059-b44dcf3e414c" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,dd5835dd-7622-44ff-9059-b44dcf3e414c.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=9f16f2c9-f7b2-4894-8ae9-b2b630b2d819</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,9f16f2c9-f7b2-4894-8ae9-b2b630b2d819.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,9f16f2c9-f7b2-4894-8ae9-b2b630b2d819.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=9f16f2c9-f7b2-4894-8ae9-b2b630b2d819</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At present C# serializer knows how to print comments and do some formatting (we had
to create micro xml serializer within xslt to serialize xml comments). C#'s formatting
is not as advanced as java's one, but it should not be such in the first place, as
C# text tends to be more neat due to properties and events. Compare: 
</p>
        <p style="padding-left: 1em">
          <b>Java:</b>
          <code>instance.getItems().get(10).setValue(value);</code>
        </p>
        <p>
vs
</p>
        <p style="padding-left: 1em">
          <b>C#:</b>
          <code>instance.Items[10].Value = value;</code>
        </p>
        <p>
TODO: implement API existing in jxom and missing in C# xom. This includes:
</p>
        <ul>
          <li>
name normalization - rewriting tree to make names unique (duplicate names are often
appear during generation from code templates);</li>
          <li>
namespaces normalization - rewriting tree to elevate type namespaces (during generation,
types are usually fully qualified);</li>
          <li>
unreachable code detection - optional feature (in java it's required, as unreachable
code is an error, while in C# it's only a warning);</li>
          <li>
compile time expression evaluation - optional feature used in code optimization and
in reachability checks;</li>
          <li>
state machine refactoring - not sure, as C# has <code>yield</code> statement that
does the similar thing.</li>
        </ul>
        <p>
Update can be found at: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=9f16f2c9-f7b2-4894-8ae9-b2b630b2d819&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">jxom/C#
xom</a>.
</p>
        <p>
          <b>June, 24 update:</b> name and namespace normalizations are implemented. 
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=9f16f2c9-f7b2-4894-8ae9-b2b630b2d819" />
      </body>
      <title>jxom/C# xom update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,9f16f2c9-f7b2-4894-8ae9-b2b630b2d819.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2009/06/18/jxomCXomUpdate.aspx</link>
      <pubDate>Thu, 18 Jun 2009 15:11:53 GMT</pubDate>
      <description>&lt;p&gt;
At present C# serializer knows how to print comments and do some formatting (we had
to create micro xml serializer within xslt to serialize xml comments). C#'s formatting
is not as advanced as java's one, but it should not be such in the first place, as
C# text tends to be more neat due to properties and events. Compare: 
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;b&gt;Java:&lt;/b&gt; &lt;code&gt;instance.getItems().get(10).setValue(value);&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
vs
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;b&gt;C#:&lt;/b&gt; &lt;code&gt;instance.Items[10].Value = value;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
TODO: implement API existing in jxom and missing in C# xom. This includes:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
name normalization - rewriting tree to make names unique (duplicate names are often
appear during generation from code templates);&lt;/li&gt;
&lt;li&gt;
namespaces normalization - rewriting tree to elevate type namespaces (during generation,
types are usually fully qualified);&lt;/li&gt;
&lt;li&gt;
unreachable code detection - optional feature (in java it's required, as unreachable
code is an error, while in C# it's only a warning);&lt;/li&gt;
&lt;li&gt;
compile time expression evaluation - optional feature used in code optimization and
in reachability checks;&lt;/li&gt;
&lt;li&gt;
state machine refactoring - not sure, as C# has &lt;code&gt;yield&lt;/code&gt; statement that
does the similar thing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Update can be found at: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=9f16f2c9-f7b2-4894-8ae9-b2b630b2d819&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt;jxom/C#
xom&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;June, 24 update:&lt;/b&gt; name and namespace normalizations are implemented. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=9f16f2c9-f7b2-4894-8ae9-b2b630b2d819" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,9f16f2c9-f7b2-4894-8ae9-b2b630b2d819.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=24bb2297-32bc-488d-9bc4-5549f99f6f49</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,24bb2297-32bc-488d-9bc4-5549f99f6f49.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,24bb2297-32bc-488d-9bc4-5549f99f6f49.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=24bb2297-32bc-488d-9bc4-5549f99f6f49</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Writing a language serializer is an as easy task, as riding a bicycle. Once you learned
it, you won't apply a mental force anymore to create a new one.
</p>
        <p>
This still requires essential mechanical efforts to write and test things.
</p>
        <p>
Well, this is the first draft of the <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=24bb2297-32bc-488d-9bc4-5549f99f6f49&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">C#
xslt serializer</a>. Archive contains both <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=24bb2297-32bc-488d-9bc4-5549f99f6f49&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">C#
xom and jxom</a>.
</p>
        <p>
Note: no comments are still supported; nothing is done to format code except line
wrapping.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=24bb2297-32bc-488d-9bc4-5549f99f6f49" />
      </body>
      <title>jxom/C# xom update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,24bb2297-32bc-488d-9bc4-5549f99f6f49.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2009/06/15/jxomCXomUpdate.aspx</link>
      <pubDate>Mon, 15 Jun 2009 14:51:11 GMT</pubDate>
      <description>&lt;p&gt;
Writing a language serializer is an as easy task, as riding a bicycle. Once you learned
it, you won't apply a mental force anymore to create a new one.
&lt;/p&gt;
&lt;p&gt;
This still requires essential mechanical efforts to write and test things.
&lt;/p&gt;
&lt;p&gt;
Well, this is the first draft of the &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=24bb2297-32bc-488d-9bc4-5549f99f6f49&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt;C#
xslt serializer&lt;/a&gt;. Archive contains both &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=24bb2297-32bc-488d-9bc4-5549f99f6f49&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"&gt;C#
xom and jxom&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Note: no comments are still supported; nothing is done to format code except line
wrapping.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=24bb2297-32bc-488d-9bc4-5549f99f6f49" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,24bb2297-32bc-488d-9bc4-5549f99f6f49.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <georss:point>0 0</georss:point>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Well, it's jxom no more but also csharpxom!
</p>
        <p>
A project concerns demanded us to create a <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fcsharp.xsd">C#
3.0 xml schema</a>.
</p>
        <p>
Shortly we expect to create an xslt serializing an xml document in this schema into
a text. Thankfully to the original design we can reuse java streamer almost without
changes.
</p>
        <p>
A fact: C# schema more than twice bigger than the java's.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c" />
      </body>
      <title>jxom Update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2009/05/28/jxomUpdate.aspx</link>
      <pubDate>Thu, 28 May 2009 09:57:02 GMT</pubDate>
      <description>&lt;p&gt;
Well, it's jxom no more but also csharpxom!
&lt;/p&gt;
&lt;p&gt;
A project concerns demanded us to create a &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fcsharp.xsd"&gt;C#
3.0 xml schema&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Shortly we expect to create an xslt serializing an xml document in this schema into
a text. Thankfully to the original design we can reuse java streamer almost without
changes.
&lt;/p&gt;
&lt;p&gt;
A fact: C# schema more than twice bigger than the java's.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=0d6b5b3d-db62-4694-81bc-7632fec2306a</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0d6b5b3d-db62-4694-81bc-7632fec2306a.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0d6b5b3d-db62-4694-81bc-7632fec2306a.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=0d6b5b3d-db62-4694-81bc-7632fec2306a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently, we have started looking into a task of creating an interactive parser. A
generic one.
</p>
        <p>
Yes, we know there are plenty of them all around, however the goals we have defined
made us to construct the new implementation.
</p>
        <p>
The goals:
</p>
        <ul>
          <li>
Parser must be incremental.<br />
You should direct what to parse, and when to stop.<br />
This virtually demands rather "pull" than conventional "push"
implementation.</li>
          <li>
Parser must be able to synchronize a tree with text.<br />
Whenever the underlying text is changed, a limited part of a tree should to be updated.</li>
          <li>
Parser should be able to recover from errors, and continue parsing.</li>
          <li>
Parser should be manageable.<br />
This is a goal of every program, really.</li>
          <li>
Parser must be fast.</li>
          <li>
A low memory footprint is desired.</li>
        </ul>
        <p>
What's implemented (VS2008, C#) and put at SourceForge, is called an <a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a&amp;url=http%3a%2f%2fsourceforge.net%2fprojects%2fincr-parser%2f">Incremental
Parser</a>.
</p>
        <p>
These are parser's insights:
</p>
        <ul>
          <li>
Bookmarks are objects to track text points. We use a binary tree (see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2009%2f02%2f12%2fBareBinaryTreeAlgorithms.aspx">Bare
binary tree algorithms</a>) to adjust positions of bookmarks when text is changed.</li>
          <li>
Ranges define parsed tree elements. Each range is defined by two bookmarks, and a
grammar annotation.</li>
          <li>
There are grammar primitives, which can be composed into a grammar graph.</li>
          <li>
A grammar graph along with ranges form a state machine.</li>
          <li>
Grammar chains are cached, turning parsing into a series of probes of literal tokens
and transitions between grammar chains. This caching is done on demand, which results
in warming-up effect.</li>
          <li>
Parser itself includes a random access tokenizer, and a queue of ranges pending to
be parsed.</li>
          <li>
Parsing is conducted as a cycle of pulling and parsing of pending ranges.</li>
          <li>
Whenever text is changed a closest range is queued for the reparsing.</li>
          <li>
A balance between amount of parsing and memory consumption can be achieved through
a detalization of grammar annotation for a range. An active text fragment can be fully
annotated, while for other text parts a coarse range can be stored.</li>
        </ul>
        <p>
We have defined <a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a&amp;url=http%3a%2f%2fincr-parser.svn.sourceforge.net%2fviewvc%2fincr-parser%2fParser%2ftrunk%2fTest%2fXPathLikeGrammar.cs%3frevision%3d27%26view%3dmarkup"> xpath
like grammar</a> to test our ideas. See printed <a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a&amp;url=http%3a%2f%2fincr-parser.svn.sourceforge.net%2fviewvc%2fincr-parser%2fParser%2ftrunk%2fTest%2fMaterials%2fTrees.txt%3frevision%3d28%26view%3dmarkup"> parsed
trees</a> to get understanding of what information can be seen from ranges.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a" />
      </body>
      <title>Incremental Parser</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0d6b5b3d-db62-4694-81bc-7632fec2306a.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2009/03/08/IncrementalParser.aspx</link>
      <pubDate>Sun, 08 Mar 2009 21:00:38 GMT</pubDate>
      <description>  &lt;p&gt;
Recently, we have started looking into a task of creating an interactive parser. A
generic one.
&lt;/p&gt;
&lt;p&gt;
Yes, we know there are plenty of them all around, however the goals we have defined
made us to construct the new implementation.
&lt;/p&gt;
&lt;p&gt;
The goals:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Parser must be incremental.&lt;br /&gt;
You should direct what to parse, and when to stop.&lt;br /&gt;
This virtually demands rather &amp;quot;pull&amp;quot; than conventional &amp;quot;push&amp;quot;
implementation.&lt;/li&gt;
&lt;li&gt;
Parser must be able to synchronize a tree with text.&lt;br /&gt;
Whenever the underlying text is changed, a limited part of a tree should to be updated.&lt;/li&gt;
&lt;li&gt;
Parser should be able to recover from errors, and continue parsing.&lt;/li&gt;
&lt;li&gt;
Parser should be manageable.&lt;br /&gt;
This is a goal of every program, really.&lt;/li&gt;
&lt;li&gt;
Parser must be fast.&lt;/li&gt;
&lt;li&gt;
A low memory footprint is desired.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
What&amp;#39;s implemented (VS2008, C#) and put at SourceForge, is called an &lt;a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a&amp;amp;url=http%3a%2f%2fsourceforge.net%2fprojects%2fincr-parser%2f"&gt;Incremental
Parser&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
These are parser's insights:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Bookmarks are objects to track text points. We use a binary tree (see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2009%2f02%2f12%2fBareBinaryTreeAlgorithms.aspx"&gt;Bare
binary tree algorithms&lt;/a&gt;) to adjust positions of bookmarks when text is changed.&lt;/li&gt;
&lt;li&gt;
Ranges define parsed tree elements. Each range is defined by two bookmarks, and a
grammar annotation.&lt;/li&gt;
&lt;li&gt;
There are grammar primitives, which can be composed into a grammar graph.&lt;/li&gt;
&lt;li&gt;
A grammar graph along with ranges form a state machine.&lt;/li&gt;
&lt;li&gt;
Grammar chains are cached, turning parsing into a series of probes of literal tokens
and transitions between grammar chains. This caching is done on demand, which results
in warming-up effect.&lt;/li&gt;
&lt;li&gt;
Parser itself includes a random access tokenizer, and a queue of ranges pending to
be parsed.&lt;/li&gt;
&lt;li&gt;
Parsing is conducted as a cycle of pulling and parsing of pending ranges.&lt;/li&gt;
&lt;li&gt;
Whenever text is changed a closest range is queued for the reparsing.&lt;/li&gt;
&lt;li&gt;
A balance between amount of parsing and memory consumption can be achieved through
a detalization of grammar annotation for a range. An active text fragment can be fully
annotated, while for other text parts a coarse range can be stored.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
We have defined &lt;a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a&amp;amp;url=http%3a%2f%2fincr-parser.svn.sourceforge.net%2fviewvc%2fincr-parser%2fParser%2ftrunk%2fTest%2fXPathLikeGrammar.cs%3frevision%3d27%26view%3dmarkup"&gt; xpath
like grammar&lt;/a&gt; to test our ideas. See printed &lt;a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a&amp;amp;url=http%3a%2f%2fincr-parser.svn.sourceforge.net%2fviewvc%2fincr-parser%2fParser%2ftrunk%2fTest%2fMaterials%2fTrees.txt%3frevision%3d28%26view%3dmarkup"&gt; parsed
trees&lt;/a&gt; to get understanding of what information can be seen from ranges.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0d6b5b3d-db62-4694-81bc-7632fec2306a" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0d6b5b3d-db62-4694-81bc-7632fec2306a.aspx</comments>
      <category>Announce</category>
      <category>Incremental Parser</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=833e9471-b5b8-4940-813e-604d2333c661</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,833e9471-b5b8-4940-813e-604d2333c661.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,833e9471-b5b8-4940-813e-604d2333c661.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=833e9471-b5b8-4940-813e-604d2333c661</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We have created <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=833e9471-b5b8-4940-813e-604d2333c661&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx"> Java
Xml Object Model</a> purely for purposes of our project. In fact jxom at present has
siblings: xml models for sql dialects. There are also different APIs like name normalizations,
refactorings, compile time evaluation.
</p>
        <p>
It turns out that jxom is also good enough for other developers. 
</p>
        <p>
The drawback of jxom, however, is rather complex xml schema. It takes time to understand
it. To simplify things we have created (and planning to create more) a couple of examples
allowing to feel how jxom xml looks like.
</p>
        <p>
The latest version can be loaded from <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=833e9471-b5b8-4940-813e-604d2333c661&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip"> jxom.zip</a></p>
        <p>
We would be pleased to see more comments on the subject.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=833e9471-b5b8-4940-813e-604d2333c661" />
      </body>
      <title>People start looking into jxom</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,833e9471-b5b8-4940-813e-604d2333c661.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/12/10/PeopleStartLookingIntoJxom.aspx</link>
      <pubDate>Wed, 10 Dec 2008 09:35:26 GMT</pubDate>
      <description>  &lt;p&gt;
We have created &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=833e9471-b5b8-4940-813e-604d2333c661&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx"&gt; Java
Xml Object Model&lt;/a&gt; purely for purposes of our project. In fact jxom at present has
siblings: xml models for sql dialects. There are also different APIs like name normalizations,
refactorings, compile time evaluation.
&lt;/p&gt;
&lt;p&gt;
It turns out that jxom is also good enough for other developers. 
&lt;/p&gt;
&lt;p&gt;
The drawback of jxom, however, is rather complex xml schema. It takes time to understand
it. To simplify things we have created (and planning to create more) a couple of examples
allowing to feel how jxom xml looks like.
&lt;/p&gt;
&lt;p&gt;
The latest version can be loaded from &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=833e9471-b5b8-4940-813e-604d2333c661&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip"&gt; jxom.zip&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We would be pleased to see more comments on the subject.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=833e9471-b5b8-4940-813e-604d2333c661" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,833e9471-b5b8-4940-813e-604d2333c661.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=ca4777e3-5ddf-46e4-8a16-4f8d58385e12</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,ca4777e3-5ddf-46e4-8a16-4f8d58385e12.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,ca4777e3-5ddf-46e4-8a16-4f8d58385e12.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=ca4777e3-5ddf-46e4-8a16-4f8d58385e12</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Although in last our projects we're using more Java and XSLT, we always compare Java
and .NET features. It's not a secret that in most applications we may find cache solutions
used to improve performance. Unlike .NET providing a robust cache solution Java doesn't
provide anything standard. Of course Java's adept may find a lot of caching frameworks
or just to say: "use HashMap (ArrayList etc.) instead", but this is not the same.
</p>
        <p>
Think about options for Java:<br />
1. Caching frameworks (caching systems). Yes, they do their work. Do it perfectly.
Some of them are brought to the state of the art, but there are drawbacks. The crucial
one is that for simple data caching one should use a whole framework. This option
requires too many efforts to solve a simple problem.
</p>
        <p>
2. Collection classes (<code>HashMap</code>, <code>ArrayList</code> etc.) for caching
data. This is very straightforward solution, and very productive. Everyone knows these
classes, nothing to configure. One should declare an instance of such class, take
care of data access synchronization and everything starts working immediately. An
admirable caching solution but for "toy applications", since it solves one problem
and introduces another one. If an application works for hours and there are a lot
of data to cache, the amount of data grows only and never reduces, so this is the
reason why such caching is very quickly surrounded with all sort of rules that somehow
reduce its size at run-time. The solution very quickly lost its shine and become not
portable, but it's still applicable for some applications.
</p>
        <p>
3. Using Java reference objects for caching data. The most appropriate for cache solution
is a <code>java.util.WeekHashMap</code> class. <code>WeakHashMap</code> works exactly
like a hash table but uses weak references internally. In practice, entries in the <code>WeakHashMap</code> are
reclaimed at any time if they are not refered outside of map. This caching strategy
depends on GC's whims and is not entirely reliable, may increase a number of cache
misses.
</p>
        <p>
We've decided to create our simple cache with sliding expiration of data.
</p>
        <p>
One may create many cache instances but there is only one global service that tracks
expired objects among these instances:
</p>
        <p style="padding-left: 1em;">
          <code>private Cache&lt;String, Object&gt; cache = new Cache&lt;String, Object&gt;();</code>
        </p>
        <p>
There is a constructor that specifies an expiration interval in milliseconds for all
cached objects:
</p>
        <p style="padding-left: 1em;">
          <code>private Cache&lt;String, Object&gt; cache = new Cache&lt;String, Object&gt;(15 * 60
* 1000)</code>
        </p>
        <p>
Access is similar to <code>HashMap</code>:
</p>
        <p style="padding-left: 1em;">
          <code>instance = cache.get("key");</code> and <code>cache.put("key", instance);</code></p>
        <p>
That's all one should know to start use it. <a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ca4777e3-5ddf-46e4-8a16-4f8d58385e12&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fCache.java.txt">Click
here to download</a> the Java source of this class. Feel free to use it in your applications.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=ca4777e3-5ddf-46e4-8a16-4f8d58385e12" />
      </body>
      <title>A simple cache for Java application.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,ca4777e3-5ddf-46e4-8a16-4f8d58385e12.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/12/04/ASimpleCacheForJavaApplication.aspx</link>
      <pubDate>Thu, 04 Dec 2008 12:12:38 GMT</pubDate>
      <description>&lt;p&gt;
Although in last our projects we're using more Java and XSLT, we always compare Java
and .NET features. It's not a secret that in most applications we may find cache solutions
used to improve performance. Unlike .NET providing a robust cache solution Java doesn't
provide anything standard. Of course Java's adept may find a lot of caching frameworks
or just to say: "use HashMap (ArrayList etc.) instead", but this is not the same.
&lt;/p&gt;
&lt;p&gt;
Think about options for Java:&lt;br /&gt;
1. Caching frameworks (caching systems). Yes, they do their work. Do it perfectly.
Some of them are brought to the state of the art, but there are drawbacks. The crucial
one is that for simple data caching one should use a whole framework. This option
requires too many efforts to solve a simple problem.
&lt;/p&gt;
&lt;p&gt;
2. Collection classes (&lt;code&gt;HashMap&lt;/code&gt;, &lt;code&gt;ArrayList&lt;/code&gt; etc.) for caching
data. This is very straightforward solution, and very productive. Everyone knows these
classes, nothing to configure. One should declare an instance of such class, take
care of data access synchronization and everything starts working immediately. An
admirable caching solution but for "toy applications", since it solves one problem
and introduces another one. If an application works for hours and there are a lot
of data to cache, the amount of data grows only and never reduces, so this is the
reason why such caching is very quickly surrounded with all sort of rules that somehow
reduce its size at run-time. The solution very quickly lost its shine and become not
portable, but it's still applicable for some applications.
&lt;/p&gt;
&lt;p&gt;
3. Using Java reference objects for caching data. The most appropriate for cache solution
is a &lt;code&gt;java.util.WeekHashMap&lt;/code&gt; class. &lt;code&gt;WeakHashMap&lt;/code&gt; works exactly
like a hash table but uses weak references internally. In practice, entries in the &lt;code&gt;WeakHashMap&lt;/code&gt; are
reclaimed at any time if they are not refered outside of map. This caching strategy
depends on GC's whims and is not entirely reliable, may increase a number of cache
misses.
&lt;/p&gt;
&lt;p&gt;
We've decided to create our simple cache with sliding expiration of data.
&lt;/p&gt;
&lt;p&gt;
One may create many cache instances but there is only one global service that tracks
expired objects among these instances:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;private Cache&amp;lt;String, Object&gt; cache = new Cache&amp;lt;String, Object&gt;();&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
There is a constructor that specifies an expiration interval in milliseconds for all
cached objects:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;private Cache&amp;lt;String, Object&gt; cache = new Cache&amp;lt;String, Object&gt;(15 * 60
* 1000)&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Access is similar to &lt;code&gt;HashMap&lt;/code&gt;:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;instance = cache.get("key");&lt;/code&gt; and &lt;code&gt;cache.put("key", instance);&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
That's all one should know to start use it. &lt;a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ca4777e3-5ddf-46e4-8a16-4f8d58385e12&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fCache.java.txt"&gt;Click
here to download&lt;/a&gt; the Java source of this class. Feel free to use it in your applications.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=ca4777e3-5ddf-46e4-8a16-4f8d58385e12" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,ca4777e3-5ddf-46e4-8a16-4f8d58385e12.aspx</comments>
      <category>Announce</category>
      <category>Tips and tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=e394e0b8-d3c2-4261-aba9-c70ed03dea1d</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,e394e0b8-d3c2-4261-aba9-c70ed03dea1d.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,e394e0b8-d3c2-4261-aba9-c70ed03dea1d.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=e394e0b8-d3c2-4261-aba9-c70ed03dea1d</wfw:commentRss>
      <title>Try/catch block in xslt 2.0 for Saxon 9.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,e394e0b8-d3c2-4261-aba9-c70ed03dea1d.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/06/26/TrycatchBlockInXslt20ForSaxon9.aspx</link>
      <pubDate>Thu, 26 Jun 2008 09:18:50 GMT</pubDate>
      <description>  &lt;p&gt;
We are designing a rather complex xslt 2.0 application, dealing with semistructured
data. We must tolerate with errors during processing, as there are cases where an
input is not perfectly valid (or the program is not designed or ready to get such
an input).
&lt;/p&gt;
&lt;p&gt;
The most typical error is unsatisfied expectation of tree structure like:&lt;br /&gt;
&amp;nbsp; &lt;code&gt;&amp;lt;xsl:variable name=&amp;quot;element&amp;quot; as=&amp;quot;element()&amp;quot; select=&amp;quot;some-element&amp;quot;/&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Obviously, dynamic error occurs if a specified element is not present. To concentrate
on primary logic, and to avoid a burden of illegal (unexpected) case recovery we have
created a try/catch API. The goal of such API is:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
to be able to continue processing in case of error;&lt;/li&gt;
&lt;li&gt;
report as much as possible useful information related to an error.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Alternatives:
&lt;/p&gt;
&lt;p&gt;
Do not think this is our arrogance, which has turned us to create a custom API. No,
we were looking for alternatives! Please see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fbiglist.com%2flists%2fxsl-list%2farchives%2f200801%2fthreads.html%2300055"&gt;[xsl]
saxon:try()&lt;/a&gt; discussion:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fwww.saxonica.com%2fdocumentation%2fextensions%2ffunctions%2ftry.html"&gt;saxon:try()&lt;/a&gt; function
- is a kind of pseudo function, which explicitly relies on lazy evaluation of its
arguments, and ... it&amp;#39;s not available in SaxonB;&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fwww.fgeorges.org%2fxslt%2ferror-safe%2f"&gt;ex:error-safe&lt;/a&gt;&amp;nbsp;
extension instruction - is far from perfect in its implementation quality, and provides
no error location.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
We have no other way except to design this feature by ourselves. In our defence one
can say that we are using innovatory approach that encapsulates details of the implementation
behind template and calls handlers indirectly.
&lt;/p&gt;
&lt;p&gt;
Use:
&lt;/p&gt;
&lt;p&gt;
Try/catch API is designed as a template &lt;code&gt; &amp;lt;xsl:template name=&amp;quot;t:try-block&amp;quot;/&amp;gt&lt;/code&gt; calling
a &amp;quot;try&amp;quot; handler, and, if required, a &amp;quot;catch&amp;quot; hanler using &lt;code&gt; &amp;lt;xsl:apply-templates
mode=&amp;quot;t:call&amp;quot;/&amp;gt;&lt;/code&gt; instruction. Caller passes any information to
these handlers by the means of tunnel parameters.
&lt;/p&gt;
&lt;p&gt;
Handlers must be in a &amp;quot;&lt;code&gt;t:call&lt;/code&gt;&amp;quot; mode. The &amp;quot;catch&amp;quot;
handler may recieve following error info parameters:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;&amp;lt;xsl:param name=&amp;quot;error&amp;quot; as=&amp;quot;xs:QName&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;xsl:param name=&amp;quot;error-description&amp;quot; as=&amp;quot;xs:string&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;xsl:param name=&amp;quot;error-location&amp;quot; as=&amp;quot;item()*&amp;quot;/&amp;gt; &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
where &lt;code&gt;$error-location&lt;/code&gt; is a sequence of pairs &lt;code&gt;(location as xs:string,
context as item())*&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
A sample:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt; &amp;lt;xsl:stylesheet version=&amp;quot;2.0&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:t=&amp;quot;http://www.nesterovsky-bros.com/xslt/public/&amp;quot;&lt;br /&gt;
&amp;nbsp; exclude-result-prefixes=&amp;quot;xs t&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:include href=&amp;quot;try-block.xslt&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;result&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:for-each select=&amp;quot;1 to 10&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:call-template name=&amp;quot;t:try-block&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:with-param name=&amp;quot;value&amp;quot;
tunnel=&amp;quot;yes&amp;quot; select=&amp;quot;. - 5&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:with-param name=&amp;quot;try&amp;quot;
as=&amp;quot;element()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;try/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:with-param&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:with-param name=&amp;quot;catch&amp;quot;
as=&amp;quot;element()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:error-handler/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:with-param&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:call-template&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/result&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template mode=&amp;quot;t:call&amp;quot; match=&amp;quot;try&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:param name=&amp;quot;value&amp;quot; tunnel=&amp;quot;yes&amp;quot; as=&amp;quot;xs:decimal&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;value&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;1 div $value&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/value&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
The sample prints values according to the formula &amp;quot;1/(i - 5)&amp;quot;, where &amp;quot;i&amp;quot;
is a variable varying from 1 to 10. Clearly, division by zero occurs when &amp;quot;i&amp;quot;
is equal to 5.
&lt;/p&gt;
&lt;p&gt;
Please notice how to access try/catch API through &lt;code&gt; &amp;lt;xsl:include href=&amp;quot;try-block.xslt&amp;quot;/&amp;gt;&lt;/code&gt;.
The main logic is executed in &lt;code&gt; &amp;lt;xsl:template mode=&amp;quot;t:call&amp;quot; match=&amp;quot;try&amp;quot;/&amp;gt;&lt;/code&gt;,
which recieves parameters using tunneling. A default error handler &lt;code&gt; &amp;lt;t:error-handler/&amp;gt;&lt;/code&gt; is
used to report errors.
&lt;/p&gt;
&lt;p&gt;
Error report:
&lt;/p&gt;
&lt;p style="color: red; padding-left: 1em;"&gt;
&lt;code&gt; Error: FOAR0001&lt;br /&gt;
Description:&lt;br /&gt;
Decimal divide by zero&lt;br /&gt;
&lt;br /&gt;
Location:&lt;br /&gt;
1. systemID: "file:///D:/style/try-block-test.xslt", line: 34&lt;br /&gt;
2. template mode="t:call" match="element(try, xs:anyType)"&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block-test.xslt", line: 30&lt;br /&gt;
&amp;nbsp; context node:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /*[1][local-name() = 'try']&lt;br /&gt;
3. template mode="t:call"&lt;br /&gt;
&amp;nbsp; match="element({http://www.nesterovsky-bros.com/xslt/private/try-block}try,
xs:anyType)"&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block.xslt", line: 53&lt;br /&gt;
&amp;nbsp; context node:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /*[1][local-name() = 'try']&lt;br /&gt;
4. systemID: "file:///D:/style/try-block.xslt", line: 40&lt;br /&gt;
5. call-template name="t:try-block"&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block-test.xslt", line: 17&lt;br /&gt;
6. for-each&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block-test.xslt", line: 16&lt;br /&gt;
&amp;nbsp; context item: 5 
&lt;br /&gt;
7. template mode="saxon:_defaultMode" match="document-node()"&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block-test.xslt", line: 14&lt;br /&gt;
&amp;nbsp; context node:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; / &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Implementation details:
&lt;/p&gt;
&lt;p&gt;
You were not expecting this API to be pure xslt, weren&amp;#39;t you? :-)
&lt;/p&gt;
&lt;p&gt;
Well, you&amp;#39;re right, there is an extension function. Its pseudo code is like this:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;function tryBlock(tryItems, catchItems) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;nbsp; try&lt;br /&gt;
&amp;nbsp; { 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; execute xsl:apply-templates for tryItems. 
&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; catch&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; execute xsl:apply-templates for catchItems. 
&lt;br /&gt;
&amp;nbsp; } 
&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The last thing. Please get the implementation &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.zip"&gt; saxon.extensions.zip&lt;/a&gt;.
There you will find sources of the try/catch, and &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f05%2f18%2fTuplesAndMapsInSaxon.aspx"&gt;tuples/maps&lt;/a&gt; API.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,e394e0b8-d3c2-4261-aba9-c70ed03dea1d.aspx</comments>
      <category>Announce</category>
      <category>Tips and tricks</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=261fb587-c621-41e1-b0ac-3a722f7ab5f6</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,261fb587-c621-41e1-b0ac-3a722f7ab5f6.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,261fb587-c621-41e1-b0ac-3a722f7ab5f6.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=261fb587-c621-41e1-b0ac-3a722f7ab5f6</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently I've proposed to add two new atomic types <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f04%2f04%2fWhatImMissingInXslt20xquery10.aspx"> tuple
and map</a> to the xpath/xslt/xquery type system (see "<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.w3.org%2fBugs%2fPublic%2fshow_bug.cgi%3fid%3d5630">Tuples
an maps</a>"). Later I've implemented <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f04%2f05%2fTupleAndMapInTheXslt20.aspx"> tuple
and map pure xslt approximation</a>. Now I want to present <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip">java
implementation for Saxon</a>.
</p>
        <p>
I've created TupleValue and MapValue atomic types, and Collections class exposing
extension functions api. It's easy to use this api. I'll repeat an example
that I was showing earlier:
</p>
        <p style="padding-left: 1em">
          <code> &lt;xsl:stylesheet version="2.0" 
<br />
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<br />
  xmlns:xs="http://www.w3.org/2001/XMLSchema"<br />
  xmlns:f="http://www.nesterovsky-bros.com/xslt/functions/public"<br />
  xmlns:p="http://www.nesterovsky-bros.com/xslt/functions/private" 
<br />
  xmlns:c="java:com.nesterovskyBros.saxon.Functions" 
<br />
  exclude-result-prefixes="xs f p c"&gt;<br /><br />
&lt;xsl:template match="/"&gt; 
<br />
   &lt;root&gt;<br />
     &lt;xsl:variable name="tuples" as="item()*"
select="<br />
       for $i in 1 to 20<br />
         return c:tuple(1 to $i)"/&gt;<br /><br />
    &lt;total-items&gt;<br />
      &lt;xsl:sequence select="<br />
        sum<br />
        (<br />
          for $tuple in $tuples return<br />
            count(c:tuple-items($tuple))<br />
        )"/&gt;<br />
    &lt;/total-items&gt;<br />
    &lt;tuples-size&gt;<br />
      &lt;xsl:sequence select="count($tuples)"/&gt;<br />
    &lt;/tuples-size&gt;<br />
    &lt;sums-per-tuples&gt;<br />
      &lt;xsl:for-each select="$tuples"&gt;<br />
        &lt;xsl:variable name="index"
as="xs:integer" select="position()"/&gt;<br /><br />
        &lt;sum index="{$index}" value="{sum(c:tuple-items(.))}"/&gt;<br />
      &lt;/xsl:for-each&gt;<br />
    &lt;/sums-per-tuples&gt;<br /><br />
    &lt;xsl:variable name="cities" as="element()*"&gt;<br />
      &lt;city name="Jerusalem" country="Israel"/&gt;<br />
      &lt;city name="London" country="Great
Britain"/&gt;<br />
      &lt;city name="Paris" country="France"/&gt;<br />
      &lt;city name="New York" country="USA"/&gt;<br />
      &lt;city name="Moscow" country="Russia"/&gt;<br />
      &lt;city name="Tel Aviv" country="Israel"/&gt;<br />
      &lt;city name="St. Petersburg" country="Russia"/&gt;<br />
     &lt;/xsl:variable&gt;<br /><br />
    &lt;xsl:variable name="map" as="item()" select="<br />
      c:map<br />
      (<br />
        for $city in $cities return<br />
        (<br />
          $city/string(@country),<br />
          $city<br />
        )<br />
      )"/&gt;<br /><br />
    &lt;xsl:for-each select="c:map-keys($map)"&gt;<br />
      &lt;xsl:variable name="key" as="xs:string"
select="."/&gt;<br /><br />
      &lt;country name="{$key}"&gt;<br />
        &lt;xsl:sequence select="c:map-value($map,
$key)"/&gt;<br />
     &lt;/country&gt;<br />
    &lt;/xsl:for-each&gt;<br />
  &lt;/root&gt; 
<br />
&lt;/xsl:template&gt; 
<br /><br />
&lt;/xsl:stylesheet&gt;</code>
        </p>
        <p>
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip">Download
java source</a>.
</p>
        <p>
P.S. I would wish this api be integrated into Saxon, as at present java extension
functions are called through reflection.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6" />
      </body>
      <title>Tuples and maps in Saxon</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,261fb587-c621-41e1-b0ac-3a722f7ab5f6.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/05/18/TuplesAndMapsInSaxon.aspx</link>
      <pubDate>Sun, 18 May 2008 08:44:09 GMT</pubDate>
      <description>&lt;p&gt;
Recently I&amp;#39;ve proposed to add two new atomic types &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f04%2f04%2fWhatImMissingInXslt20xquery10.aspx"&gt; tuple
and map&lt;/a&gt; to the xpath/xslt/xquery type system (see &amp;quot;&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.w3.org%2fBugs%2fPublic%2fshow_bug.cgi%3fid%3d5630"&gt;Tuples
an maps&lt;/a&gt;&amp;quot;). Later I&amp;#39;ve implemented &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f04%2f05%2fTupleAndMapInTheXslt20.aspx"&gt; tuple
and map pure xslt approximation&lt;/a&gt;. Now I want to present &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip"&gt;java
implementation for Saxon&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I&amp;#39;ve created TupleValue and MapValue atomic types, and Collections class exposing
extension functions api. It&amp;#39;s easy to use this api. I&amp;#39;ll repeat an example
that I was showing earlier:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt; &amp;lt;xsl:stylesheet version=&amp;quot;2.0&amp;quot; 
&lt;br /&gt;
&amp;nbsp; xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:f=&amp;quot;http://www.nesterovsky-bros.com/xslt/functions/public&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:p=&amp;quot;http://www.nesterovsky-bros.com/xslt/functions/private&amp;quot; 
&lt;br /&gt;
&amp;nbsp; xmlns:c=&amp;quot;java:com.nesterovskyBros.saxon.Functions&amp;quot; 
&lt;br /&gt;
&amp;nbsp; exclude-result-prefixes=&amp;quot;xs f p c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;root&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;tuples&amp;quot; as=&amp;quot;item()*&amp;quot;
select=&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for $i in 1 to 20&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return c:tuple(1 to $i)&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;total-items&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for $tuple in $tuples return&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(c:tuple-items($tuple))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/total-items&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tuples-size&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;count($tuples)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tuples-size&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sums-per-tuples&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:for-each select=&amp;quot;$tuples&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;index&amp;quot;
as=&amp;quot;xs:integer&amp;quot; select=&amp;quot;position()&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sum index=&amp;quot;{$index}&amp;quot; value=&amp;quot;{sum(c:tuple-items(.))}&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sums-per-tuples&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;cities&amp;quot; as=&amp;quot;element()*&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;Jerusalem&amp;quot; country=&amp;quot;Israel&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;London&amp;quot; country=&amp;quot;Great
Britain&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;Paris&amp;quot; country=&amp;quot;France&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;New York&amp;quot; country=&amp;quot;USA&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;Moscow&amp;quot; country=&amp;quot;Russia&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;Tel Aviv&amp;quot; country=&amp;quot;Israel&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;St. Petersburg&amp;quot; country=&amp;quot;Russia&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;map&amp;quot; as=&amp;quot;item()&amp;quot; select=&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c:map&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for $city in $cities return&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $city/string(@country),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $city&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:for-each select=&amp;quot;c:map-keys($map)&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;key&amp;quot; as=&amp;quot;xs:string&amp;quot;
select=&amp;quot;.&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;country name=&amp;quot;{$key}&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;c:map-value($map,
$key)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/country&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/root&amp;gt; 
&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt; 
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip"&gt;Download
java source&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
P.S. I would wish this api be integrated into Saxon, as at present java extension
functions are called through reflection.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,261fb587-c621-41e1-b0ac-3a722f7ab5f6.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=4ebfe453-e17b-42c1-aa04-4a329de77923</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,4ebfe453-e17b-42c1-aa04-4a329de77923.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,4ebfe453-e17b-42c1-aa04-4a329de77923.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=4ebfe453-e17b-42c1-aa04-4a329de77923</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="/download/undoredo.zip">Download sample code.</a>
        </p>
        <p>
In our recent .NET 2.0 GUI project our client ingenuously asked us to implement undo
and redo facility. Nothing unusual nowadays, however it's still not the easiest thing
in the world to implement.
</p>
        <p>
Naturally you want to have this feature for a free. You do not want to invest too
much time to support it. We had no much time to implement this "sugar" also. I know,
I know, this is important for a user, however when you're facing a big project with
a lot of logic to be implemented in short time you're starting to think it would be
nice to have undo and redo logic that works independently (at least almost independently)
on business logic.
</p>
        <p>
Thus, what's that place where we could plug this service? - Exactly! - It's data binding
layer.
</p>
        <p>
When you're binding your data to controls the "Type Descriptor Architecture" is used
to retrieve and update the data. Fortunately this architecture is allowing us to create
a data wrapper (ICustomTypeDescriptor). Such wrapper should track property modifications
of the data object thus providing undo and redo service. In short that's all, other
are technical details.
</p>
        <p>
Let's look at how undo and redo service goes into the action. Instead of:
</p>
        <code>  bindingSource.DataSource = data;</code>
        <p>
you have to write:
</p>
        <code>  bindingSource.DataSource = Create-UndoRedo-Wrapper(data);</code>
        <p>
There should also be a class to collect and track actions. User should create an instance
of this class to implement the simplest form of code with undo and redo support:
</p>
        <code>  // Create UndoRedoManager.</code>
        <br />
        <code>  undoRedoManager = new UndoRedoManager();</code>
        <br />
        <code>  // Create undo and redo wrapper around the data object.</code>
        <br />
        <code>  // Bind controls.</code>
        <br />
        <code>  dataBindingSource.DataSource =</code>
        <br />
        <code>    new UndoRedoTypeDescriptor(data, undoRedoManager);</code>
        <p>
Now turn our attention to the implementation of the undo and redo mechanism. There
are two types in the core: UndoRedoManager and IAction. The first one is to track
actions, the later one is to define undo and redo actions. UndoRedoManager performs
either "Do/Redo", or "Undo" operations over IAction instances. We have provided two
useful implementations of the IAction interface: UndoRedoTypeDescriptor - wrapper
around an object that tracks property changes, and UndoRedoList<T>
- wrapper around the IList<T><T>
that tracks collection modifications. Users may create their implementations of the
IAction to handle other undo and redo activities.
</T></T></T></p>
        <p>
We have created a sample application to show undo and redo in action. You can download
it from <a href="/download/undoredo.zip">here</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=4ebfe453-e17b-42c1-aa04-4a329de77923" />
      </body>
      <title>Undo and redo? - Easy!</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,4ebfe453-e17b-42c1-aa04-4a329de77923.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2006/06/02/UndoAndRedoEasy.aspx</link>
      <pubDate>Fri, 02 Jun 2006 22:49:40 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="/download/undoredo.zip"&gt;Download sample code.&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
In our recent .NET 2.0 GUI project our client ingenuously asked us to implement undo
and redo facility. Nothing unusual nowadays, however it's still not the easiest thing
in the world to implement.
&lt;/p&gt;
&lt;p&gt;
Naturally you want to have this feature for a free. You do not want to invest too
much time to support it. We had no much time to implement this "sugar" also. I know,
I know, this is important for a user, however when you're facing a big project with
a lot of logic to be implemented in short time you're starting to think it would be
nice to have undo and redo logic that works independently (at least almost independently)
on business logic.
&lt;/p&gt;
&lt;p&gt;
Thus, what's that place where we could plug this service? - Exactly! - It's data binding
layer.
&lt;/p&gt;
&lt;p&gt;
When you're binding your data to controls the "Type Descriptor Architecture" is used
to retrieve and update the data. Fortunately this architecture is allowing us to create
a data wrapper (ICustomTypeDescriptor). Such wrapper should track property modifications
of the data object thus providing undo and redo service. In short that's all, other
are technical details.
&lt;/p&gt;
&lt;p&gt;
Let's look at how undo and redo service goes into the action. Instead of:
&lt;/p&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;bindingSource.DataSource = data;&lt;/code&gt; 
&lt;p&gt;
you have to write:
&lt;/p&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;bindingSource.DataSource = Create-UndoRedo-Wrapper(data);&lt;/code&gt; 
&lt;p&gt;
There should also be a class to collect and track actions. User should create an instance
of this class to implement the simplest form of code with undo and redo support:
&lt;/p&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;// Create UndoRedoManager.&lt;/code&gt;
&lt;br&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;undoRedoManager = new UndoRedoManager();&lt;/code&gt;
&lt;br&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;// Create undo and redo wrapper around the data object.&lt;/code&gt;
&lt;br&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;// Bind controls.&lt;/code&gt;
&lt;br&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;dataBindingSource.DataSource =&lt;/code&gt;
&lt;br&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new UndoRedoTypeDescriptor(data, undoRedoManager);&lt;/code&gt; 
&lt;p&gt;
Now turn our attention to the implementation of the undo and redo mechanism. There
are two types in the core: UndoRedoManager and IAction. The first one is to track
actions, the later one is to define undo and redo actions. UndoRedoManager performs
either "Do/Redo", or "Undo" operations over IAction instances. We have provided two
useful implementations of the IAction interface: UndoRedoTypeDescriptor - wrapper
around an object that tracks property changes, and UndoRedoList&lt;T&gt;
- wrapper around the IList&lt;T&gt;
&lt;T&gt;
that tracks collection modifications. Users may create their implementations of the
IAction to handle other undo and redo activities.
&lt;/p&gt;
&lt;p&gt;
We have created a sample application to show undo and redo in action. You can download
it from &lt;a href="/download/undoredo.zip"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=4ebfe453-e17b-42c1-aa04-4a329de77923" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,4ebfe453-e17b-42c1-aa04-4a329de77923.aspx</comments>
      <category>Announce</category>
    </item>
  </channel>
</rss>