<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Nesterovsky bros</title>
  <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/" />
  <link rel="self" href="http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2010-02-28T11:29:52.4142429-08:00</updated>
  <author>
    <name>Nesterovsky bros</name>
  </author>
  <subtitle />
  <id>http://www.nesterovsky-bros.com/weblog/</id>
  <generator uri="http://dasblog.info/" version="2.3.9074.18820">DasBlog</generator>
  <entry>
    <title>AVL Tree in Xslt</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/28/AVLTreeInXslt.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,1c5bfc72-d817-4916-b85e-e90e6bc498b7.aspx</id>
    <published>2010-02-28T11:28:07.276-08:00</published>
    <updated>2010-02-28T11:29:52.4142429-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
The story about immutable tree would not be complete without xslt implementation.
To make it possible one needs something to approxomate tree nodes. You cannot implement
such consruct efficiently in pure xslt 2.0 (it would be either unefficient or not
pure).
</p>
        <p>
To isolate the problem we have used tuple interface:
</p>
        <ul>
          <li>
            <code>tuple:ref($items as item()*) as item()</code> - to wrap items into a tuple;</li>
          <li>
            <code>tuple:deref($tuple as item()?) as item()*</code> - to unwrap items from a tuple;</li>
          <li>
            <code>tuple:is-same($first as item(), $second as item()) as xs:boolean</code> - to
test whether two tuples are the same.</li>
        </ul>
        <p>
and defined inefficient implementation based on xml elements. Every other part of
code is a regular AVL algorithm implementation.
</p>
        <p>
We want to stress again that even assuming that there is a good tuple implementation
we would prefer built-in associative container implementation. Why the heck you need
to include about 1000 lines of code just to use a map?
</p>
        <p>
Source code is:
</p>
        <ul>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=1c5bfc72-d817-4916-b85e-e90e6bc498b7&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2ftest.xslt">test.xslt</a> -
a little test;</li>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=1c5bfc72-d817-4916-b85e-e90e6bc498b7&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2ftree.xslt">tree.xslt</a> -
an AVL tree implementation;</li>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=1c5bfc72-d817-4916-b85e-e90e6bc498b7&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2ftuple.xslt">tuple.xslt</a> -
a tuple interface and implementation.</li>
        </ul>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=1c5bfc72-d817-4916-b85e-e90e6bc498b7" />
      </div>
    </content>
  </entry>
  <entry>
    <title>VS 2010, Still Beta</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/28/VS2010StillBeta.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,28a0a8a6-ac66-466f-825d-873b62e4feec.aspx</id>
    <published>2010-02-28T10:37:58.807-08:00</published>
    <updated>2010-02-28T10:40:33.6435209-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We like Visual Studio very much, and try to adopt new version earlier.
</p>
        <p>
For the last time our VS's use pattern is centered around xml and xslt. In our opinion
VS 2008 is the best xslt 2 editor we have ever seen even with lack of support of xslt
2.0 debugging.
</p>
        <p>
Unfortunatelly, that is still a true when VS 2010 is almost out. VS 2008 is just 2
- 3 times faster. You can observe this working with xslt files like those in <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=28a0a8a6-ac66-466f-825d-873b62e4feec&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">languages-xom.zip</a> (1000
- 2000 rows). Things just become slow.
</p>
        <p>
We still hope that VS 2010 will make a final effort to outdo what VS 2008 has already
delivered.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=28a0a8a6-ac66-466f-825d-873b62e4feec" />
      </div>
    </content>
  </entry>
  <entry>
    <title>t:allocate-names() implementation</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/25/tallocatenamesImplementation.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0de88938-0a18-45cd-b2ad-5fdf71d0aad8.aspx</id>
    <published>2010-02-24T23:19:06.3719769-08:00</published>
    <updated>2010-02-24T23:19:06.3719769-08:00</updated>
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
While bemoaning about lack of associative containers in xpath type system, we have
came up with a good implementation of t:allocate-names(). Implementation can be seen
at location <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0de88938-0a18-45cd-b2ad-5fdf71d0aad8&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fmisc%2fcobol-names.xslt"> cobol-names.xslt</a>.
</p>
        <p>
It is based on recursion and on the use of xsl:for-each-group. Alogrithmic worst case
complexity is O(N*LogN*LogL), where N is number of names, and L is a length of a longest
name.
</p>
        <p>
This does not invalidate the idea that associative containers are very wishful, as
blessed one who naturally types such implementation. For us, it went the hard way,
and has taken three days to realize that original algorithm is problematic, and to
work out the better one.
</p>
        <p>
In practice this means 2 seconds for the new implementation against 25 minutes for
the old one.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0de88938-0a18-45cd-b2ad-5fdf71d0aad8" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Welcome to VS 2010!</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/24/WelcomeToVS2010.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,81db7ec4-7b65-4f6d-b1a6-1101f6fd4c41.aspx</id>
    <published>2010-02-24T13:00:36.314-08:00</published>
    <updated>2010-02-24T13:03:25.4652814-08:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <i>Ladies and gentlemen of the jury...</i>
        </p>
        <p>
          <img src="/weblog/content/binary/vs2010-xslt.JPG" alt="Xml Editor in VS 2010" />
        </p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=81db7ec4-7b65-4f6d-b1a6-1101f6fd4c41" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Again on immutable binary trees</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/24/AgainOnImmutableBinaryTrees.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,74a4bf7e-caba-4e58-8319-cb43fd5c87e5.aspx</id>
    <published>2010-02-23T23:34:07.265-08:00</published>
    <updated>2010-02-24T02:44:03.3074569-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Why do we return to <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=74a4bf7e-caba-4e58-8319-cb43fd5c87e5&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f01%2f27%2fAssociativeContainersInAFunctionalLanguages.aspx">this
theme</a> again?
</p>
        <p>
Well, it's itching!
</p>
        <p>
In <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=74a4bf7e-caba-4e58-8319-cb43fd5c87e5&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">cobolxom</a> there
is an utility function to allocate names in scope. Its signature looks like this:
</p>
        <p style="PADDING-LEFT: 1em">
          <code>&lt;!--<br />
  Allocates unique names in the form $prefix{number}?.<br />
  Note that prefixes may coincide. 
<br />
    $prefixes - a name prefixes. 
<br />
    $names - allocated names pool. 
<br />
    $name-max-length - a longest allowable name length. 
<br />
    Returns unique names.<br />
--&gt; 
<br />
&lt;xsl:function name="t:allocate-names" as="xs:string*"&gt; 
<br />
  &lt;xsl:param name="prefixes" as="xs:string*"/&gt; 
<br />
  &lt;xsl:param name="names" as="xs:string*"/&gt; 
<br />
  &lt;xsl:param name="name-max-length" as="xs:integer?"/&gt; </code>
        </p>
        <p>
We have created several different implementations (all use recursion). Every implementation
works fair for relatively small input sequences, say N &lt; 100, but we have cases
when there are about 10000 items on input. Algorithm's worst case complexity, in absence
of associative containers, is O(N*N), and be sure it's an O-o-o-oh... due to xslt
engine implementation.
</p>
        <p>
If there were associative containers with efficient access (complexity is O(LogN)),
and construction of updated container (complexity is also O(LogN)) then implementation
would be straightforward and had complexity O(N*LogN).
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=74a4bf7e-caba-4e58-8319-cb43fd5c87e5" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Integer and fraction in xslt</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/17/IntegerAndFractionInXslt.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,ce398a0f-0131-486a-ba0b-2398980c78c0.aspx</id>
    <published>2010-02-16T23:29:55.69-08:00</published>
    <updated>2010-02-16T23:37:55.3312639-08:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
The very same simple tasks tend to appear in different languages (e.g. <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=ce398a0f-0131-486a-ba0b-2398980c78c0&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2009%2f11%2f13%2fCHaiku.aspx">C#
Haiku</a>). Now we have to find:
</p>
        <ul>
          <li>
integer and fractional part of a decimal;</li>
          <li>
length and precision of a decimal.</li>
        </ul>
        <p>
These tasks have no trivial solutions in xslt 2.0.
</p>
        <p>
At present we have came up with the following answers:
</p>
        <p>
Fractional part:
</p>
        <p style="padding-left: 1em">
          <code>&lt;xsl:function name="t:fraction" as="xs:decimal"&gt;<br />
&lt;xsl:param name="value" as="xs:decimal"/&gt;<br /><br />
&lt;xsl:sequence select="$value mod 1"/&gt;<br />
&lt;/xsl:function&gt;</code>
        </p>
        <p>
Integer part v1:
</p>
        <p style="padding-left: 1em">
          <code>&lt;xsl:function name="t:integer" as="xs:decimal"&gt;<br />
&lt;xsl:param name="value" as="xs:decimal"/&gt;<br /><br />
&lt;xsl:sequence select="$value - t:fraction($value)"/&gt;<br />
&lt;/xsl:function&gt;</code>
        </p>
        <p>
Integer part v2:
</p>
        <p style="padding-left: 1em">
          <code>&lt;xsl:function name="t:integer" as="xs:decimal"&gt;<br />
&lt;xsl:param name="value" as="xs:decimal"/&gt;<br /><br />
&lt;xsl:sequence select="<br />
if ($value ge 0) then<br />
floor($value)<br />
else<br />
-floor(-$value)"/&gt;<br />
&lt;/xsl:function&gt;</code>
        </p>
        <p>
Length and precision:
</p>
        <p style="padding-left: 1em">
          <code>&lt;!-- 
<br />
Gets a decimal specification as a closure:<br />
($length as xs:integer, $precision as xs:integer).<br />
--&gt; 
<br />
&lt;xsl:function name="t:decimal-spec" as="xs:integer+"&gt;<br />
&lt;xsl:param name="value" as="xs:decimal"/&gt;<br /><br />
&lt;xsl:variable name="text" as="xs:string" select="<br />
if ($value lt 0) then<br />
xs:string(-$value)<br />
else<br />
xs:string($value)"/&gt;<br /><br />
&lt;xsl:variable name="length" as="xs:integer"<br />
select="string-length($text)"/&gt;<br />
&lt;xsl:variable name="integer-length" as="xs:integer"<br />
select="string-length(substring-before($text, '.'))"/&gt;<br /><br />
&lt;xsl:sequence select="<br />
if ($integer-length) then 
<br />
($length - 1, $length - $integer-length - 1)<br />
else<br />
($length, 0)"/&gt;<br />
&lt;/xsl:function&gt;</code>
        </p>
        <p>
The last function looks odious. In many other languages its implementation would be
considered as embarrassing.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=ce398a0f-0131-486a-ba0b-2398980c78c0" />
      </div>
    </content>
  </entry>
  <entry>
    <title>C# readonly ring</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/07/CReadonlyRing.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,68f64584-9279-4b5d-84a9-d562346c182d.aspx</id>
    <published>2010-02-06T23:57:08.262-08:00</published>
    <updated>2010-02-07T00:02:45.6736129-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Given:
</p>
        <p style="padding-left: 1em">
          <code>public class N<br />
{ 
<br />
public readonly N next; 
<br />
}</code>
        </p>
        <p>
What needs to be done to construct a ring of <code>N</code>: <code>n1</code> refers
to <code>n2</code>, <code>n2</code> to <code>n3</code>, ... <code>nk</code> to <code>n1</code>?
Is it possible?
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=68f64584-9279-4b5d-84a9-d562346c182d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Map, based on immutable trees</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/06/MapBasedOnImmutableTrees.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,5b7bdc23-b158-4169-b374-f55959ea5c75.aspx</id>
    <published>2010-02-06T10:31:13.638-08:00</published>
    <updated>2010-02-11T07:34:51.4426789-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
To end with immutable trees, at least for now, we've implemented <code>IDictionary&lt;K,
V&gt;</code>. It's named <code>Map&lt;K, V&gt;</code>. Functionally it looks very like <code>SortedDictionary&lt;K,
V&gt;</code>. there are some differences, however:
</p>
        <ul>
          <li>
            <code>Map</code> in contrast to <code>SortedDictionary</code> is very cheap on copy.</li>
          <li>
Bacause <code>Map</code> is based on AVL tree, which is more rigorly balanced than
RB tree, so it's a little bit faster asymptotically for lookup than <code>SortedDictionary</code>,
and a little bit slower on modification.</li>
          <li>
Due to the storage structure: node + navigator, <code>Map</code> consumes less memory
than <code>SortedDictionary</code>, and is probably cheaper for GC (simple garbage
graphs).</li>
          <li>
As AVL tree stores left and right subtree sizes, in contrast to a "color" in RB tree,
we able to index data in two ways: with integer index, and with key value.</li>
        </ul>
        <p>
Sources are:
</p>
        <ul>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5b7bdc23-b158-4169-b374-f55959ea5c75&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2fAVL%2fProgram.cs.txt"> Program.cs</a>;</li>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5b7bdc23-b158-4169-b374-f55959ea5c75&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2fAVL%2fAVLTreeNavigator.cs.txt"> AVLTreeNavigator.cs</a>;</li>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5b7bdc23-b158-4169-b374-f55959ea5c75&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2fAVL%2fMap.cs.txt">Map.cs</a>.</li>
        </ul>
        <p>
          <b>Update:</b>
        </p>
        <p>
It was impossible to withstand temptation to commit some primitive performance comparision. <code>Map</code> outperforms <code>SortedDictionary</code> both
in population and in access. this does not aggree with pure algorithm's theory, but
there might be other unaccounted factors: memory consumption, quality of implementation,
and so on.
</p>
        <p>
Program.cs is updated with measurements.
</p>
        <p>
          <b>Update 2:</b>
        </p>
        <p>
More occurate tests show that for some key types <code>Map</code>'s faster, for others <code>SortedDictionary</code>'s
faster. Usually <code>Map</code>'s slower during population (mutable AVL tree navigator
may fix this). the odd thing is that <code>Map&lt;string, int&gt;</code> is faster than <code>SortedDictionary&lt;string,
int&gt;</code> both for allocaction and for access. See <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=5b7bdc23-b158-4169-b374-f55959ea5c75&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2fAVL%2fAVL.xls">excel
report</a>.
</p>
        <p>
          <b>Update 3:</b>
        </p>
        <p>
Interesing observation. The following table shows maximal and average tree heights
for different node sizes in AVL and RB trees after a random population:
</p>
        <table border="1">
          <tr style="text-align: center;">
            <th>
            </th>
            <th colspan="2">
AVL</th>
            <th colspan="2">
RB</th>
          </tr>
          <tr style="text-align: center;">
            <th>
Size</th>
            <th>
Max</th>
            <th>
Avg</th>
            <th>
Max</th>
            <th>
Avg</th>
          </tr>
          <tr style="text-align: right;">
            <td>
10</td>
            <td>
4</td>
            <td>
2.90</td>
            <td>
5</td>
            <td>
3.00</td>
          </tr>
          <tr style="text-align: right;">
            <td>
50</td>
            <td>
7</td>
            <td>
4.94</td>
            <td>
8</td>
            <td>
4.94</td>
          </tr>
          <tr style="text-align: right;">
            <td>
100</td>
            <td>
8</td>
            <td>
5.84</td>
            <td>
9</td>
            <td>
5.86</td>
          </tr>
          <tr style="text-align: right;">
            <td>
500</td>
            <td>
11</td>
            <td>
8.14</td>
            <td>
14</td>
            <td>
8.39</td>
          </tr>
          <tr style="text-align: right;">
            <td>
1000</td>
            <td>
12</td>
            <td>
9.14</td>
            <td>
16</td>
            <td>
9.38</td>
          </tr>
          <tr style="text-align: right;">
            <td>
5000</td>
            <td>
15</td>
            <td>
11.51</td>
            <td>
18</td>
            <td>
11.47</td>
          </tr>
          <tr style="text-align: right;">
            <td>
10000</td>
            <td>
16</td>
            <td>
12.53</td>
            <td>
20</td>
            <td>
12.47</td>
          </tr>
          <tr style="text-align: right;">
            <td>
50000</td>
            <td>
19</td>
            <td>
14.89</td>
            <td>
23</td>
            <td>
14.72</td>
          </tr>
          <tr style="text-align: right;">
            <td>
100000</td>
            <td>
20</td>
            <td>
15.90</td>
            <td>
25</td>
            <td>
15.72</td>
          </tr>
          <tr style="text-align: right;">
            <td>
500000</td>
            <td>
25</td>
            <td>
18.26</td>
            <td>
28</td>
            <td>
18.27</td>
          </tr>
          <tr style="text-align: right;">
            <td>
1000000</td>
            <td>
25</td>
            <td>
19.28</td>
            <td>
30</td>
            <td>
19.27</td>
          </tr>
        </table>
        <p>
Here, according with theory, the height of AVL tree is shorter than the height of
RB tree. But what is most interesting is that the depth of an "average node".
This value describes a number of steps required to find a random key. RB tree is very
close and often is better than AVL in this regard.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=5b7bdc23-b158-4169-b374-f55959ea5c75" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Convenience of Generics in C#</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/02/03/ConvenienceOfGenericsInC.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,12c73e3f-8cd0-4baa-a90f-cfabefb054bf.aspx</id>
    <published>2010-02-03T03:59:19.342-08:00</published>
    <updated>2010-02-03T04:37:58.6278909-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
It was obvious as hell from day one of generics that there will appear obscure long
names when you will start to parametrize your types. It was the easiest thing in the
world to take care of this in advanvce. Alas, C# inherits C++'s bad practices.
</p>
        <p>
Read <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=12c73e3f-8cd0-4baa-a90f-cfabefb054bf&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f01%2f27%2fAssociativeContainersInAFunctionalLanguages.aspx">Associative
containers in a functional languages</a> and <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=12c73e3f-8cd0-4baa-a90f-cfabefb054bf&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2fAVL%2fProgram.cs.txt"> Program.cs</a> to
see what we're talking about.
</p>
        <p>
Briefly, there is a pair (<code>string</code>, <code>int</code>), which in C# should
be declared as:
</p>
        <p style="padding-left: 1em;">
          <code>System.Collections.Generic.KeyValuePair&lt;string, int&gt;</code>
        </p>
        <p>
Obviously we would like to write it in a short way. These are our attempts, which
fail:
</p>
        <p>
1. Introduce generic alias Pair&lt;K, V&gt;:
</p>
        <p style="padding-left: 1em;">
          <code>using System.Collections.Generic;<br />
using Pair&lt;K, V&gt; = KeyValuePair&lt;K, V&gt;;</code>
        </p>
        <p>
2. Introduce type alias for a generic type with specific types.
</p>
        <p style="padding-left: 1em;">
          <code> using System.Collections.Generic;<br />
using Pair = KeyValuePair&lt;string, int&gt;;</code>
        </p>
        <p>
And this is only one that works:
</p>
        <p style="padding-left: 1em;">
          <code> using Pair = System.Collections.Generic.KeyValuePair&lt;string, int&gt;;</code>
        </p>
        <p>
Do you think is it bearable? Well, consider the following:
</p>
        <ul>
          <li>
There is a generic type <code>ValueNode&lt;T&gt;</code>, where <code>T</code> should
be <code>Pair</code>.</li>
          <li>
There is a generic type <code>TreeNavigator&lt;N&gt;</code>, where <code>N</code> is
should be <code>ValueNode&lt;Pair&gt;</code>.</li>
        </ul>
        <p>
The declaration looks like this:
</p>
        <p style="padding-left: 1em;">
          <code> using Pair = System.Collections.Generic.KeyValuePair&lt;string, int&gt;; 
<br />
using Node = NesterovskyBros.Collections.AVL.ValueNode&lt;<br />
System.Collections.Generic.KeyValuePair&lt;string, int&gt;&gt;; 
<br />
using Navigator = NesterovskyBros.Collections.AVL.TreeNavigator&lt;<br />
NesterovskyBros.Collections.AVL.ValueNode&lt;<br />
System.Collections.Generic.KeyValuePair&lt;string, int&gt;&gt;&gt;;</code>
        </p>
        <p>
Do you still think is it acceptable?
</p>
        <p>
P.S. Legacy thinking led C#'s and java's designers to the use of word "new"
for the object construction. It is not required at all. Consider <code>new Pair("A",
1)</code> vs <code>Pair("A", 1)</code>. C++ prefers second form. C# and java always
use the first one.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=12c73e3f-8cd0-4baa-a90f-cfabefb054bf" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Associative containers in a functional languages</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/01/27/AssociativeContainersInAFunctionalLanguages.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,593edb29-559e-4571-91dd-6e02711757c7.aspx</id>
    <published>2010-01-26T23:00:55.226-08:00</published>
    <updated>2010-01-27T05:25:58.1881366-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Continuing with the post "<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=593edb29-559e-4571-91dd-6e02711757c7&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2010%2f01%2f06%2fOngoingXsltxquerySpecUpdate.aspx">Ongoing
xslt/xquery spec update</a>" we would like to articulate what options regarding associative
containers do we have in a functional languages (e.g. xslt, xquery), assuming that
variables are immutable and implementation is efficient (in some sense).
</p>
        <p>
There are three common implementation techniques:
</p>
        <ul>
          <li>
store data (keys, value pairs) in sorted array, and use binary search to access values
by a key;</li>
          <li>
store data in a hash map;</li>
          <li>
store data in a binary tree (usually RB or AVL trees).</li>
        </ul>
        <p>
Implementation choice considerably depends on operations, which are taken over the
container. Usually these are:
</p>
        <ol style="list-style-type: lower-alpha">
          <li>
construction;</li>
          <li>
value lookup by key;</li>
          <li>
key enumeration (ordered or not);</li>
          <li>
container modification (add and remove data into the container);</li>
          <li>
access elements by index;</li>
        </ol>
        <p>
Note that modification in a functional programming means a creation of a new container,
so here is a division: 
</p>
        <ol style="list-style-type: lower-alpha">
          <li>
If container's use pattern does not include modification, then probably the simplest
solution is to build it as an ordered sequence of pairs, and use binary search to
access the data. Alternatively, one could implement associative container as a hash
map.</li>
          <li>
If modification is essential then neither ordered sequence of pairs, hash map nor
classical tree implementation can be used, as they are either too slow or too greedy
for a memory, either during modification or during access.</li>
        </ol>
        <p>
On the other hand to deal with container's modifications one can build an implementation,
which uses "top-down" RB or AVL trees. To see the difference consider a classical
tree structure and its functional variant:
</p>
        <table border="1">
          <col style="text-align: left; vertical-align: top" />
          <col style="vertical-align: top" />
          <col style="vertical-align: top" />
          <tr>
            <th />
            <th>
Classical</th>
            <th>
Functional</th>
          </tr>
          <tr>
            <th>
Node structure:</th>
            <td>
              <code>node<br />
parent<br />
left<br />
right<br />
other data</code>
            </td>
            <td>
              <code>node<br /><br />
left<br />
right<br />
other data</code>
            </td>
          </tr>
          <tr>
            <th>
Node reference:</th>
            <td>
node itself</td>
            <td>
node path from a root of a tree</td>
          </tr>
          <tr>
            <th>
Modification:</th>
            <td>
either mutable or requires a completely new tree</td>
            <td>
O(LnN) nodes are created<br /></td>
          </tr>
        </table>
        <br />
        <p>
Here we observe that:
</p>
        <ol>
          <li>
one can implement efficient map (lookup time no worse than O(LnN)) with no modification
support, using ordered array;</li>
          <li>
one can implement efficient map with support of modification, using immutable binary
tree;</li>
          <li>
one can implement all these algorithms purely in xslt and xquery (provided that inline
functions are supported);</li>
          <li>
any such imlementation will lose against the same implementation written in C++, C#,
java;</li>
          <li>
the best implementation would probably start from sorted array and will switch to
binary tree after some size threshold.</li>
        </ol>
        <p>
Here we provide a C# implementation of a functional AVL tree, which also supports
element indexing:
</p>
        <ul>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=593edb29-559e-4571-91dd-6e02711757c7&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2fAVL%2fAVLTreeNavigator.cs.txt"> AVLTreeNavigator.cs</a>
          </li>
          <li>
            <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=593edb29-559e-4571-91dd-6e02711757c7&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2ftree%2fAVL%2fProgram.cs.txt"> Program.cs</a>
          </li>
        </ul>
        <p>
Our intention was to show that the usual algorithms for associative containers apply
in functional programming; thus a feature complete functional language must support
associative containers to make development more conscious, and to free a developer
from inventing basic things existing already for almost a half of century.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=593edb29-559e-4571-91dd-6e02711757c7" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Unintentional help</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/01/19/UnintentionalHelp.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,f8b61c9e-63cf-44d9-ad74-063451ae70cd.aspx</id>
    <published>2010-01-19T11:56:04.944-08:00</published>
    <updated>2010-01-19T22:00:33.470662-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Several years ago we have started a new project. We do not like neither hate any particular
language, thus the decision what language to use was pragmatical: xslt 2.0 fitted
perfectly.
</p>
        <p>
At present it's a solid volume of xslt code. It exhibits all the virtues of any other
good project in other language: clean design, modularity, documentation, sophisticationless
(good code should not be clever).
</p>
        <p>
Runtime profile of the project is that it deals with xml documents with sizes from
a few dozens of bytes to several megabytes, and with xml schemas from simple ones
like a tabular data, and to rich like xhtml and untyped. Pipeline of stylesheets processes
gigabytes of data stored in the database and in files.
</p>
        <p>
All the bragging above is needed here to introduce the context for the following couple
of lines.
</p>
        <p>
The diversity of load conditions and a big code base, exposed xslt engine of choice
to a good proof test. The victim is Saxon. In the course of project we have found
and reported many bugs. Some of them are nasty and important, and others are bearable.
To Michael Kay's credit (he's owner of Saxon) all bugs are being fixed promtly (see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=f8b61c9e-63cf-44d9-ad74-063451ae70cd&amp;url=http%3a%2f%2fsourceforge.net%2fprojects%2fsaxon%2fforums%2fforum%2f94027%2ftopic%2f3522343"> the
last one</a>).
</p>
        <p>
Such project helps us to understand a weak sides of xslt (it seems sometimes they,
in WG, lack such experience, which should lead them through).
</p>
        <p>
Well, it has happened so that we're helping to Saxon project. Unintentionally, however! <img alt=":-)" src="http://www.nesterovsky-bros.com/weblog/smilies/happy.gif" /></p>
        <p>
P.S. About language preferences. 
</p>
        <p>
Nowdays we're polishing a <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=f8b61c9e-63cf-44d9-ad74-063451ae70cd&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip">COBOL
generation</a>. To this end we have familiarized ourselves with this language. That's
the beatiful language. Its straightforwardness helps to see the evolution of computer
languages and to understand what and why today's languages try to timidly hide.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=f8b61c9e-63cf-44d9-ad74-063451ae70cd" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Languages Xml Object Model Update</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/01/15/LanguagesXmlObjectModelUpdate.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,2dbb5a3f-1f53-4042-b5d8-bfaf8d3b88de.aspx</id>
    <published>2010-01-15T08:20:41.049-08:00</published>
    <updated>2010-01-15T11:12:02.3602714-08:00</updated>
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We have updated <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2dbb5a3f-1f53-4042-b5d8-bfaf8d3b88de&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2flanguages-xom.zip"> languages-xom.zip</a>.
There are many fixes in cobolxom (well, cobolxom is new, and probably there will be
some more bugs). Also we have included Xml Object Model for the SQL, which in fact
has appeared along with jxom.
</p>
        <p style="direction: ltr">
SQL xom supports basic sql syntax including common table expressions, and two dialects
for DB2 and Oracle.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=2dbb5a3f-1f53-4042-b5d8-bfaf8d3b88de" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Ongoing xslt/xquery spec update</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/01/06/OngoingXsltxquerySpecUpdate.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,01661783-5ce8-43f3-9c25-e1f4dde1240a.aspx</id>
    <published>2010-01-06T05:13:16.717-08:00</published>
    <updated>2010-01-06T05:24:25.6937117-08:00</updated>
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently W3C has published new drafts for <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=01661783-5ce8-43f3-9c25-e1f4dde1240a&amp;url=http%3a%2f%2fwww.w3.org%2fTR%2f2009%2fWD-xquery-11-20091215">xquery
1.1</a> and for <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=01661783-5ce8-43f3-9c25-e1f4dde1240a&amp;url=http%3a%2f%2fwww.w3.org%2fTR%2fxpath-21%2f">xpath
2.1</a>. We have noticed that committee has decided to introduce inline functions
both for the xquery and for the xpath. 
</p>
        <p>
That's a really good news! This way xquery, xpath and xslt are being approached the
Object Oriented Programming the way of javascript with its inline functions.
</p>
        <p>
Now we shall be able to implement tuples (a sequence of items wrapped into single
item), object with named properties, trees (e.g. RB Tree), associative containers
(tree maps and hash maps, sets).
</p>
        <p>
Surely, all this will be in the spirit of functional programming.
</p>
        <p>
The only thing we regret about is that the WG did not include built-in implementations
for trees and associative containers, as we don't believe that one can create an efficient
implementation of these abstractions neither in xquery nor in xslt (asymptotically
results will be good, but coefficients will be painful).
</p>
        <p>
See also: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=01661783-5ce8-43f3-9c25-e1f4dde1240a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f07%2f10%2fTuplesAndMapsStatusCLOSEDWONTFIX.aspx"> Tuple
and maps</a></p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=01661783-5ce8-43f3-9c25-e1f4dde1240a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Another problem in Saxon 9.2</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/01/04/AnotherProblemInSaxon92.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,143a7a99-89b8-4f8c-940a-d0c05230ad86.aspx</id>
    <published>2010-01-04T05:39:47.57-08:00</published>
    <updated>2010-01-04T23:27:28.7115005-08:00</updated>
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Not sure how things work for others but for us it turns out that Saxon 9.2 introduces
new bugs, works slower and eats much more memory than its ancestor v9.1.
</p>
        <p>
See <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=143a7a99-89b8-4f8c-940a-d0c05230ad86&amp;url=https%3a%2f%2fsourceforge.net%2fprojects%2fsaxon%2fforums%2fforum%2f94027%2ftopic%2f3505697%2findex%2fpage%2f1"> Memory
problem with V9.2</a>.
</p>
        <p>
We hope all this will be fixed soon.
</p>
        <p>
          <b>Update:</b> By the way, Saxon 9.2 (at the moment 2009-01-04) does not like (despises
in fact) small documents and especially text nodes in those documents. It loves huge
in memory documents, however. <img alt=":-)" src="http://www.nesterovsky-bros.com/weblog/smilies/happy.gif" /></p>
        <p>
          <b>Update 2009-01-05:</b> case's closed, fix's commited into svn.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=143a7a99-89b8-4f8c-940a-d0c05230ad86" />
      </div>
    </content>
  </entry>
  <entry>
    <title>What does it mean?</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2010/01/01/WhatDoesItMean.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,a255a8ca-1816-43fd-9515-154d652d547f.aspx</id>
    <published>2010-01-01T14:17:47.849-08:00</published>
    <updated>2010-01-02T05:07:55.3509333-08:00</updated>
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today, I've tried to upgrade our projects to Saxon 9.2. We have a rather big set
of stylesheets grinding gigabytes of information. It's obvious that we expected
at least the same performance from the new version.
</p>
        <p>
But to my puzzlement a pipeline of transformations failed almost immediately with
en error message:
</p>
        <p style="padding-left: 1em;">
          <code>XPTY0018: Cannot mix nodes and atomic values in the result of a path expression </code>
        </p>
        <p>
We do agree with this statement in general, but what it had in common with our stylesheets?
And how everything was working in 9.1?
</p>
        <p>
To find the root of the problem I've created a minimal problem reproduction:
</p>
        <p style="padding-left: 1em;">
          <code>&lt;xsl:stylesheet version="2.0"<br />
xmlns:xsl="<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a255a8ca-1816-43fd-9515-154d652d547f&amp;url=http%3a%2f%2fwww.w3.org%2f1999%2fXSL%2fTransform">http://www.w3.org/1999/XSL/Transform</a>"<br />
xmlns:xs="<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a255a8ca-1816-43fd-9515-154d652d547f&amp;url=http%3a%2f%2fwww.w3.org%2f2001%2fXMLSchema">http://www.w3.org/2001/XMLSchema</a>"<br />
xmlns:t="this"<br />
exclude-result-prefixes="xs t"&gt;<br /><br />
&lt;!-- Entry point. --&gt;<br />
&lt;xsl:template match="/"&gt;<br />
&lt;xsl:variable name="p" as="element()"&gt;<br />
&lt;p l="1"/&gt;<br />
&lt;/xsl:variable&gt;<br /><br />
&lt;o l="{$p/t:d(.)}"/&gt;<br />
&lt;/xsl:template&gt;<br /><br />
&lt;xsl:function name="t:d" as="item()*"&gt;<br />
&lt;xsl:param name="p" as="element()"/&gt;<br /><br />
&lt;xsl:apply-templates mode="p" select="$p"/&gt;<br />
&lt;/xsl:function&gt;<br /><br />
&lt;xsl:template match="*" mode="p"&gt;<br />
&lt;xsl:sequence select="concat('0', @l)"/&gt;<br />
&lt;/xsl:template&gt;<br /><br />
&lt;/xsl:stylesheet&gt;</code>
        </p>
        <p>
Really simple, isn't it? The problem is in a new optimization of <code>concat()</code> function,
introduced in version 9.2. It tries to eliminate string concatenation, and in certain
cases emits its arguments directly into the output as text nodes, separating whole
output with some stopper strings. The only problem is that no such optimization is
allowed in this particular case (which is rather common, and surely legal, in our
stylesheets); result of <code> &lt;xsl:template match="p" mode="p"&gt;</code> should
not be a node, but of type <code>xs:string</code>.
</p>
        <p>
Saxon 9.2 is here already for 3 month, at lest! Thus, how come that such <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a255a8ca-1816-43fd-9515-154d652d547f&amp;url=http%3a%2f%2fsourceforge.net%2fprojects%2fsaxon%2fforums%2fforum%2f94027%2ftopic%2f3504120">a
bug</a> was not discovered earlier?
</p>
        <p>
          <b>Update:</b> the fix is commited into the svn on the next day. That's promptly!
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=a255a8ca-1816-43fd-9515-154d652d547f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Addition to XOM Family</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/12/27/AdditionToXOMFamily.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,dd5835dd-7622-44ff-9059-b44dcf3e414c.aspx</id>
    <published>2009-12-27T09:00:07.878-08:00</published>
    <updated>2009-12-27T23:20:04.0628691-08:00</updated>
    <category term="Announce" label="Announce" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,Announce.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>An xslt 2 task</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/12/21/AnXslt2Task.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,621718a1-7972-4dbb-bf4d-808aa60d78eb.aspx</id>
    <published>2009-12-21T09:19:32.682-08:00</published>
    <updated>2009-12-21T09:56:05.8242636-08:00</updated>
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Given: 
</p>
        <ul>
          <li>
an xml defining elements and groups; 
</li>
          <li>
each element belongs to a group or groups; 
</li>
          <li>
group may belong to another group. 
</li>
        </ul>
        <p>
Find: 
</p>
        <ul>
          <li>
groups, a given element directly or inderectly belongs to; 
</li>
          <li>
a function checking whether an element belongs to a group. 
</li>
        </ul>
        <p>
Example: 
</p>
        <p style="padding-left: 1em">
          <code> &lt;groups&gt;<br />
&lt;group name="g1"&gt;<br />
&lt;element ref="e1"/&gt;<br />
&lt;element ref="e2"/&gt;<br />
&lt;element ref="e3"/&gt;<br />
&lt;group ref="g2"/&gt; 
<br />
&lt;/group&gt;<br />
&lt;group name="g2"&gt; 
<br />
&lt;element ref="e5"/&gt; 
<br />
&lt;/group&gt; 
<br />
&lt;group name="g3"&gt; 
<br />
&lt;element ref="e1"/&gt; 
<br />
&lt;element ref="e4"/&gt; 
<br />
&lt;/group&gt; 
<br />
&lt;/groups&gt;</code>
        </p>
        <p>
There are several solutions depending on aggresiveness of optimization. A moderate
one is done through the xsl:key. All this reminds recursive common table expressions
in SQL. 
</p>
        <p>
Anyone?
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=621718a1-7972-4dbb-bf4d-808aa60d78eb" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Java vs C#</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/12/19/JavaVsC.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,01856d90-93f8-406d-a1cc-bb267d91ec78.aspx</id>
    <published>2009-12-19T09:08:23.6-08:00</published>
    <updated>2009-12-20T04:03:48.4413927-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In spite of the fact that our last projects are being developed in Java, the .NET
is definitly our favorite platform.
</p>
        <p>
In a <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=01856d90-93f8-406d-a1cc-bb267d91ec78&amp;url=http%3a%2f%2ftwitter.com%2folegtk%2fstatuses%2f6804433900">twitter</a> I
saw the phrase: "Java the language is a stagnant mess". It's said in favour of C#.
It's true that C# significantly affects now even on Java (let's remember generics,
jaxb, web services, etc.), but in my opinion, the C# won't be the leading language
for worldwide enterprise applications in the nearest future.
</p>
        <p>
One of causes is that the main platform for .NET still is Windows. The situation could
be changed by <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=01856d90-93f8-406d-a1cc-bb267d91ec78&amp;url=http%3a%2f%2fmono-project.com%2fMain_Page" target="blank">Mono
project</a>, but I think there are yet not enough projects on platforms other than
Windows.
</p>
        <p>
My guess is confirmed by some of observations that I did as a software engineer of
an IT company. Our company performs different software porting projects from legacy
programming languages like COBOL, ADSO, Natural etc. into up to date languages like
Java, C# etc. It worth to say that clients rarely select to migrate to .NET despite
to our advices.
</p>
        <p>
The main reason of such choice, according to most of our clients, is that they want
to be platform independent and only Java gives them this choice.
</p>
        <p>
It worth for Microsoft to think about cooperation with Mono in order to make .NET
really platform indpendent, otherwise C# will always be a step behind Java despite
apparent advantages of C# as a programming language.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=01856d90-93f8-406d-a1cc-bb267d91ec78" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Excel Reports</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/12/11/ExcelReports.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,3c37d5a6-10ed-4567-b1de-c316b4ae3953.aspx</id>
    <published>2009-12-11T01:28:32.549-08:00</published>
    <updated>2009-12-11T01:50:56.9157912-08:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A client asked us to produce Excel reports in ASP.NET application. They've given an
Excel templates, and also defined what they want to show.
</p>
        <p>
What are our options?
</p>
        <ul>
          <li>
Work with Office COM API;</li>
          <li>
Use Office Open XML SDK (which is a set of pure .NET API);</li>
          <li>
Try to apply xslt somehow;</li>
          <li>
Macro, other?</li>
        </ul>
        <p>
For us, biased to xslt, it's hard to make a fair choice. To judge, we've tried formalize
client's request and to look into future support.
</p>
        <p>
So, we have defined sql stored procedures to provide the data. This way data can be
represented either as ADO.NET DataSet, a set of classes, as xml, or in other reasonable
format. We do not predict any considerable problem with data representation if client
will decide to modify reports in future.
</p>
        <p>
It's not so easy when we think about Excel generation. 
</p>
        <p>
Due to ignorance we've thought that Excel is much like xslt in some regard, and that
it's possible to provide a tabular data in some form and create Excel template, which
will consume the data to form a final output. To some extent it's possible, indeed,
but you should start creating macro or vb scripts to achieve acceptable results.
</p>
        <p>
When we've mentioned macroses to the client, they immediately stated that such a solution
won't work due to security reasons.
</p>
        <p>
Comparing COM API and Open XML SDK we can see that both provide almost the same level
of service for us, except that the later is much more lighter and<span lang="ru"></span>supports
only Open XML format, and the earlier is a heavy API exposing MS Office and supports
earlier versions also.
</p>
        <p>
Both solutions have a considerable drawback: it's not easy to create Excel report
in C#, and it will be a pain to support such solution if client will ask, say in half
a year, to modify something in Excel template or to create one more report.
</p>
        <p>
Thus we've approached to xslt. There we've found two more directions:
</p>
        <ul>
          <li>
generate data for Office Open XML;</li>
          <li>
generate xml in format of MS Office 2003.</li>
        </ul>
        <p>
It's turned out that it's rather untrivial task to generate data for Open XML, and
it's not due to the format, which is not xml at all but a zipped folder containing
xmls. The problem is in the complex schemas and in many complex relations between
files constituting Open XML document. In contrast, MS Office 2003 format allows us
to create a single xml file for the spreadsheet.
</p>
        <p>
Selecting between standard and up to date format, and older proprietary one, the later
looks more attractive for the development and support.
</p>
        <p>
        </p>
        <p>
At present we're at position to use xslt and to generate files in MS Office 2003 format.
Are there better options?
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=3c37d5a6-10ed-4567-b1de-c316b4ae3953" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Old lesson about decimal rounding</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/12/05/OldLessonAboutDecimalRounding.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,f3a60164-b137-40fc-8305-86e6167df7fe.aspx</id>
    <published>2009-12-05T05:17:42.438-08:00</published>
    <updated>2009-12-05T08:57:10.5729075-08:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Did you ever hear that <code>double</code> numbers may cause roundings, and that many
financial institutions are very sensitive to those roundings?
</p>
        <p>
Sure you did! We're also aware of this kind of problem, and we thought we've
taken care of it. But things are not that simple, as you're not always know what
an impact the problem can have.
</p>
        <p>
To understand the context it's enough to say that we're converting (using
xslt by the way) programs written in a CASE tool called <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=f3a60164-b137-40fc-8305-86e6167df7fe&amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fCoolgen"> Cool:GEN</a> into
java and into C#. Originally, Cool:GEN generated COBOL and C programs as deliverables.
Formally, clients compare COBOL results vs java or C# results, and they want them
to be as close as possible. 
</p>
        <p>
For one particular client it was crucial to have correct results during manipulation
with numbers with 20-25 digits in total, and with 10 digits after a decimal point.
</p>
        <p>
Clients are definitely right, and we've introduced generation options to control
how to represent numbers in java and C# worlds; either as <code>double</code> or <code>BigDecimal</code> (in
java), and <code>decimal</code> (in C#).
</p>
        <p>
That was our first implementation. Reasonable and clean. Was it enough? - Not at all!
</p>
        <p>
Client's reported that java's results (they use java and <code>BigDecimal</code> for
every number with decimal point) are too precise, comparing to Mainframe's (MF)
COBOL. This rather unusuall complain puzzles a litle, but client's confirmed that
they want no more precise results than those MF produces.
</p>
        <p>
The reason of the difference was in that that both C# and especially java may store
much more decimal digits than is defined for the particualar result on MF. So, whenever
you define a field storing 5 digits after decimal point, you're sure that exactly
5 digits will be stored. This contrasts very much with results we had in java and
C#, as both multiplication and division can produce many more digits after the decimal
point. The solution was to truncate(!) (not to round) the numbers to the specific
precision in property setters.
</p>
        <p>
So, has it resolved the problem? - No, still not!
</p>
        <p>
Client's reported that now results much more better (coincide with MF, in fact)
but still there are several instances when they observe differences in 9th and 10th
digits after a decimal point, and again java's result are more accurate.
</p>
        <p>
No astonishment this time from us but analisys of the reason of the difference. It's
turned out that previous solution is partial. We're doing a final truncation but
still there were intermediate results like in <code>a/(b * c)</code>, or in <code>a
* (b/c)</code>.
</p>
        <p>
For the intermediate results MF's COBOL has its, rather untrivial, formulas (and
options) per each operation defining the number of digits to keep after a decimal
point. After we've added similar options into the generator, several truncations've
manifested in the code to adjust intermediate results. This way we've reached the
same accurateness as MF has.
</p>
        <p>
What have we learned (reiterated)?
</p>
        <ul>
          <li>
A simple problems may have far reaching impact.</li>
          <li>
More precise is not always better. Client often prefers compatible rather than more
accurate results.</li>
        </ul>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=f3a60164-b137-40fc-8305-86e6167df7fe" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Back to Ukraine</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/12/03/BackToUkraine.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0b443486-5312-4aff-a1b0-b38055aedefc.aspx</id>
    <published>2009-12-02T23:32:18.415-08:00</published>
    <updated>2009-12-03T07:15:20.534595-08:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently we were visiting Ukraine, the capital city, and a town we've come from.
</p>
        <p>
Today's Ukraine makes a twofold impression.
</p>
        <p>
On the one hand it's a childhood places and relatives, an enormous pleasure of
meeting university and school friends, a good surprise of meeting university chancellor
who was already hoary with age when we were studying.
</p>
        <p>
On the other hand it's already a very different country from what the memory draws.
I must be wrong but my impression was that it's a country of traders and endless
political battles. It's neither bad nor good but a point of history. Unfortunately
we cannot think ourselves now living in Ukraine.
</p>
        <p>
On the question where is our home now, we have the only answer it's in Israel.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0b443486-5312-4aff-a1b0-b38055aedefc" />
      </div>
    </content>
  </entry>
  <entry>
    <title>C# Haiku</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/11/13/CHaiku.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,3864c2ed-531d-430d-a8d4-5d6c0c65cb62.aspx</id>
    <published>2009-11-13T06:31:26.65-08:00</published>
    <updated>2009-11-13T22:13:34.5546739-08:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
For some reason C# lacks a decimal truncation function limiting result to a specified
number of digits after a decimal point. Don't know what's the reasoning behind,
but it stimulates the thoughts. Internet is plentiful with workarounds. A <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=3864c2ed-531d-430d-a8d4-5d6c0c65cb62&amp;url=http%3a%2f%2fstackoverflow.com%2fquestions%2f329957%2ftruncate-decimal-number-not-round-off">tipical
answer</a> is like this:
</p>
        <p style="padding-left: 1em">
          <code>Math.Truncate(2.22977777 * 1000) / 1000; // Returns 2.229</code>
        </p>
        <p>
So, we also want to provide our solution to this problem.
</p>
        <p style="padding-left: 1em">
          <code> public static decimal Truncate(decimal value, byte decimals)<br />
{<br />
decimal result = decimal.Round(value, decimals);<br />
int c = decimal.Compare(value, result);<br />
bool negative = decimal.Compare(value, 0) &lt; 0;<br /><br />
if (negative ? c &lt;= 0 : c &gt;= 0)<br />
{<br />
return result;<br />
}<br /><br />
return result - new decimal(1, 0, 0, negative, decimals);<br />
}</code>
        </p>
        <p>
Definitely, if the function were implemented by the framework it were much more efficient.
We assume, however, that above's the best implementation that can be done externally.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=3864c2ed-531d-430d-a8d4-5d6c0c65cb62" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Connection pooling in Apache</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/11/03/ConnectionPoolingInApache.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,e16de07f-4501-4c27-8eca-f68997aa7516.aspx</id>
    <published>2009-11-03T03:20:00.013-08:00</published>
    <updated>2009-11-03T03:31:11.1837843-08:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A natural curiosity led us to the implementation of connection pooling in Apache Tomcat
(org.apache.commons.dbcp).
</p>
        <p>
And what're results do you ask?
</p>
        <p>
Uneasiness... Uneasiness for all those who use it. Uneasiness due to the difference
between our expectations and real implementation.
</p>
        <p>
Briefly the design is following: 
</p>
        <ul>
          <li>
wrap every jdbc object;</li>
          <li>
cache prepared statements <b>wrappers</b>;</li>
          <li>
lookup prepared statement <b>wrappers</b> in the cache before asking original driver;</li>
          <li>
upon close return <b>wrappers</b> into the cache.</li>
        </ul>
        <p>
It took us a couple of minutes to see that this is very problematic design, as it
does not address double close of statements properly (jdbc states that is safe to
call close() over closed jdbc object). With Apache's design it's safe not
to touch the object after the close() call, as it returned to the pool and possibly
already given to an other client who requested it.
</p>
        <p>
The correct design would be:
</p>
        <ul>
          <li>
wrap every jdbc object;</li>
          <li>
cache <b>original</b> prepared statements;</li>
          <li>
lookup <b>original</b> prepared statement in the cache before asking original driver,
and return wrappers;</li>
          <li>
detach wrapper upon close from original object, and put <b>original</b> object into
the cache.</li>
        </ul>
        <p>
          <b>A bit later.</b> We've found a confirmation of our doubts on Apache site: see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e16de07f-4501-4c27-8eca-f68997aa7516&amp;url=http%3a%2f%2ftomcat.apache.org%2ftomcat-6.0-doc%2fjndi-datasource-examples-howto.html" target="blank">"JNDI
Datasource HOW-TO ", chapter "Common Problems"</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=e16de07f-4501-4c27-8eca-f68997aa7516" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A twitter conversation</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/11/03/ATwitterConversation.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,b0096b73-5d04-476a-b96a-ab0d10eacbf1.aspx</id>
    <published>2009-11-03T01:21:25.914-08:00</published>
    <updated>2009-11-03T22:54:58.8764265-08:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In a <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b0096b73-5d04-476a-b96a-ab0d10eacbf1&amp;url=http%3a%2f%2ftwitter.com%2fmichaelhkay%2fstatuses%2f5359165615">twitter</a> I've
found a conversation:
</p>
        <p style="padding-left: 1em; font-style: italic">
michaelhkay: @fgeorges [XSLT 2.1 - Still nothing public?] Afraid not. Why don't you
join the WG and help to speed things up?
</p>
        <p>
I think it's a tendency. 
</p>
        <p>
WGs are a very different world. There people think of eternity... There a pace of
time is less important than final words. But developers who're busy with their
projects, and have no enough spare time to help to WGs, cannot wait for years for
good specs and implementations. On the other hand good designers succeed dealing with
existing technologies.
</p>
        <p>
Looking into the future I see different perspectives regarding WGs. The one I think
the most is that eventually WG'll run out of its enthusiasm, which I suspect happens
after the second generation of members, and a technology'll go either to a museum,
become a legacy but sill used one, or hopefully to a university community.
</p>
        <p>
At present I'm calm about Xslt/XQuery WGs, as they're only approaching to the
second generation. My fears're about C++ WG, which is on its third decade...
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=b0096b73-5d04-476a-b96a-ab0d10eacbf1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>JSF quality</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/10/10/JSFQuality.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,f2b0eb1a-9298-4b73-b069-2db43f633b26.aspx</id>
    <published>2009-10-10T03:06:52.385374-07:00</published>
    <updated>2009-10-10T03:06:52.385374-07:00</updated>
    <category term="JSF and Facelets" label="JSF and Facelets" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,JSFAndFacelets.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
It's not a secret that we don't like JSF (something is very wrong with whole
its design), however we have no choice but to work with it. But at times to lift hands
up is only wish we have working with it.
</p>
        <p>
The last pearl is with check box control: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=f2b0eb1a-9298-4b73-b069-2db43f633b26&amp;url=http%3a%2f%2fjava.sun.com%2fjavaee%2fjavaserverfaces%2f1.2_MR1%2fdocs%2ftlddocs%2fh%2fselectBooleanCheckbox.html"> selectBooleanCheckbox</a>.
It turns out that when you disable the control on a client and assume that its value
won't be databound on a server, you're wrong. Browser does not send the value
as you would expect, but JSF (reference implementation at least) works like this:
</p>
        <p style="padding-left: 1em">
          <code> private static String isChecked(String value) {<br />
return Boolean.toString("on".equalsIgnoreCase(value)<br />
|| "yes".equalsIgnoreCase(value)<br />
|| "true".equalsIgnoreCase(value));<br />
}</code>
        </p>
        <p>
where <code>value</code> is <code>null</code>, which means that JSF thinks checkbox
is unchecked.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=f2b0eb1a-9298-4b73-b069-2db43f633b26" />
      </div>
    </content>
  </entry>
  <entry>
    <title>JSF/Facelets, conditional attributes</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/10/07/JSFFaceletsConditionalAttributes.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,7d9050ad-3e00-4242-9d57-8174a110e598.aspx</id>
    <published>2009-10-07T02:16:10.216-07:00</published>
    <updated>2009-10-21T03:46:49.3312912-07:00</updated>
    <category term="JSF and Facelets" label="JSF and Facelets" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,JSFAndFacelets.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Our experience with facelets shows that when you're designing a composition components
you often want to add a level of customization. E.g. generate element with or without
id, or define class/style if value is specified.
</p>
        <p>
Consider for simplicity that you want to encapsulate a check box and pass several
attributes to it. The first version that you will probably think of is something like
this:
</p>
        <p style="padding-left: 1em">
          <code>&lt;html xmlns="<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7d9050ad-3e00-4242-9d57-8174a110e598&amp;url=http%3a%2f%2fwww.w3.org%2f1999%2fxhtml">http://www.w3.org/1999/xhtml</a>"<br />
xmlns:ui="<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7d9050ad-3e00-4242-9d57-8174a110e598&amp;url=http%3a%2f%2fjava.sun.com%2fjsf%2ffacelets">http://java.sun.com/jsf/facelets</a>" 
<br />
xmlns:c="<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7d9050ad-3e00-4242-9d57-8174a110e598&amp;url=http%3a%2f%2fjava.sun.com%2fjstl%2fcore">http://java.sun.com/jstl/core</a>" 
<br />
xmlns:h="<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7d9050ad-3e00-4242-9d57-8174a110e598&amp;url=http%3a%2f%2fjava.sun.com%2fjsf%2fhtml">http://java.sun.com/jsf/html</a>"<br />
xmlns:ex="<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=7d9050ad-3e00-4242-9d57-8174a110e598&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2f">http://www.nesterovsky-bros.com/jsf</a>"&gt;<br />
&lt;body&gt;<br />
&lt;!-- 
<br />
Attributes:<br />
id - an optional id;<br />
value - a data binding;<br />
class - an optional element class;<br />
style - an optional element inline style;<br />
onclick - an optional script event handler for onclick event;<br />
onchange - an optional script event handler for onchange event.<br />
--&gt;<br />
&lt;ui:component&gt;<br />
&lt;h:selectBooleanCheckbox 
<br />
id="#{id}" 
<br />
value="#{value}"<br />
style="#{style}"<br />
class="#{class}"<br />
onchange="#{onchange}"<br />
onclick="#{onclick}"/&gt;<br />
&lt;/ui:component&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt; </code>
        </p>
        <p>
Be sure, this is not what you have expected. Output will contain all mentioned attributes,
even those, which weren't passed into a component (they will have empty values).
More than that, if you will omit "id", you will get an error like: <i>"emtpy
string is not valid id"</i>.
</p>
        <p>
The reason is in the EL! Attributes used in this example are of type <code>String</code>,
thus result of evaluation of value expression is coersed to <code>String</code>. Values
of attributes that weren't passed in are evaluated to <code>null</code>. EL returns <code>""</code> while
coersing <code>null</code> to <code>String</code>. The interesting thing is that,
if EL were not changing <code>null</code> then those omitted attributes would not
appear in the output.
</p>
        <p>
The second attept would probably be:
</p>
        <p style="padding-left: 1em">
          <code> &lt;h:selectBooleanCheckbox value="#{value}"&gt;<br />
&lt;c:if test="#{!empty id}"&gt;<br />
&lt;f:attribute name="id" value="#{id}"/&gt;<br />
&lt;/c:if&gt;<br />
&lt;c:if test="#{!empty onclick}"&gt;<br />
&lt;f:attribute name="onclick" value="#{onclick}"/&gt;<br />
&lt;/c:if&gt;<br />
&lt;c:if test="#{!empty onchange}"&gt;<br />
&lt;f:attribute name="onchange" value="#{onchange}"/&gt;<br />
&lt;/c:if&gt;<br />
&lt;c:if test="#{!empty class}"&gt;<br />
&lt;f:attribute name="class" value="#{class}"/&gt;<br />
&lt;/c:if&gt;<br />
&lt;c:if test="#{!empty style}"&gt;<br />
&lt;f:attribute name="style" value="#{style}"/&gt;<br />
&lt;/c:if&gt; 
<br />
&lt;/h:selectBooleanCheckbox&gt;</code>
        </p>
        <p>
Be sure, this won't work either (it may work but not as you would expect). Instruction <code>c:if</code> is
evaluated on the stage of the building of a component tree, and not on the rendering
stage.
</p>
        <p>
To workaround the problem you should prevent <code>null</code> to <code>""</code> conversion
in the EL. That's, in fact, rather trivial to achieve: value expression should
evaluate to an object different from <code>String</code>, whose <code>toString()</code> method
returns a required value.
</p>
        <p>
The final component may look like this:
</p>
        <p style="padding-left: 1em">
          <code>&lt;h:selectBooleanCheckbox 
<br />
id="#{ex:object(id)}" 
<br />
value="#{value}"<br />
style="#{ex:object(style)}"<br />
class="#{ex:object(class)}"<br />
onchange="#{ex:object(onchange)}"<br />
onclick="#{ex:object(onclick)}"/&gt;</code>
        </p>
        <p>
where ex:object() is a function defined like this:
</p>
        <p style="padding-left: 1em">
          <code> public static Object object(final Object value)<br />
{<br />
return new Object()<br />
{<br />
public String toString()<br />
{<br />
return value == null ? null : value.toString();<br />
}<br />
}<br />
}</code>
        </p>
        <p>
          <b>A bit later: </b>not everything works as we expected. Such approach doesn't work
with the <code>validator</code> attribute, whereas it works with <code>converter</code> attribute.
The difference between them is that the first attribute should be <code>MethodExpression</code> value,
when the second one is <code>ValueExpression</code> value. Again, we suffer from ugly
JSF implementation of UOutput component. 
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=7d9050ad-3e00-4242-9d57-8174a110e598" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Dilemma</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/09/22/Dilemma.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,e38729d9-e22f-4779-b470-2e538fcf991c.aspx</id>
    <published>2009-09-22T01:16:11.302-07:00</published>
    <updated>2009-12-19T09:21:27.4708896-08:00</updated>
    <category term="Thinking aloud" label="Thinking aloud" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,ThinkingAloud.aspx" />
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Suppose you have a library, which is out in the production and is used by many clients.
At the same time the library evolves: API is extended, bugs are being fixed, code
becomes faster and cleaner, bla bla bla...
</p>
        <p>
At some point you're fixing some important bug that's been hiding for a long time
in the bowels of your library. You're happy that you've spotted it before clients
got into troubles. You're notifying all the clients that there is an important fix,
and that they need to update the library.
</p>
        <p>
What do you think you hear in return?
</p>
        <p>
Well, we're not perfect, there are bugs in our software. We and our clients realize
this. Nothing will eliminate bugs to creep into a code from time to time.
</p>
        <p>
That's a train of thought of a particular client:
</p>
        <p style="PADDING-LEFT: 1em; FONT-STYLE: italic">
We agree that there is a bug and that it has to be fixed. We, however, want to touch
the library in a minimal way, as who knows what other new bugs had they introduced,
so let's ask them to fix this particular bug in our version of the library.
</p>
        <p>
That's fair from the client's perspective. They don't want better code, they just
want that particular bug fixed!
</p>
        <p>
For us, however, this means branching some old version of the library, fixing bug
and supporting this branch for the particular client. It's fair to expect similar
position from each client, thus should we create and support library branches per
client, and branch a main branch for a new client only?
</p>
        <p>
For us (Arthur and Vladimir) it looks as enormous waste of resources. We (our company)
should either hire more and more scaled people or experience gradual slowdown of support
and development.
</p>
        <p>
Our answer could be obvious if not position of top managers who value client relations
so much that they easily promise whatever client wishes. No arguments that latest
version is better tested, more conforming to specifications, more reliable, faster
and so on are accepted. The main argument against our position is that the client's
applications run in the production, and no new potential bugs are acceptable.
</p>
        <p>
Here is our dilemma: we neither can convince the client (more precisely our managers)
that we're right, nor are convinced with their arguments...
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=e38729d9-e22f-4779-b470-2e538fcf991c" />
      </div>
    </content>
  </entry>
  <entry>
    <title>JSF clientId</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/09/09/JSFClientId.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,890d7c31-b881-4bb3-b5f3-d680f61f318a.aspx</id>
    <published>2009-09-09T04:39:14.836-07:00</published>
    <updated>2009-09-10T13:31:15.1891403-07:00</updated>
    <category term="JSF and Facelets" label="JSF and Facelets" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,JSFAndFacelets.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently we have seen a blog entry: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=890d7c31-b881-4bb3-b5f3-d680f61f318a&amp;url=http%3a%2f%2fillegalargumentexception.blogspot.com%2f2009%2f05%2fjsf-ids-and-clientids-in-facelets.html">"JSF:
IDs and clientIds in Facelets"</a>, which provided wrong implementation of the feature.
</p>
        <p>
I'm not sure how useful it is, but here is our approach to the same problem.
</p>
        <p>
In the core is <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=890d7c31-b881-4bb3-b5f3-d680f61f318a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjsf1.2%2fScopeComponent.java.txt">ScopeComponent</a>.
Example uses a couple of utility functions defined in <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=890d7c31-b881-4bb3-b5f3-d680f61f318a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjsf1.2%2fFunctions.java.txt">Functions</a>.
Example itself is found at <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=890d7c31-b881-4bb3-b5f3-d680f61f318a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjsf1.2%2fwindow.xhtml.txt" type="text/plain">window.xhtml</a>:
</p>
        <p style="padding-left: 1em">
          <code>&lt;html xmlns="http://www.w3.org/1999/xhtml"<br />
xmlns:ui="http://java.sun.com/jsf/facelets"<br />
xmlns:c="http://java.sun.com/jstl/core"<br />
xmlns:h="http://java.sun.com/jsf/html"<br />
xmlns:f="http://java.sun.com/jsf/core"<br />
xmlns:fn="http://java.sun.com/jsp/jstl/functions"<br />
xmlns:ex="http://www.nesterovsky-bros.com/jsf"&gt;<br />
&lt;body&gt;<br />
&lt;h:form&gt;<br />
&lt;ui:repeat value="#{ex:sequence(5)}"&gt;<br />
&lt;f:subview id="scope" binding="#{ex:scope().value}"&gt;<br />
#{scope.id}, #{scope.clientId}<br />
&lt;/f:subview&gt;<br />
&lt;f:subview id="script" uniqueId="my-script"<br />
binding="#{ex:scope().value}" myValue="#{2 + 2}"&gt;<br />
, #{script.id}, #{script.clientId},<br />
#{script.bindings.myValue.expressionString},<br />
#{ex:value(script.bindings.myValue)},<br />
#{script.attributes.myValue}<br />
&lt;/f:subview&gt;<br />
&lt;br/&gt;<br />
&lt;/ui:repeat&gt;<br />
&lt;/h:form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code>
        </p>
        <p>
          <b>Update:</b> ex:scope() is made to return a simple bean with property "value".
</p>
        <p>
Another useful example:
</p>
        <p style="padding-left: 1em">
          <code> &lt;f:subview id="group" binding="#{ex:scope().value}"&gt;<br />
&lt;h:inputText id="input" value="#{bean.property}"/&gt;<br />
&lt;script type="text/javascript"&gt;<br />
var element = document.getElementById('#{group.clientId}:input');<br />
&lt;/script&gt;<br />
&lt;/f:subview&gt;<br /></code>
        </p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=890d7c31-b881-4bb3-b5f3-d680f61f318a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>About JSF 2.0</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/09/09/AboutJSF20.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,39492e20-5446-4a99-a2d2-bd7ab0366171.aspx</id>
    <published>2009-09-08T22:54:38.311-07:00</published>
    <updated>2009-09-10T13:32:02.1413638-07:00</updated>
    <category term="JSF and Facelets" label="JSF and Facelets" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,JSFAndFacelets.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the section about AJAX, JSF 2.0 spec (final draft) talks about partial requests...
</p>
        <p>
This sounds rather strange. My perception was that the AJAX is about partial responses.
What a sense to send partial requests? Requests are comparatively small anyway! Besides,
a partial request may complicate restoring component tree on the server and made things
fragile, but this largely depends on what they mean with these words.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=39492e20-5446-4a99-a2d2-bd7ab0366171" />
      </div>
    </content>
  </entry>
  <entry>
    <title>EL references in JSF/Facelets</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/08/29/ELReferencesInJSFFacelets.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,a64eebaa-9408-48d0-85a1-c341b31e0480.aspx</id>
    <published>2009-08-29T06:11:26.321-07:00</published>
    <updated>2009-09-10T13:33:52.7329904-07:00</updated>
    <category term="JSF and Facelets" label="JSF and Facelets" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,JSFAndFacelets.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently we were disputing (Arthur vs Vladimir) about the benefits of ValueExpression
references in JSF/Facelets.
</p>
        <p>
Such dispute in itself presents rather funny picture when you're defending one
position and after a while you're taking opposite point and starting to maintain
it. But let's go to the problem.
</p>
        <p>
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a64eebaa-9408-48d0-85a1-c341b31e0480&amp;url=http%3a%2f%2fjava.sun.com%2fjavaee%2f5%2fdocs%2ftutorial%2fdoc%2fbnaph.html">JSF/Facelets</a> uses <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=a64eebaa-9408-48d0-85a1-c341b31e0480&amp;url=http%3a%2f%2fjava.sun.com%2fjavaee%2f5%2fdocs%2ftutorial%2fdoc%2fbnahq.html">Unified
Expression Language</a> for the data binding, e.g.:
</p>
        <p style="padding-left: 1em;">
          <code>&lt;h:inputText id="name" value="#{customer.name}" /&gt;</code>
        </p>
        <p>
or
</p>
        <p style="padding-left: 1em;">
          <code>&lt;h:selectBooleanCheckbox id="selected" value="#{customer.selected}" /&gt;</code>
        </p>
        <p>
In these cases value from input and check boxes are mapped to a properties <code>name</code>,
and <code>selected</code> of a bean named <code>customer</code>. Everything is fine
except of a case when <code>selected</code> is not of boolean type (e.g. <code>int</code>).
In this case you will have a hard time thinking on how to adapt bean property to the
jsf component. Basically, you have to provide a bean adapter, or change type of property.
Later is unfeasible in our case, thus we're choosing bean adapter. More than that
we have to create a generic solution for <code>int</code> to <code>boolean</code> property
type adapter. With this target in mind we may create a function receiving bean and
a property name and returning other bean with a single propery of boolean type:
</p>
        <p style="padding-left: 1em;">
          <code>&lt;h:selectBooleanCheckbox id="selected"<br />
value="#{ex:toBoolean(customer, 'selected').value}" /&gt;</code>
        </p>
        <p>
But thinking further the question appears: whether we can pass ValueExpression by
reference into a bean adapter function, and have something like this:
</p>
        <p style="padding-left: 1em;">
          <code>&lt;h:selectBooleanCheckbox id="selected"<br />
value="#{ex:toBoolean(byref customer.selected).value}" /&gt;</code>
        </p>
        <p>
It turns out that it's possible to do this kind of thing. Unfortunately it requires
custom facelets tag, like this:
</p>
        <p style="padding-left: 1em;">
          <code>&lt;ex:ref var="selected" value="#{customer.selected}"/&gt;<br /><br />
&lt;h:selectBooleanCheckbox id="selected"<br />
value="#{ex:toBoolean(selected).value}" /&gt;</code>
        </p>
        <p>
Implementation of such a tag is really primitive (in fact it mimics c:set tag handler
except one line), but still it's an extension on the level we don't happy
to introduce.
</p>
        <p>
This way we were going circles considering pros and cons, regretting that el references
ain't native in jsf/facelets and weren't able to classify whether our solution
is a hack or a neat extension...
</p>
        <p>
P.S. We know that JSF 2.0 provides solution for <code>h:selectBooleanCheckbox</code> but
still there are cases when similar technique is required even there.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=a64eebaa-9408-48d0-85a1-c341b31e0480" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Unsound java protected modifier</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/08/21/UnsoundJavaProtectedModifier.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,c9d56435-8983-4c9a-b2f4-3dc4cf88ab01.aspx</id>
    <published>2009-08-21T05:25:59.194-07:00</published>
    <updated>2009-09-25T01:41:03.5592992-07:00</updated>
    <category term="JSF and Facelets" label="JSF and Facelets" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,JSFAndFacelets.aspx" />
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We always tacitly assumed that <b><code>protected</code></b> modifier in java permits
member access from a class the member belongs to, or from an instance of class's descendant.
Very like the C++ defines it, in fact. 
</p>
        <p>
In other words no external client of an instance can directly access a protected member
of that instance or class the instance belongs to. 
</p>
        <p>
It would be very interesting to know how many people live with such a naivete, really! 
</p>
        <p>
Well, that's what java states: 
</p>
        <p style="padding-left: 1em; font-style: italic">
The protected modifier specifies that the member can only be accessed within its own
package (as with package-private) and, in addition, by a subclass of its class in
another package. 
</p>
        <p>
If one'll think, just a little, she'll see that this gorgeous definition is
so different from C++'s and so meaningless that they would better dropped this
modifier altogether. 
</p>
        <p>
The hole is so huge that I can easily build an example showing how to modify protected
member of some other class in a perfectly valid way. Consider: 
</p>
        <p>
MyClass.java
</p>
        <p style="padding-left: 1em">
          <code>package com.mypackage;<br /><br />
import javax.faces.component.Hack;<br />
import javax.faces.component.UIComponentBase;<br /><br />
import javax.faces.event.FacesListener;<br /><br />
public class MyClass<br />
{<br />
public void addFacesListener(<br />
UIComponentBase component,<br />
FacesListener listener)<br />
{<br />
Hack.addFacesListener(component, listener);<br />
}<br /><br />
...<br />
}</code>
        </p>
        <p>
Hack.java
</p>
        <p style="padding-left: 1em">
          <code>package javax.faces.component;<br /><br />
import javax.faces.event.FacesListener;<br /><br />
public class Hack<br />
{<br />
public static void addFacesListener(<br />
UIComponentBase component,<br />
FacesListener listener)<br />
{<br />
component.<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c9d56435-8983-4c9a-b2f4-3dc4cf88ab01&amp;url=http%3a%2f%2fjava.sun.com%2fjavaee%2fjavaserverfaces%2f1.2%2fdocs%2fapi%2fjavax%2ffaces%2fcomponent%2fUIComponentBase.html%23addFacesListener(javax.faces.event.FacesListener)">addFacesListener(listener)</a>;<br />
}<br />
}</code>
        </p>
        <p>
An example is about to how one adds custom listener to an arbitrary jsf component.
Notice that this is not assumed by design, as a method addFacesListener() is protected.
But see how easy one can hack this dummy "protected" notion.
</p>
        <p>
          <b>Update:</b> for a proper implementation of protected please read <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=c9d56435-8983-4c9a-b2f4-3dc4cf88ab01&amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fManifest_file">Manifest
file</a>, a part about package sealing.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=c9d56435-8983-4c9a-b2f4-3dc4cf88ab01" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Funny method to support JSON in java</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/08/20/FunnyMethodToSupportJSONInJava.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,e75751f1-9f2a-4ff6-8e14-2e6994ed6982.aspx</id>
    <published>2009-08-19T23:28:37.9543345-07:00</published>
    <updated>2009-08-19T23:28:37.9543345-07:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just in case, if you don't know what <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e75751f1-9f2a-4ff6-8e14-2e6994ed6982&amp;url=http%3a%2f%2fwww.json.org%2f">JSON
stands for - it's JavaScript Object Notation</a>.
</p>
        <p>
You may find a plenty of JSON implementations in java, so we shall add one more idea.
Briefly, it's about to plug it into xml serialization infrastructure <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e75751f1-9f2a-4ff6-8e14-2e6994ed6982&amp;url=https%3a%2f%2fjaxb.dev.java.net%2f">JAXB</a>.
Taking into account that JAXB now is an integral part of java platform itself, benefits
are that you can transparently use the same beans for xml and JSON serialization.
</p>
        <p>
What you need to do is only to provide JSON reader and writer under the hood of <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e75751f1-9f2a-4ff6-8e14-2e6994ed6982&amp;url=http%3a%2f%2fjava.sun.com%2fwebservices%2fdocs%2f1.5%2fapi%2fjavax%2fxml%2fstream%2fXMLStreamReader.html">XMLStreamReader</a> and <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e75751f1-9f2a-4ff6-8e14-2e6994ed6982&amp;url=http%3a%2f%2fjava.sun.com%2fwebservices%2fdocs%2f1.5%2fapi%2fjavax%2fxml%2fstream%2fXMLStreamWriter.html">XMLStreamWriter</a> interfaces.
</p>
        <p>
In spare time we shall implement this idea.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=e75751f1-9f2a-4ff6-8e14-2e6994ed6982" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Notes for javaist</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/08/19/NotesForJavaist.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,d34b4c0f-25ec-4069-a632-acb2f63a546f.aspx</id>
    <published>2009-08-18T21:44:42.624-07:00</published>
    <updated>2009-08-18T22:20:07.400129-07:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you by chance see lines like the following in your code:
</p>
        <p style="padding-left: 1em">
          <code>
            <b>private transient final</b> Type field;</code>
        </p>
        <p>
then know, you're in the trouble!
</p>
        <p>
The reason is simple, really (provided you're sane and don't put field modifiers without
reason). <b>transient</b> assumes that your class is serializable, and you have a
particular field that you don't want to serialize. <b>final</b> states that the field
is initialized in the constructor, and does not change the value for the rest life
cycle.
</p>
        <p>
This way if you will serialize an instance of class with such a field, and then deserialize
it back, you will have the field initialized with <b>null</b>, and no way to have
another value there.
</p>
        <p>
P.S. That's what we have found in our code recently:
</p>
        <p style="padding-left: 1em">
          <code>
            <b>private transient final</b> Lock sync = <b>new</b> ReentrantLock();</code>
        </p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=d34b4c0f-25ec-4069-a632-acb2f63a546f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Borland Went To Micro Focus</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/08/10/BorlandWentToMicroFocus.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,e23edc5f-814e-42db-a289-54acc4a42604.aspx</id>
    <published>2009-08-09T21:25:15.925-07:00</published>
    <updated>2009-08-10T02:18:54.3071115-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Well, we ain't a top news trackers, so only today have found that Micro Focus has
acquired <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e23edc5f-814e-42db-a289-54acc4a42604&amp;url=http%3a%2f%2fwww.borland.com%2f">Borland</a>.
</p>
        <p>
Once, we were a great supporters of their C++ and Pascal software, but then something
has changed. Was it an inspiration that had left them or something else?
</p>
        <p>
Anyhow, their products will live for a long time, but that's a very different kind
of life, similar to a lot of COBOL.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=e23edc5f-814e-42db-a289-54acc4a42604" />
      </div>
    </content>
  </entry>
  <entry>
    <title>C++0x without concepts</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/08/06/C0xWithoutConcepts.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,9c709fa0-c7d7-4496-b09e-2ec2c3b4e98e.aspx</id>
    <published>2009-08-06T06:45:45.856-07:00</published>
    <updated>2009-08-06T08:55:04.5614815-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Forthcoming update of C++ standard will not include <b>concepts</b>!
</p>
        <p>
This the major backoff is very unfortunate, in my opinion, for C++'s future. Anyhow,
there is a strong reasoning behind the decision. WG experienced the lack of resources,
and a threatening amount of open questions and inconsistencies related to concepts.
</p>
        <p>
Besides, there is no proper and up to date C++ compiler implementing the feature,
which made impossible to verify ideas. All that might delay the C++0x standard up
to 2012 or even 2015.
</p>
        <p>
As result WG's decided to move concepts out of scope of the nearest update.
</p>
        <p>
I hope very much that concepts will follow soon after the standard.
</p>
        <p>
Read more at: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=9c709fa0-c7d7-4496-b09e-2ec2c3b4e98e&amp;url=http%3a%2f%2fcpp-next.com%2farchive%2f2009%2f08%2fwhat-happened-in-frankfurt%2f">What
Happened in Frankfurt?</a><img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=9c709fa0-c7d7-4496-b09e-2ec2c3b4e98e" /></p>
      </div>
    </content>
  </entry>
  <entry>
    <title>Our motto</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/07/28/OurMotto.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,b2053d6b-1bb6-4d83-b64d-e5a77094db20.aspx</id>
    <published>2009-07-28T01:23:28.293-07:00</published>
    <updated>2009-07-28T20:48:16.361986-07:00</updated>
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <table border="0" width="100%">
          <tr>
            <td style="vertical-align: top;">
A week ago my brothers had returned from their journey to France. They have brought
a reproduction of one of remarkable and meaningful images. The title on it can be
used as our motto.</td>
            <td style="width: 120px;">
              <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b2053d6b-1bb6-4d83-b64d-e5a77094db20&amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fFile%3aWe_Can_Do_It!.jpg" traget="blank_" title="We Can Do It!">
                <img style="width: 116px; height: 150px;" src="http://www.acclaimimages.com/_gallery/_images_n300/0420-0611-1314-4657_vintage_the_we_can_do_it_rosie_the_riveter_poster_by_j_howard_miller.jpg" />
              </a>
            </td>
          </tr>
        </table>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=b2053d6b-1bb6-4d83-b64d-e5a77094db20" />
      </div>
    </content>
  </entry>
  <entry>
    <title>cool:gen java bean generation</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/07/23/coolgenJavaBeanGeneration.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,fc1f7ba7-97c4-4dfe-9901-6c863ad54152.aspx</id>
    <published>2009-07-23T11:22:12.764-07:00</published>
    <updated>2009-07-23T11:25:04.946436-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Interestingly enough that a google search for "coolgen java bean generation" leads
to our site.
</p>
        <p>
That's a good starting point, as we support such conversions. We, however, suggest
to follow to <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=fc1f7ba7-97c4-4dfe-9901-6c863ad54152&amp;url=http%3a%2f%2fwww.bphx.com%2f">BluePhoenix</a> location.
That's where the bosses live. <img alt=":-)" src="http://www.nesterovsky-bros.com/weblog/smilies/happy.gif" /></p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=fc1f7ba7-97c4-4dfe-9901-6c863ad54152" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A Generics Solution</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/07/20/AGenericsSolution.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,3168d991-71d3-4a84-baf3-fe005089403b.aspx</id>
    <published>2009-07-20T00:18:51.487-07:00</published>
    <updated>2009-07-20T07:41:12.2159495-07:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Generics in C# look inferior to templates (especially to concepts) in C++, however
now and then you can build a wonderful pieces the way a C++ profi would envy. 
</p>
        <p>
Consider a generic converter method: <code>T Convert&lt;T&gt;(object value)</code>. 
</p>
        <p>
In C++ I would create several template specializations for all supported conversions.
Well, to make things harder, think of converter provider supporting conversion:
</p>
        <p style="padding-left: 1em">
          <code>public interface IConverterProvider<br />
{<br />
Converter&lt;object, T&gt; Get&lt;T&gt;();<br />
}</code>
        </p>
        <p>
That begins to be a puzzle in C++, but C# handles it easily!
</p>
        <p>
My first C#'s implementation was too naive, and spent too many cycles in provider,
resolving which converter to use. So, I went on, and have created a sofisticated implementation
like this:
</p>
        <p style="padding-left: 1em">
          <code> private IConverterProvider provider = ...<br /><br />
public T Convert&lt;T&gt;(object value)<br />
{<br />
var converter = provider.Get&lt;T&gt;();<br /><br />
return converter(value);<br />
}<br /><br />
...<br /><br />
public class ConverterProvider: IConverterProvider<br />
{<br />
public Converter&lt;object, T&gt; Get&lt;T&gt;()<br />
{<br />
return Impl&lt;T&gt;.converter;<br />
}<br /><br />
private static class Impl&lt;T&gt;<br />
{<br />
static Impl()<br />
{<br />
// Heavy implementation initializing converters.<br />
converter = ...<br />
}<br /><br />
public static readonly Converter&lt;object, T&gt; converter;<br />
}<br />
}</code>
        </p>
        <p>
Go, and do something close in C++!
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=3168d991-71d3-4a84-baf3-fe005089403b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Paris, Paris...</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/07/10/ParisParis.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,fe4a78f8-aaff-4c0e-8dfd-49caa8bda2be.aspx</id>
    <published>2009-07-10T06:58:27.464-07:00</published>
    <updated>2009-07-11T03:57:08.8539775-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Living in Israel, moving almost exclusively in a car I would not experience what I've
seen today in metro of Paris.
</p>
        <p>
On the Ranelagh station an old woman has entered the train. She's in her mid seventies.
Once, she was beautiful. She still is! Colors and features are faded but her dressing
and posture are still elegant. But what's struck me most are her eyes. Well, they
ain't beautiful anymore. I've read a sadness there.
</p>
        <p>
I think she will probably live ten or even twenty years more, but she would give them
up just for one year to be younger.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=fe4a78f8-aaff-4c0e-8dfd-49caa8bda2be" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Funny xpath</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/06/29/FunnyXpath.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,96128977-21c0-4fb5-8e3f-40fbecdbe76b.aspx</id>
    <published>2009-06-28T23:00:28.414-07:00</published>
    <updated>2009-06-28T23:04:02.610854-07:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you have a string variable <code>$value as xs:string</code>, and want to know whether
it starts from a digit, then what's the best way to do it in the xpath?
</p>
        <p>
Our answer is: <code>($value ge '0') and ($value lt ':')</code>.
</p>
        <p>
Looks a little funny (and disturbing).
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=96128977-21c0-4fb5-8e3f-40fbecdbe76b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Xml Diff And Merge</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/06/24/XmlDiffAndMerge.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,a5877fe2-a986-466c-a77a-fe91bfa68094.aspx</id>
    <published>2009-06-24T04:40:32.716-07:00</published>
    <updated>2009-06-24T08:41:32.5978375-07:00</updated>
    <category term="Tips and tricks" label="Tips and tricks" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,TipsAndTricks.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In our project we're generating a lot of xml files, which are subjects of manual
changes, and repeated generations (often with slightly different generation options).
This way a life flow of such an xml can be described as following:
</p>
        <ol>
          <li>
generate original xml (version 1)</li>
          <li>
manual changes (version 2)</li>
          <li>
next generation (version 3)</li>
          <li>
manual changes integrated into the new generation (version 4)</li>
        </ol>
        <p>
If it were a regular text files we could use <code>diff</code> utility to prepare
patch between versions 1 and 2, and apply it with <code>patch</code> utility to a
version 3. Unfortunately xml has additional semantics compared to a plain text. What's
an invariant or a simple modification in xml is often a drastic change in text. <code>diff</code>/<code>patch</code> does
not work well for us. We need xml diff and patch.
</p>
        <p>
The first guess is to google it! Not so simple. We have failed to find a tool or an
API that can be used from ant. There are a lot of GUIs to show xml differences and
to perform manual merge, or doing similar but <b>different</b> things to what we need
(like MS's xmldiffpatch).
</p>
        <p>
Please point us to such a program!
</p>
        <p>
Meantime, we need to proceed. We don't believe that such a tool can be done on
the knees, as it's a heuristical and mathematical at the same time task requiring
a careful design and good statistics for the use cases. Our idea is to exploit <code>diff</code>/<code>patch</code>.
To achieve the goals we're going to perform some normalization of xmls before <code>diff</code> to
remove redundant invariants, and normalization after the <code>patch</code> to return
it into a readable form. This includes:
</p>
        <ul>
          <li>
ordering attributes by their names;</li>
          <li>
replacing unsignificant whitespaces with line breaks;</li>
          <li>
entering line breaks after element names and before attributes, after attribute name
and before it's value, and after an attribute value.</li>
        </ul>
        <p>
This way we expect to recieve files reacting to modifications similarly to text files.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=a5877fe2-a986-466c-a77a-fe91bfa68094" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Most ancient program</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/06/18/MostAncientProgram.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,18a1cab1-5a37-42a4-afe3-ff6a47e25491.aspx</id>
    <published>2009-06-18T09:01:46.897-07:00</published>
    <updated>2009-06-21T06:22:12.3652915-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <i>Ladies and gentlemen of the jury, exhibit number one is what the seraphs, the misinformed,
simple, noble-winged seraphs, envied.</i> Look at this the most ancient program:
</p>
        <p>
          <a href="/weblog/content/binary/ancient.JPG">
            <img alt="most ancient program" src="/weblog/content/binary/ancient.JPG" style="width: 35em; " />
          </a>
        </p>
        <p>
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=18a1cab1-5a37-42a4-afe3-ff6a47e25491&amp;url=http%3a%2f%2fcode.msdn.microsoft.com%2fProject%2fProjectDirectory.aspx%3fProjectSearchText%3dxmldif">See
origin</a>
        </p>
        <p>
          <img alt=":-)" src="http://www.nesterovsky-bros.com/weblog/smilies/happy.gif" />
        </p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=18a1cab1-5a37-42a4-afe3-ff6a47e25491" />
      </div>
    </content>
  </entry>
  <entry>
    <title>jxom/C# xom update</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/06/18/jxomCXomUpdate.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,9f16f2c9-f7b2-4894-8ae9-b2b630b2d819.aspx</id>
    <published>2009-06-18T08:11:53.055-07:00</published>
    <updated>2009-06-24T08:34:19.533571-07:00</updated>
    <category term="Announce" label="Announce" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,Announce.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>jxom/C# xom update</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/06/15/jxomCXomUpdate.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,24bb2297-32bc-488d-9bc4-5549f99f6f49.aspx</id>
    <published>2009-06-15T07:51:11.924-07:00</published>
    <updated>2009-06-15T08:04:29.5862265-07:00</updated>
    <category term="Announce" label="Announce" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,Announce.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Too sad</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/06/09/TooSad.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,309a2b53-e916-4eed-987d-6805a5c3642e.aspx</id>
    <published>2009-06-09T12:12:25.276-07:00</published>
    <updated>2009-06-09T12:41:41.564079-07:00</updated>
    <author>
      <name>Arthur Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today an old book was extracted by my son on the light of God. The book was immediatly
opened on this verse:
</p>
        <p>
          <i>Any trifle can become<br />
a main business of your life.<br />
You just need be a firmly believed<br />
that there is nothing more important that can be achieved.<br />
And then nothing won't prevent you gasp out from delight to engage with this nonsense.</i>
        </p>
        <p>
Unfortunatelly too often these facetious verses of Gregory Oster becoming a true.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=309a2b53-e916-4eed-987d-6805a5c3642e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Babbling</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/06/02/Babbling.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0fe7949e-fe1b-4f57-90f3-29a936864449.aspx</id>
    <published>2009-06-01T23:50:38.667-07:00</published>
    <updated>2009-06-02T00:03:48.9308448-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've read a popular scientific stuff about DNA, RNA, proteins, cells, prokaryotes
and eukaryotes their structures, roles, operational principles, evolution.
</p>
        <p>
All the computer technologies and robotics seem like a childish babbling comparing
to microbiology and molecular biology.
</p>
        <p>
I would wish to be so open minded, and have so capable brain with infinite work capacity
(and live so long life <img alt=":-)" src="http://www.nesterovsky-bros.com/weblog/smilies/happy.gif" />)
to push, to break through the borders of knowledge of the humanity.
</p>
        <p>
Ah, I envy to the Renaissance people who were capble to hold and drive the science
and art, this contrasts so much with contemporary specializations.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0fe7949e-fe1b-4f57-90f3-29a936864449" />
      </div>
    </content>
  </entry>
  <entry>
    <title>jxom Update</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/05/28/jxomUpdate.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,51f7e6f4-6f0f-4f7d-ac01-dd6f88f7b63c.aspx</id>
    <published>2009-05-28T02:57:02.659-07:00</published>
    <updated>2009-05-28T03:35:36.3835392-07:00</updated>
    <category term="Announce" label="Announce" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,Announce.aspx" />
    <category term="xslt" label="xslt" scheme="http://www.nesterovsky-bros.com/weblog/CategoryView,category,xslt.aspx" />
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div 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" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A C++0x FAQ</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/05/26/AC0xFAQ.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,13862ed4-4423-44d4-9e00-52dba7bb5e8e.aspx</id>
    <published>2009-05-26T05:46:37.649-07:00</published>
    <updated>2009-05-26T05:48:35.3485504-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today, I've found <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=13862ed4-4423-44d4-9e00-52dba7bb5e8e&amp;url=http%3a%2f%2fwww.research.att.com%2f%7ebs%2fC%2b%2b0xFAQ.html">a
C++0x FAQ by Bjarne Stroustrup</a> reviewing most of the new features that we shall
see in the next version.
</p>
        <p>
A good insight for those who don't track the WG progress.
</p>
        <p>
But what attracts me is a passage:
</p>
        <div style="padding-left: 1em; font-style: italic">
          <p>
            <b>
              <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=13862ed4-4423-44d4-9e00-52dba7bb5e8e&amp;url=http%3a%2f%2fwww.research.att.com%2f%7ebs%2fC%2b%2b0xFAQ.html%23think">What
do you think of C++0x?</a>
            </b>
          </p>
          <p>
...My ideal is to use programming language facilities to ...
</p>
          <p>
In other words, I'm still an optimist.
</p>
        </div>
        <p>
Sounds rather pessimistic to my taste. <img alt=":-)" src="http://www.nesterovsky-bros.com/weblog/smilies/happy.gif" /></p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=13862ed4-4423-44d4-9e00-52dba7bb5e8e" />
      </div>
    </content>
  </entry>
  <entry>
    <title>ServiceLoader API in Java 5</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/05/16/ServiceLoaderAPIInJava5.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,4e040c53-e8be-4c9f-a9d2-6bb3b15ab0e4.aspx</id>
    <published>2009-05-16T02:30:51.892-07:00</published>
    <updated>2009-05-16T02:37:17.5025818-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
There is a nice <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=4e040c53-e8be-4c9f-a9d2-6bb3b15ab0e4&amp;url=http%3a%2f%2fjava.sun.com%2fjavase%2f6%2fdocs%2fapi%2fjava%2futil%2fServiceLoader.html"> ServiceLoader
API</a> in java 6 implementing a service provider idiom. It's good (good because
it's standard) class resolving interface implementation using META-INF/service
location.
</p>
        <p>
Unfortunately, there is even no JSR implementation for this class in java 5. This
makes it impossible for us to use it.
</p>
        <p>
What a nuisance!
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=4e040c53-e8be-4c9f-a9d2-6bb3b15ab0e4" />
      </div>
    </content>
  </entry>
  <entry>
    <title>In memory of our grandfathers</title>
    <link rel="alternate" type="text/html" href="http://www.nesterovsky-bros.com/weblog/2009/05/09/InMemoryOfOurGrandfathers.aspx" />
    <id>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,632df132-313e-44cb-b012-68f420dc4abf.aspx</id>
    <published>2009-05-09T02:06:54.187-07:00</published>
    <updated>2009-05-10T09:29:44.4400336-07:00</updated>
    <author>
      <name>Vladimir Nesterovsky</name>
    </author>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <table border="0">
          <tr>
            <td>
              <p>
We honour the memory of our grandfathers and grandmothers who battled that cruel war.
Our grandfather has fallen in that war, other grandfather and grandmothers have survived
and lived long lives.
</p>
              <p>
Time is relentless, they have left this world but we shall keep them and their deeds
in memory.
</p>
            </td>
            <td>
              <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=632df132-313e-44cb-b012-68f420dc4abf&amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fRibbon_of_Saint_George">
                <img src="http://www.nesterovsky-bros.com/images/Ribbon_of_Saint_George.png" alt="Георгиевская лента" border="0" />
              </a>
            </td>
          </tr>
        </table>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=632df132-313e-44cb-b012-68f420dc4abf" />
      </div>
    </content>
  </entry>
</feed>