<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Nesterovsky bros</title>
    <link>http://www.nesterovsky-bros.com/weblog/</link>
    <description />
    <language>en-us</language>
    <copyright>Nesterovsky bros</copyright>
    <lastBuildDate>Fri, 05 Sep 2008 15:39:50 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>contact@nesterovsky-bros.com</managingEditor>
    <webMaster>contact@nesterovsky-bros.com</webMaster>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=0141ac17-edb2-4d0e-9781-fb76568a7d70</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0141ac17-edb2-4d0e-9781-fb76568a7d70.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0141ac17-edb2-4d0e-9781-fb76568a7d70.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=0141ac17-edb2-4d0e-9781-fb76568a7d70</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We're facing a task of conversion of a java method into a state machine. This
is like to convert a SAX Parser, pushing data, into an Xml Reader, which pulls data. 
</p>
        <p>
The task is formalized as:
</p>
        <ul>
          <li>
for a given method containing split markers create a class perimitting iteration;</li>
          <li>
each iteration performs part of a logic of a method. 
</li>
        </ul>
        <p>
We have defined rules converting all statements into a state machine except of the
statement <b><code>synchronied</code></b>. In fact the logic it rather linear, however
the most untrivial conversion is for <b><code>try</code></b> statement. Consider
an example:
</p>
        <p style="padding-left: 1em">
          <code>
            <b>public</b>
            <b>class</b> Test<br />
{<br /><b>void</b> method()<br /><b>throws</b> Exception<br />
{<br /><b>try</b><br />
{<br />
A();<br />
B();<br />
}<br /><b>catch</b>(Exception e)<br />
{<br />
C(e);<br />
}<br /><b>finally</b><br />
{<br />
D();<br />
}<br /><br />
E();<br />
}<br /><br /><b>private</b> void A()<br /><b>throws</b> Exception<br />
{<br />
// logic A<br />
}<br /><br /><b>private</b> void B()<br /><b>throws</b> Exception<br />
{<br />
// logic B<br />
}<br /><br /><b>private</b><b>void</b> C(Exception e)<br /><b>throws</b> Exception<br />
{<br />
// logic C<br />
}<br /><br /><b>private</b><b>void</b> D()<br /><b>throws</b> Exception<br />
{<br />
// logic D<br />
}<br /><br /><b>private</b><b>void</b> E()<br /><b>throws</b> Exception<br />
{<br />
// logic E<br />
}<br />
}</code>
        </p>
        <p>
Suppose we want to see <code>method()</code> as a state machine in a way that split
markers are after calls to methods <code>A()</code>, <code>B()</code>, <code>C()</code>, <code>D()</code>, <code>E()</code>.
This is how it looks as a state machine:
</p>
        <p style="padding-left: 1em;">
          <code>Callable&lt;Boolean&gt; methodAsStateMachine()<br /><b>throws</b> Exception<br />
{<br /><b>return</b><b>new</b> Callable&lt;Boolean&gt;()<br />
{<br /><b>public</b> Boolean call()<br /><b>throws</b> Exception<br />
{<br /><b>do</b><br />
{<br /><b>try</b><br />
{<br /><b>switch</b>(state)<br />
{<br /><b>case</b> 0:<br />
{<br />
A();<br />
state = 1;<br /><br /><b>return</b><b>true</b>;<br />
}<br /><b>case</b> 1:<br />
{<br />
B();<br />
state = 3;<br /><br /><b>return</b><b>true</b>;<br />
}<br /><b>case</b> 2:<br />
{<br />
C(ex);<br />
state = 3;<br /><br /><b>return</b><b>true</b>;<br />
}<br /><b>case</b> 3:<br />
{<br />
D();<br /><br /><b>if</b> (currentException != <b>null</b>)<br />
{<br /><b>throw</b> currentException;<br />
}<br /><br />
state = 4;<br /><br /><b>return</b><b>true</b>;<br />
}<br /><b>case</b> 4:<br />
{<br />
E();<br />
state = -1;<br /><br /><b>return</b><b>false</b>;<br />
}<br />
}<br /><br /><b>if</b> (currentException == <b>null</b>)<br />
{<br />
currentException = <b>new</b> IllegalStateException();<br />
}<br />
}<br /><b>catch</b>(Throwable e)<br />
{<br />
currentException = <b>null</b>;<br /><br /><b>switch</b>(state)<br />
{<br /><b>case</b> 0:<br /><b>case</b> 1:<br />
{<br /><b>if</b> (e <b>instanceof</b> Exception)<br />
{<br />
ex = (Exception)e;<br />
state = 2;<br />
}<br /><b>else</b><br />
{<br />
currentException = e;<br />
state = 3;<br />
}<br /><br /><b>continue</b>;<br />
}<br /><b>case</b> 2:<br />
{<br />
currentException = e;<br />
state = 3;<br /><br /><b>continue</b>;<br />
}<br />
}<br /><br />
currentException = e;<br />
state = -1;<br />
}<br />
}<br /><b>while</b>(false);<br /><br /><b>return</b><b>this</b>.&lt;Exception&gt;error();<br />
}<br /><br />
@SuppressWarnings("unchecked")<br /><b>private</b> &lt;T <b>extends</b> Throwable&gt; <b>boolean</b> error()<br /><b>throws</b> T<br />
{<br /><b>throw</b> (T)currentException;<br />
}<br /><br /><b>private</b><b>int</b> state = 0;<br /><b>private</b> Throwable currentException = <b>null</b>;<br /><b>private</b> Exception ex = <b>null</b>;<br />
};<br />
}</code>
        </p>
        <p>
Believe it, or not but this transformation can be done purely in xslt 2.0 with the
help of the <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0141ac17-edb2-4d0e-9781-fb76568a7d70&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx">jxom
(Java xml object model)</a>. We shall update <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0141ac17-edb2-4d0e-9781-fb76568a7d70&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip">jxom.zip</a> whenever
this module will be implemented and tested.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0141ac17-edb2-4d0e-9781-fb76568a7d70" />
      </body>
      <title>What you can do with jxom</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,0141ac17-edb2-4d0e-9781-fb76568a7d70.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/09/05/WhatYouCanDoWithJxom.aspx</link>
      <pubDate>Fri, 05 Sep 2008 15:39:50 GMT</pubDate>
      <description>  &lt;p&gt;
We&amp;#39;re facing a task of conversion of a java method into a state machine. This
is like to convert a SAX Parser, pushing data, into an Xml Reader, which pulls data. 
&lt;/p&gt;
&lt;p&gt;
The task is formalized as:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
for a given method containing split markers create a class perimitting iteration;&lt;/li&gt;
&lt;li&gt;
each iteration performs part of a logic of a method. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
We have defined rules converting all statements into a state machine except of the
statement &lt;b&gt; &lt;code&gt;synchronied&lt;/code&gt;&lt;/b&gt;. In fact the logic it rather linear, however
the most untrivial conversion is for &lt;b&gt; &lt;code&gt;try&lt;/code&gt;&lt;/b&gt; statement. Consider
an example:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt;&lt;b&gt;public&lt;/b&gt; &lt;b&gt;class&lt;/b&gt; Test&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;void&lt;/b&gt; method()&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; Exception&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;try&lt;/b&gt;
&lt;br /&gt;
{&lt;br /&gt;
A();&lt;br /&gt;
B();&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;catch&lt;/b&gt;(Exception e)&lt;br /&gt;
{&lt;br /&gt;
C(e);&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;finally&lt;/b&gt;
&lt;br /&gt;
{&lt;br /&gt;
D();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
E();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; void A()&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; Exception&lt;br /&gt;
{&lt;br /&gt;
// logic A&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; void B()&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; Exception&lt;br /&gt;
{&lt;br /&gt;
// logic B&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; C(Exception e)&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; Exception&lt;br /&gt;
{&lt;br /&gt;
// logic C&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; D()&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; Exception&lt;br /&gt;
{&lt;br /&gt;
// logic D&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; E()&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; Exception&lt;br /&gt;
{&lt;br /&gt;
// logic E&lt;br /&gt;
}&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Suppose we want to see &lt;code&gt;method()&lt;/code&gt; as a state machine in a way that split
markers are after calls to methods &lt;code&gt;A()&lt;/code&gt;, &lt;code&gt;B()&lt;/code&gt;, &lt;code&gt;C()&lt;/code&gt;, &lt;code&gt;D()&lt;/code&gt;, &lt;code&gt;E()&lt;/code&gt;.
This is how it looks as a state machine:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;Callable&amp;lt;Boolean&amp;gt; methodAsStateMachine()&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; Exception&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;return&lt;/b&gt; &lt;b&gt;new&lt;/b&gt; Callable&amp;lt;Boolean&amp;gt;()&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;public&lt;/b&gt; Boolean call()&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; Exception&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;do&lt;/b&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;try&lt;/b&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;switch&lt;/b&gt;(state)&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;case&lt;/b&gt; 0:&lt;br /&gt;
{&lt;br /&gt;
A();&lt;br /&gt;
state = 1;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;return&lt;/b&gt; &lt;b&gt;true&lt;/b&gt;;&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;case&lt;/b&gt; 1:&lt;br /&gt;
{&lt;br /&gt;
B();&lt;br /&gt;
state = 3;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;return&lt;/b&gt; &lt;b&gt;true&lt;/b&gt;;&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;case&lt;/b&gt; 2:&lt;br /&gt;
{&lt;br /&gt;
C(ex);&lt;br /&gt;
state = 3;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;return&lt;/b&gt; &lt;b&gt;true&lt;/b&gt;;&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;case&lt;/b&gt; 3:&lt;br /&gt;
{&lt;br /&gt;
D();&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;if&lt;/b&gt; (currentException != &lt;b&gt;null&lt;/b&gt;)&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;throw&lt;/b&gt; currentException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
state = 4;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;return&lt;/b&gt; &lt;b&gt;true&lt;/b&gt;;&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;case&lt;/b&gt; 4:&lt;br /&gt;
{&lt;br /&gt;
E();&lt;br /&gt;
state = -1;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;return&lt;/b&gt; &lt;b&gt;false&lt;/b&gt;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;if&lt;/b&gt; (currentException == &lt;b&gt;null&lt;/b&gt;)&lt;br /&gt;
{&lt;br /&gt;
currentException = &lt;b&gt;new&lt;/b&gt; IllegalStateException();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;catch&lt;/b&gt;(Throwable e)&lt;br /&gt;
{&lt;br /&gt;
currentException = &lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;switch&lt;/b&gt;(state)&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;case&lt;/b&gt; 0:&lt;br /&gt;
&lt;b&gt;case&lt;/b&gt; 1:&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;if&lt;/b&gt; (e &lt;b&gt;instanceof&lt;/b&gt; Exception)&lt;br /&gt;
{&lt;br /&gt;
ex = (Exception)e;&lt;br /&gt;
state = 2;&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;else&lt;/b&gt;
&lt;br /&gt;
{&lt;br /&gt;
currentException = e;&lt;br /&gt;
state = 3;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;continue&lt;/b&gt;;&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;case&lt;/b&gt; 2:&lt;br /&gt;
{&lt;br /&gt;
currentException = e;&lt;br /&gt;
state = 3;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;continue&lt;/b&gt;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
currentException = e;&lt;br /&gt;
state = -1;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;while&lt;/b&gt;(false);&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;return&lt;/b&gt; &lt;b&gt;this&lt;/b&gt;.&amp;lt;Exception&amp;gt;error();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@SuppressWarnings("unchecked")&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; &amp;lt;T &lt;b&gt;extends&lt;/b&gt; Throwable&amp;gt; &lt;b&gt;boolean&lt;/b&gt; error()&lt;br /&gt;
&lt;b&gt;throws&lt;/b&gt; T&lt;br /&gt;
{&lt;br /&gt;
&lt;b&gt;throw&lt;/b&gt; (T)currentException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; &lt;b&gt;int&lt;/b&gt; state = 0;&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; Throwable currentException = &lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
&lt;b&gt;private&lt;/b&gt; Exception ex = &lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;
};&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Believe it, or not but this transformation can be done purely in xslt 2.0 with the
help of the &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0141ac17-edb2-4d0e-9781-fb76568a7d70&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx"&gt;jxom
(Java xml object model)&lt;/a&gt;. We shall update &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=0141ac17-edb2-4d0e-9781-fb76568a7d70&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip"&gt;jxom.zip&lt;/a&gt; whenever
this module will be implemented and tested.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=0141ac17-edb2-4d0e-9781-fb76568a7d70" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,0141ac17-edb2-4d0e-9781-fb76568a7d70.aspx</comments>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=afe516f6-a2f9-4b8c-9445-b1bdb1e5daab</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,afe516f6-a2f9-4b8c-9445-b1bdb1e5daab.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,afe516f6-a2f9-4b8c-9445-b1bdb1e5daab.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=afe516f6-a2f9-4b8c-9445-b1bdb1e5daab</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the xslt one can express logically the same things in different words like:
</p>
        <p>
        </p>
        <p>
          <code>  exists($x)</code>
          <br />
and<br /><code>  every $y in $x satisfies exists($y)</code></p>
        <p>
          <b>newbie&gt;</b> Really the same?<br /><b>expert&gt;</b> Ops... You're right, these are different things! 
</p>
        <p>
What's the difference?
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=afe516f6-a2f9-4b8c-9445-b1bdb1e5daab" />
      </body>
      <title>Xslt 2.0 casuistry</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,afe516f6-a2f9-4b8c-9445-b1bdb1e5daab.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/09/03/Xslt20Casuistry.aspx</link>
      <pubDate>Wed, 03 Sep 2008 12:34:06 GMT</pubDate>
      <description>&lt;p&gt;
In the xslt one can express logically the same things in different words like:&lt;p&gt;
&lt;p&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;exists($x)&lt;/code&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;every $y in $x satisfies exists($y)&lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;newbie&amp;gt;&lt;/b&gt; Really the same?&lt;br /&gt;
&lt;b&gt;expert&amp;gt;&lt;/b&gt; Ops... You're right, these are different things! 
&lt;/p&gt;
&lt;p&gt;
What's the difference?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=afe516f6-a2f9-4b8c-9445-b1bdb1e5daab" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,afe516f6-a2f9-4b8c-9445-b1bdb1e5daab.aspx</comments>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=3a3777a4-2e05-403c-b87a-dacaa6124f40</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,3a3777a4-2e05-403c-b87a-dacaa6124f40.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,3a3777a4-2e05-403c-b87a-dacaa6124f40.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=3a3777a4-2e05-403c-b87a-dacaa6124f40</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was already writing about tuples and maps in the xslt (see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=3a3777a4-2e05-403c-b87a-dacaa6124f40&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f07%2f10%2fTuplesAndMapsStatusCLOSEDWONTFIX.aspx"> Tuples
and maps - Status: CLOSED, WONTFIX</a>, and <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=3a3777a4-2e05-403c-b87a-dacaa6124f40&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f05%2f18%2fTuplesAndMapsInSaxon.aspx"> Tuples
and maps in Saxon</a>).
</p>
        <p>
Now, I want to argue on a use case, and on how xslt processor can detect such a use
case and implement it as map. This way, for a certain conditions, a sequences could
be treated as maps (or as sets).
</p>
        <p>
Use case.
</p>
        <p>
There are two stages:
</p>
        <ul>
          <li>
a logic collecting nodes/values satisfying some criteria.</li>
          <li>
process data, and take a special action whenever a node/value is collected on the
previous stage.</li>
        </ul>
        <p>
Whenever we're talking of nodes than result of the first stage is a sequence <code>$set
as node()*</code>. The role of this sequence is a set of nodes (order is not important).
</p>
        <p>
The second stage is usually an <code>xsl:for-each</code>, an <code>xsl:apply-templates</code>,
or something of this kind, which repeatedly verifies whether a some <code>$node as
node()?</code> belongs to the <code>$set</code>, like a following: <code>$node intersect
$set</code>, or <code>$node except $set</code>.
</p>
        <p>
In spite of that we're still using regular xpath 2.0, we have managed to express
a set based operation. It's a matter of xslt processor's optimizer to detect
such a use case and consider a sequence as a set. In fact the detection rule is rather
simple. 
</p>
        <div style="padding-left: 1em">
          <div>
For expressions <code>$node except $set</code> and <code>$node intersect $set</code>:
</div>
          <ul>
            <li>
              <code>$set</code> can be considered as a set, as order of elements is not important;</li>
            <li>
chances are good that a <code>$set</code> being implemented as a set outperforms implementation
using a list or an array.</li>
          </ul>
        </div>
        <p>
Thus what to do? Well, I do not think I'm the smartest child, quite opposite...
however it worth to hint this idea to xslt implementers (see <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=3a3777a4-2e05-403c-b87a-dacaa6124f40&amp;url=http%3a%2f%2fsourceforge.net%2fforum%2fforum.php%3fthread_id%3d2183484%26forum_id%3d94026"> Suggest
optimization</a>). I still do not know if it was fruitful...
</p>
        <p>
P.S. A very similar use case exists for a function index-of($collection, $item). 
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=3a3777a4-2e05-403c-b87a-dacaa6124f40" />
      </body>
      <title>Tuples and maps - next try</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,3a3777a4-2e05-403c-b87a-dacaa6124f40.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/08/30/TuplesAndMapsNextTry.aspx</link>
      <pubDate>Sat, 30 Aug 2008 07:44:44 GMT</pubDate>
      <description>  &lt;p&gt;
I was already writing about tuples and maps in the xslt (see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=3a3777a4-2e05-403c-b87a-dacaa6124f40&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f07%2f10%2fTuplesAndMapsStatusCLOSEDWONTFIX.aspx"&gt; Tuples
and maps - Status: CLOSED, WONTFIX&lt;/a&gt;, and &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=3a3777a4-2e05-403c-b87a-dacaa6124f40&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f05%2f18%2fTuplesAndMapsInSaxon.aspx"&gt; Tuples
and maps in Saxon&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
Now, I want to argue on a use case, and on how xslt processor can detect such a use
case and implement it as map. This way, for a certain conditions, a sequences could
be treated as maps (or as sets).
&lt;/p&gt;
&lt;p&gt;
Use case.
&lt;/p&gt;
&lt;p&gt;
There are two stages:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
a logic collecting nodes/values satisfying some criteria.&lt;/li&gt;
&lt;li&gt;
process data, and take a special action whenever a node/value is collected on the
previous stage.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Whenever we&amp;#39;re talking of nodes than result of the first stage is a sequence &lt;code&gt;$set
as node()*&lt;/code&gt;. The role of this sequence is a set of nodes (order is not important).
&lt;/p&gt;
&lt;p&gt;
The second stage is usually an &lt;code&gt;xsl:for-each&lt;/code&gt;, an &lt;code&gt;xsl:apply-templates&lt;/code&gt;,
or something of this kind, which repeatedly verifies whether a some &lt;code&gt;$node as
node()?&lt;/code&gt; belongs to the &lt;code&gt;$set&lt;/code&gt;, like a following: &lt;code&gt;$node intersect
$set&lt;/code&gt;, or &lt;code&gt;$node except $set&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
In spite of that we&amp;#39;re still using regular xpath 2.0, we have managed to express
a set based operation. It&amp;#39;s a matter of xslt processor&amp;#39;s optimizer to detect
such a use case and consider a sequence as a set. In fact the detection rule is rather
simple. 
&lt;/p&gt;
&lt;div style="padding-left: 1em"&gt;
&lt;div&gt;
For expressions &lt;code&gt;$node except $set&lt;/code&gt; and &lt;code&gt;$node intersect $set&lt;/code&gt;:
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;$set&lt;/code&gt; can be considered as a set, as order of elements is not important;&lt;/li&gt;
&lt;li&gt;
chances are good that a &lt;code&gt;$set&lt;/code&gt; being implemented as a set outperforms implementation
using a list or an array.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;
Thus what to do? Well, I do not think I&amp;#39;m the smartest child, quite opposite...
however it worth to hint this idea to xslt implementers (see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=3a3777a4-2e05-403c-b87a-dacaa6124f40&amp;amp;url=http%3a%2f%2fsourceforge.net%2fforum%2fforum.php%3fthread_id%3d2183484%26forum_id%3d94026"&gt; Suggest
optimization&lt;/a&gt;). I still do not know if it was fruitful...
&lt;/p&gt;
&lt;p&gt;
P.S. A very similar use case exists for a function index-of($collection, $item). 
&lt;/p&gt;
&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=3a3777a4-2e05-403c-b87a-dacaa6124f40" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,3a3777a4-2e05-403c-b87a-dacaa6124f40.aspx</comments>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I know we're not the first who create a parser in xslt. However I still want to share
our implementation, as I think it's beautiful. 
</p>
        <p>
In our project, which is conversion from a some legacy language to java, we're
dealing with dynamic expressions. For example in the legacy language one can filter
a collection using an expression defined by a string: <code>collection.filter("a
&gt; 0 and b = 7");</code></p>
        <p>
Whenever expression string is calculated there is nothing to do except to parse such
string at runtime and perform filtering dynamically. On the other hand we have found
that in the majority of cases literal strings are used. Thus we have decided to optimize
this route like this:
</p>
        <p style="padding-left: 1em;">
          <code>  collection.filter(<br />
    new Filter&lt;T&gt;()<br />
    {<br />
      boolean filter(T value)<br />
      {<br />
        return (value.getA() &gt; 0) and (value.getB()
= 7);<br />
      }<br />
    });</code>
        </p>
        <p>
This means that we're converting that expression string into java code on the
generation stage.
</p>
        <p>
In the xslt - our generator engine - this means that we have to convert a string into
expression tree like this:
</p>
        <p style="padding-left: 1em;">
          <code>(a &gt; 7 or a= 3) and c * d = 2.2</code>
        </p>
        <p>
to
</p>
        <p style="padding-left: 1em;">
          <code> &lt;and&gt;<br />
  &lt;or&gt;<br />
    &lt;gt&gt;<br />
      &lt;identifier&gt;a&lt;/identifier&gt;<br />
      &lt;integer&gt;7&lt;/integer&gt;<br />
    &lt;/gt&gt;<br />
    &lt;eq&gt;<br />
      &lt;identifier&gt;a&lt;/identifier&gt;<br />
      &lt;integer&gt;3&lt;/integer&gt;<br />
    &lt;/eq&gt;<br />
  &lt;/or&gt;<br />
  &lt;eq&gt;<br />
    &lt;mul&gt;<br />
      &lt;identifier&gt;c&lt;/identifier&gt;<br />
      &lt;identifier&gt;d&lt;/identifier&gt;<br />
    &lt;/mul&gt;<br />
    &lt;decimal&gt;2.2&lt;/decimal&gt;<br />
  &lt;/eq&gt;<br />
&lt;/and&gt;</code>
        </p>
        <p style="padding-left: 1em">
Our parser fits naturally to the world of parsers: it uses <code>xsl:analyze-string</code> instruction
to tokenize input and parses tokens according to an expression grammar. During implementation
I've found some new to me things. I think they worth mentioning:
</p>
        <ul>
          <li>
            <div>
As tokenizer is defined as a big regular expression, we have rather verbose <code>regex</code> attribute
over <code>xsl:analyze-string</code>. It was hard to edit such a big line until I've
found there is <code>flag="x"</code> option that solves formatting problems:<br /><p style="padding-left: 1em; font-style: italic">
The flags attribute may be used to control the interpretation of the regular expression...
If it contains the letter x, then whitespace within the regular expression is ignored.
</p>
This means that I can use spaces to format regular expression and <code>/s</code> to
specify space as part of expression. 
</div>
          </li>
          <li>
Saxon 9.1.0.1 has inefficiency in implementation of <code>xsl:analyze-string</code> instruction,
whenever regex contains literal value however with '{' character (e.g. "\p{{L}}"),
as it considers the value to be an AVT and delays pattern compilation until runtime,
which it does every time instruction is executed.</li>
        </ul>
        <p>
Use following link to see the xslt: <a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fxslt%2fexpression-parser.xslt">expression-parser.xslt</a>.<br />
To see how to generate java from an xml follow this link: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx"> Xslt
for the jxom (Java xml object model)</a>, <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip">jxom.zip</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd" />
      </body>
      <title>Expression parser in the xslt.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/08/12/ExpressionParserInTheXslt.aspx</link>
      <pubDate>Tue, 12 Aug 2008 14:45:54 GMT</pubDate>
      <description>  &lt;p&gt;
I know we're not the first who create a parser in xslt. However I still want to share
our implementation, as I think it's beautiful. 
&lt;/p&gt;
&lt;p&gt;
In our project, which is conversion from a some legacy language to java, we&amp;#39;re
dealing with dynamic expressions. For example in the legacy language one can filter
a collection using an expression defined by a string: &lt;code&gt;collection.filter(&amp;quot;a
&amp;gt; 0 and b = 7&amp;quot;);&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Whenever expression string is calculated there is nothing to do except to parse such
string at runtime and perform filtering dynamically. On the other hand we have found
that in the majority of cases literal strings are used. Thus we have decided to optimize
this route like this:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;&amp;nbsp; collection.filter(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; new Filter&amp;lt;T&amp;gt;()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;boolean filter(T value)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; return (value.getA() &amp;gt; 0) and (value.getB()
= 7);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
This means that we&amp;#39;re converting that expression string into java code on the
generation stage.
&lt;/p&gt;
&lt;p&gt;
In the xslt - our generator engine - this means that we have to convert a string into
expression tree like this:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;(a &amp;gt; 7 or a= 3) and c * d = 2.2&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
to
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt; &amp;lt;and&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;or&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;gt&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;identifier&amp;gt;a&amp;lt;/identifier&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;integer&amp;gt;7&amp;lt;/integer&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/gt&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;eq&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;identifier&amp;gt;a&amp;lt;/identifier&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;integer&amp;gt;3&amp;lt;/integer&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/eq&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/or&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;eq&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mul&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;identifier&amp;gt;c&amp;lt;/identifier&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;identifier&amp;gt;d&amp;lt;/identifier&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/mul&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;decimal&amp;gt;2.2&amp;lt;/decimal&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/eq&amp;gt;&lt;br /&gt;
&amp;lt;/and&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
Our parser fits naturally to the world of parsers: it uses &lt;code&gt;xsl:analyze-string&lt;/code&gt; instruction
to tokenize input and parses tokens according to an expression grammar. During implementation
I&amp;#39;ve found some new to me things. I think they worth mentioning:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;
As tokenizer is defined as a big regular expression, we have rather verbose &lt;code&gt;regex&lt;/code&gt; attribute
over &lt;code&gt;xsl:analyze-string&lt;/code&gt;. It was hard to edit such a big line until I&amp;#39;ve
found there is &lt;code&gt;flag=&amp;quot;x&amp;quot;&lt;/code&gt; option that solves formatting problems:&lt;br /&gt;
&lt;p style="padding-left: 1em; font-style: italic"&gt;
The flags attribute may be used to control the interpretation of the regular expression...
If it contains the letter x, then whitespace within the regular expression is ignored.
&lt;/p&gt;
This means that I can use spaces to format regular expression and &lt;code&gt;/s&lt;/code&gt; to
specify space as part of expression. 
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
Saxon 9.1.0.1 has inefficiency in implementation of &lt;code&gt;xsl:analyze-string&lt;/code&gt; instruction,
whenever regex contains literal value however with &amp;#39;{&amp;#39; character (e.g. &amp;quot;\p{{L}}&amp;quot;),
as it considers the value to be an AVT and delays pattern compilation until runtime,
which it does every time instruction is executed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Use following link to see the xslt: &lt;a target="_blank" href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fxslt%2fexpression-parser.xslt"&gt;expression-parser.xslt&lt;/a&gt;.&lt;br /&gt;
To see how to generate java from an xml follow this link: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx"&gt; Xslt
for the jxom (Java xml object model)&lt;/a&gt;, &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip"&gt;jxom.zip&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,2d6b3a53-aa1b-421f-b0c9-26e7ac535ffd.aspx</comments>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=b7f6d884-fe84-4382-815f-15e02faff179</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,b7f6d884-fe84-4382-815f-15e02faff179.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,b7f6d884-fe84-4382-815f-15e02faff179.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=b7f6d884-fe84-4382-815f-15e02faff179</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Yesterday, incidentally, I've arrived to a problem of a dynamic error during evaluation
of a template's match. This reminded me <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fSubstitution_failure_is_not_an_error" rel="nofollow" target="_blank"> SFINAE</a> in
C++. There the principle is applied at compile time to find a matching template.
</p>
        <p>
I think people underestimate the meaning of this behaviour. The effect of dynamic
errors occurring during pattern evaluation is described in the <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;url=http%3a%2f%2fwww.w3.org%2fTR%2fxslt20%2f%23pattern-errors" rel="nofollow" target="_blank">specification</a>:
</p>
        <p style="padding-left: 1em; font-style: italic">
Any dynamic error or type error that occurs during the evaluation of a pattern against
a particular node is treated as a recoverable error even if the error would not be
recoverable under other circumstances. The optional recovery action is to treat the
pattern as not matching that node.
</p>
        <p>
This has far reaching consequences, like an error recovery. To illustrate what I'm
talking about please look at this simple stylesheet that recovers from "Division by
zero.":
</p>
        <p style="padding-left: 1em; font-family: monospace">
&lt;xsl:stylesheet version="2.0"<br />
  xmlns:xsl="<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;url=http%3a%2f%2fwww.w3.org%2f1999%2fXSL%2fTransform">http://www.w3.org/1999/XSL/Transform</a>"<br />
  xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;<br /><br />
&lt;xsl:template match="/"&gt;<br />
  &lt;xsl:variable name="operator" as="element()+"&gt;<br />
    &lt;div divident="10" divisor="0"/&gt;<br />
    &lt;div divident="10" divisor="2"/&gt;<br />
  &lt;/xsl:variable&gt;<br /><br />
  &lt;xsl:apply-templates select="$operator"/&gt;<br />
&lt;/xsl:template&gt;<br /><br />
&lt;xsl:param name="NaN" as="xs:double" select="1.0 div 0"/&gt;<br /><br />
&lt;xsl:template<br />
  match="div[(xs:integer(@divident) div xs:integer(@divisor)) ne $NaN]"&gt;<br />
  &lt;xsl:message select="xs:integer(@divident) div xs:integer(@divisor)"/&gt;<br />
&lt;/xsl:template&gt;<br /><br />
&lt;xsl:template match="div"&gt;<br />
  &lt;xsl:message select="'Division by zero.'"/&gt;<br />
&lt;/xsl:template&gt;<br /><br />
&lt;/xsl:stylesheet&gt; 
</p>
        <p>
Here, if there is a division by zero a template is not matched and other template
is selected, thus second template serves as an error handler for the first one. Definitely,
one may define much more complex construction to be handled this way.
</p>
        <p>
I never was a purist (meaning doing everything in xslt), however this example along
with <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f18%2fIndirectFunctionCallInXslt20.aspx"> indirect
function call</a>, shows that xslt is rather equiped language. One just need to be
smart enough to understand how to do a things.
</p>
        <p>
See also: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f06%2f26%2fTrycatchBlockInXslt20ForSaxon9.aspx">Try/catch
block in xslt 2.0 for Saxon 9</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179" />
      </body>
      <title>SFINAE in xslt? - or native exception handling.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,b7f6d884-fe84-4382-815f-15e02faff179.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/07/31/SFINAEInXsltOrNativeExceptionHandling.aspx</link>
      <pubDate>Thu, 31 Jul 2008 11:52:21 GMT</pubDate>
      <description>  &lt;p&gt;
Yesterday, incidentally, I've arrived to a problem of a dynamic error during evaluation
of a template's match. This reminded me &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fSubstitution_failure_is_not_an_error" rel="nofollow" target="_blank"&gt; SFINAE&lt;/a&gt; in
C++. There the principle is applied at compile time to find a matching template.
&lt;/p&gt;
&lt;p&gt;
I think people underestimate the meaning of this behaviour. The effect of dynamic
errors occurring during pattern evaluation is described in the &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;amp;url=http%3a%2f%2fwww.w3.org%2fTR%2fxslt20%2f%23pattern-errors" rel="nofollow" target="_blank"&gt;specification&lt;/a&gt;:
&lt;/p&gt;
&lt;p style="padding-left: 1em; font-style: italic"&gt;
Any dynamic error or type error that occurs during the evaluation of a pattern against
a particular node is treated as a recoverable error even if the error would not be
recoverable under other circumstances. The optional recovery action is to treat the
pattern as not matching that node.
&lt;/p&gt;
&lt;p&gt;
This has far reaching consequences, like an error recovery. To illustrate what I'm
talking about please look at this simple stylesheet that recovers from "Division by
zero.":
&lt;/p&gt;
&lt;p style="padding-left: 1em; font-family: monospace"&gt;
&amp;lt;xsl:stylesheet version="2.0"&lt;br /&gt;
&amp;nbsp; xmlns:xsl="&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;amp;url=http%3a%2f%2fwww.w3.org%2f1999%2fXSL%2fTransform"&gt;http://www.w3.org/1999/XSL/Transform&lt;/a&gt;"&lt;br /&gt;
&amp;nbsp; xmlns:xs="http://www.w3.org/2001/XMLSchema"&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template match="/"&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:variable name="operator" as="element()+"&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div divident="10" divisor="0"/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div divident="10" divisor="2"/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:apply-templates select="$operator"/&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:param name="NaN" as="xs:double" select="1.0 div 0"/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template&lt;br /&gt;
&amp;nbsp; match="div[(xs:integer(@divident) div xs:integer(@divisor)) ne $NaN]"&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:message select="xs:integer(@divident) div xs:integer(@divisor)"/&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template match="div"&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:message select="'Division by zero.'"/&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt; 
&lt;/p&gt;
&lt;p&gt;
Here, if there is a division by zero a template is not matched and other template
is selected, thus second template serves as an error handler for the first one. Definitely,
one may define much more complex construction to be handled this way.
&lt;/p&gt;
&lt;p&gt;
I never was a purist (meaning doing everything in xslt), however this example along
with &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f18%2fIndirectFunctionCallInXslt20.aspx"&gt; indirect
function call&lt;/a&gt;, shows that xslt is rather equiped language. One just need to be
smart enough to understand how to do a things.
&lt;/p&gt;
&lt;p&gt;
See also: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f06%2f26%2fTrycatchBlockInXslt20ForSaxon9.aspx"&gt;Try/catch
block in xslt 2.0 for Saxon 9&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=b7f6d884-fe84-4382-815f-15e02faff179" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,b7f6d884-fe84-4382-815f-15e02faff179.aspx</comments>
      <category>Tips and tricks</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=5dfdbafd-389e-4004-93fe-d50858c7009e</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,5dfdbafd-389e-4004-93fe-d50858c7009e.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,5dfdbafd-389e-4004-93fe-d50858c7009e.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=5dfdbafd-389e-4004-93fe-d50858c7009e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Among other job activities, we're from time to time asked to check technical skills
of job applicants.
</p>
        <p>
Several times we were interviewing people who're far below the acceptable professional
skills. It's a torment for both sides, I should say.
</p>
        <p>
To ease things we have designed a small questionnaire (specific to our projects) for
job applicants. It's sent to an applicant before the meeting. Even partially answered,
this questionnaire constitutes a good filter against profanes: 
</p>
        <p style="padding-left: 1em; font-family: monospace">
&lt;questionnaire&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Please estimate your knowledge in XML Schema (xsd)
as lacking, bad, good, or perfect.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Please estimate your knowledge in xslt 2.0/xquery 1.0
as lacking, bad, good, or perfect.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Please estimate your knowledge in xslt 1.0 as lacking,
bad, good, or perfect.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Please estimate your knowledge in java as lacking,
bad, good, or perfect.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Please estimate your knowledge in c# as lacking, bad,
good, or perfect.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Please estimate your knowledge in sql as lacking, bad,
good, or perfect.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      For logical values A, B, please rewrite logical expression
"A and B" using operator "or".<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      For logical values A, B, please rewrite logical expression
"A = B" using operators "and" and "or".<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      There are eight balls, with only one heavier than some
other.<br />
      What is a minimum number of weighings reveals the heavier
ball?<br />
      Please be suspicious about the "trivial"
solution.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      If A results in B. What one may say about the reason
of B?<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      If only A or B result in C. What one may say about
the reason of C?<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Please define an xml schema for this questionnaire.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Please create a simple stylesheet creating an html
table based on this questionnaire.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      For a table A with columns B, C, and D, please create
an sql query selecting B groupped by C and ordered by D.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      For a sequence of xml elements A with attribute B,
please write a stylesheet excerpt creating a sequence of elements D, grouping elements
A with the same string value of attribute B, sorted in the order of ascending of B.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Having a java class A with properties B and C, please
sort a collection of A for B in ascending, and C in descending order.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      What does a following line mean in c#?<br />
      int? x;<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      What is a parser?<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      How to issue an error in the xml stylesheet?<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      What is a lazy evaluation?<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      How do you understand a following sentence?<br />
      For each line of code there should be a comment.<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Have you used any supplemental information to answer
these questions?<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
  &lt;item&gt;<br />
    &lt;question&gt;<br />
      Have you independently answered these questions?<br />
    &lt;/question&gt;<br />
    &lt;answer/&gt;<br />
  &lt;/item&gt;<br />
&lt;/questionnaire&gt; 
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=5dfdbafd-389e-4004-93fe-d50858c7009e" />
      </body>
      <title>On the job applicants...</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,5dfdbafd-389e-4004-93fe-d50858c7009e.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/07/28/OnTheJobApplicants.aspx</link>
      <pubDate>Mon, 28 Jul 2008 10:54:54 GMT</pubDate>
      <description>&lt;p&gt;
Among other job activities, we're from time to time asked to check technical skills
of job applicants.
&lt;/p&gt;
&lt;p&gt;
Several times we were interviewing people who're far below the acceptable professional
skills. It&amp;#39;s a torment for both sides, I should say.
&lt;/p&gt;
&lt;p&gt;
To ease things we have designed a small questionnaire (specific to our projects) for
job applicants. It&amp;#39;s sent to an applicant before the meeting. Even partially answered,
this questionnaire constitutes a good filter against profanes: 
&lt;/p&gt;
&lt;p style="padding-left: 1em; font-family: monospace"&gt;
&amp;lt;questionnaire&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please estimate your knowledge in XML Schema (xsd)
as lacking, bad, good, or perfect.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please estimate your knowledge in xslt 2.0/xquery 1.0
as lacking, bad, good, or perfect.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please estimate your knowledge in xslt 1.0 as lacking,
bad, good, or perfect.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please estimate your knowledge in java as lacking,
bad, good, or perfect.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please estimate your knowledge in c# as lacking, bad,
good, or perfect.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please estimate your knowledge in sql as lacking, bad,
good, or perfect.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For logical values A, B, please rewrite logical expression
&amp;quot;A and B&amp;quot; using operator &amp;quot;or&amp;quot;.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For logical values A, B, please rewrite logical expression
&amp;quot;A = B&amp;quot; using operators &amp;quot;and&amp;quot; and &amp;quot;or&amp;quot;.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; There are eight balls, with only one heavier than some
other.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; What is a minimum number of weighings reveals the heavier
ball?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please be suspicious about the &amp;quot;trivial&amp;quot;
solution.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If A results in B. What one may say about the reason
of B?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If only A or B result in C. What one may say about
the reason of C?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please define an xml schema for this questionnaire.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please create a simple stylesheet creating an html
table based on this questionnaire.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For a table A with columns B, C, and D, please create
an sql query selecting B groupped by C and ordered by D.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For a sequence of xml elements A with attribute B,
please write a stylesheet excerpt creating a sequence of elements D, grouping elements
A with the same string value of attribute B, sorted in the order of ascending of B.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Having a java class A with properties B and C, please
sort a collection of A for B in ascending, and C in descending order.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; What does a following line mean in c#?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int? x;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; What is a parser?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; How to issue an error in the xml stylesheet?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; What is a lazy evaluation?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; How do you understand a following sentence?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For each line of code there should be a comment.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Have you used any supplemental information to answer
these questions?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Have you independently answered these questions?&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/question&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;answer/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;/questionnaire&amp;gt; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=5dfdbafd-389e-4004-93fe-d50858c7009e" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,5dfdbafd-389e-4004-93fe-d50858c7009e.aspx</comments>
      <category>Tips and tricks</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=34355851-2d73-446b-86f0-f5abca96914e</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,34355851-2d73-446b-86f0-f5abca96914e.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,34355851-2d73-446b-86f0-f5abca96914e.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=34355851-2d73-446b-86f0-f5abca96914e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've found that proposition to introduce <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=34355851-2d73-446b-86f0-f5abca96914e&amp;url=http%3a%2f%2fwww.w3.org%2fBugs%2fPublic%2fshow_bug.cgi%3fid%3d5630" rel="nofollow">tuples
and maps</a> to xslt/xquery type system has not found a support: 
</p>
        <p style="font-style: italic; padding-left: 1em">
At the joint meeting of the XSL and XQuery Working groups 2008-06-23 it was decided
that a change of this nature would be too large for the next "point" release of the
Recommendations. The request for new functionality will be considered for a future
"main" release. 
</p>
        <p>
          <b>Boor&gt;</b> *****!
</p>
        <p>
          <b>Pessimist&gt;</b> Ah, there won't be tuples and maps in xslt/xquery...
</p>
        <p>
          <b>Optimist&gt;</b> Wow, chances are good to see this addition by the year 2018!
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=34355851-2d73-446b-86f0-f5abca96914e" />
      </body>
      <title>Tuples and maps - Status: CLOSED, WONTFIX</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,34355851-2d73-446b-86f0-f5abca96914e.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/07/10/TuplesAndMapsStatusCLOSEDWONTFIX.aspx</link>
      <pubDate>Thu, 10 Jul 2008 05:54:52 GMT</pubDate>
      <description>&lt;p&gt;
I've found that proposition to introduce &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=34355851-2d73-446b-86f0-f5abca96914e&amp;amp;url=http%3a%2f%2fwww.w3.org%2fBugs%2fPublic%2fshow_bug.cgi%3fid%3d5630" rel="nofollow"&gt;tuples
and maps&lt;/a&gt; to xslt/xquery type system has not found a support: 
&lt;/p&gt;
&lt;p style="font-style: italic; padding-left: 1em"&gt;
At the joint meeting of the XSL and XQuery Working groups 2008-06-23 it was decided
that a change of this nature would be too large for the next "point" release of the
Recommendations. The request for new functionality will be considered for a future
"main" release. 
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Boor&amp;gt;&lt;/b&gt; *****!
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Pessimist&amp;gt;&lt;/b&gt; Ah, there won't be tuples and maps in xslt/xquery...
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Optimist&amp;gt;&lt;/b&gt; Wow, chances are good to see this addition by the year 2018!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=34355851-2d73-446b-86f0-f5abca96914e" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,34355851-2d73-446b-86f0-f5abca96914e.aspx</comments>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=2f439579-df72-4ea1-9ae7-e127cff9375b</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,2f439579-df72-4ea1-9ae7-e127cff9375b.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,2f439579-df72-4ea1-9ae7-e127cff9375b.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=2f439579-df72-4ea1-9ae7-e127cff9375b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today Michael Kay has announced an update for the Saxon processor. The latest version
for now is 9.1. 
</p>
        <p>
I've checked our <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip">saxon.extensions</a>,
and has fixed incompatibilities.
</p>
        <p>
The source for the new version of the Saxon can be found at <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b&amp;url=http%3a%2f%2fsaxon.sourceforge.net%2f">http://saxon.sourceforge.net/</a>.
</p>
        <p>
New features are discussed at: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b&amp;url=http%3a%2f%2fwww.saxonica.com%2fdocumentation%2fchanges%2fintro.html">http://www.saxonica.com/documentation/changes/intro.html</a></p>
        <p>
Our extensions can be found at <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip">saxon.extensions.9.1.zip</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b" />
      </body>
      <title>Update Saxon extensions to reflect v9.1</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,2f439579-df72-4ea1-9ae7-e127cff9375b.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/07/03/UpdateSaxonExtensionsToReflectV91.aspx</link>
      <pubDate>Thu, 03 Jul 2008 13:47:13 GMT</pubDate>
      <description>&lt;p&gt;
Today Michael Kay has announced an update for the Saxon processor. The latest version
for now is 9.1. 
&lt;/p&gt;
&lt;p&gt;
I've checked our &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip"&gt;saxon.extensions&lt;/a&gt;,
and has fixed incompatibilities.
&lt;/p&gt;
&lt;p&gt;
The source for the new version of the Saxon can be found at &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b&amp;amp;url=http%3a%2f%2fsaxon.sourceforge.net%2f"&gt;http://saxon.sourceforge.net/&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
New features are discussed at: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b&amp;amp;url=http%3a%2f%2fwww.saxonica.com%2fdocumentation%2fchanges%2fintro.html"&gt;http://www.saxonica.com/documentation/changes/intro.html&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Our extensions can be found at &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip"&gt;saxon.extensions.9.1.zip&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=2f439579-df72-4ea1-9ae7-e127cff9375b" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,2f439579-df72-4ea1-9ae7-e127cff9375b.aspx</comments>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=e394e0b8-d3c2-4261-aba9-c70ed03dea1d</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,e394e0b8-d3c2-4261-aba9-c70ed03dea1d.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,e394e0b8-d3c2-4261-aba9-c70ed03dea1d.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=e394e0b8-d3c2-4261-aba9-c70ed03dea1d</wfw:commentRss>
      <title>Try/catch block in xslt 2.0 for Saxon 9.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,e394e0b8-d3c2-4261-aba9-c70ed03dea1d.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/06/26/TrycatchBlockInXslt20ForSaxon9.aspx</link>
      <pubDate>Thu, 26 Jun 2008 09:18:50 GMT</pubDate>
      <description>  &lt;p&gt;
We are designing a rather complex xslt 2.0 application, dealing with semistructured
data. We must tolerate with errors during processing, as there are cases where an
input is not perfectly valid (or the program is not designed or ready to get such
an input).
&lt;/p&gt;
&lt;p&gt;
The most typical error is unsatisfied expectation of tree structure like:&lt;br /&gt;
&amp;nbsp; &lt;code&gt;&amp;lt;xsl:variable name=&amp;quot;element&amp;quot; as=&amp;quot;element()&amp;quot; select=&amp;quot;some-element&amp;quot;/&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Obviously, dynamic error occurs if a specified element is not present. To concentrate
on primary logic, and to avoid a burden of illegal (unexpected) case recovery we have
created a try/catch API. The goal of such API is:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
to be able to continue processing in case of error;&lt;/li&gt;
&lt;li&gt;
report as much as possible useful information related to an error.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Alternatives:
&lt;/p&gt;
&lt;p&gt;
Do not think this is our arrogance, which has turned us to create a custom API. No,
we were looking for alternatives! Please see &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fbiglist.com%2flists%2fxsl-list%2farchives%2f200801%2fthreads.html%2300055"&gt;[xsl]
saxon:try()&lt;/a&gt; discussion:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fwww.saxonica.com%2fdocumentation%2fextensions%2ffunctions%2ftry.html"&gt;saxon:try()&lt;/a&gt; function
- is a kind of pseudo function, which explicitly relies on lazy evaluation of its
arguments, and ... it&amp;#39;s not available in SaxonB;&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fwww.fgeorges.org%2fxslt%2ferror-safe%2f"&gt;ex:error-safe&lt;/a&gt;&amp;nbsp;
extension instruction - is far from perfect in its implementation quality, and provides
no error location.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
We have no other way except to design this feature by ourselves. In our defence one
can say that we are using innovatory approach that encapsulates details of the implementation
behind template and calls handlers indirectly.
&lt;/p&gt;
&lt;p&gt;
Use:
&lt;/p&gt;
&lt;p&gt;
Try/catch API is designed as a template &lt;code&gt; &amp;lt;xsl:template name=&amp;quot;t:try-block&amp;quot;/&amp;gt&lt;/code&gt; calling
a &amp;quot;try&amp;quot; handler, and, if required, a &amp;quot;catch&amp;quot; hanler using &lt;code&gt; &amp;lt;xsl:apply-templates
mode=&amp;quot;t:call&amp;quot;/&amp;gt;&lt;/code&gt; instruction. Caller passes any information to
these handlers by the means of tunnel parameters.
&lt;/p&gt;
&lt;p&gt;
Handlers must be in a &amp;quot;&lt;code&gt;t:call&lt;/code&gt;&amp;quot; mode. The &amp;quot;catch&amp;quot;
handler may recieve following error info parameters:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;&amp;lt;xsl:param name=&amp;quot;error&amp;quot; as=&amp;quot;xs:QName&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;xsl:param name=&amp;quot;error-description&amp;quot; as=&amp;quot;xs:string&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;xsl:param name=&amp;quot;error-location&amp;quot; as=&amp;quot;item()*&amp;quot;/&amp;gt; &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
where &lt;code&gt;$error-location&lt;/code&gt; is a sequence of pairs &lt;code&gt;(location as xs:string,
context as item())*&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
A sample:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt; &amp;lt;xsl:stylesheet version=&amp;quot;2.0&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:t=&amp;quot;http://www.nesterovsky-bros.com/xslt/public/&amp;quot;&lt;br /&gt;
&amp;nbsp; exclude-result-prefixes=&amp;quot;xs t&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:include href=&amp;quot;try-block.xslt&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;result&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:for-each select=&amp;quot;1 to 10&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:call-template name=&amp;quot;t:try-block&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:with-param name=&amp;quot;value&amp;quot;
tunnel=&amp;quot;yes&amp;quot; select=&amp;quot;. - 5&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:with-param name=&amp;quot;try&amp;quot;
as=&amp;quot;element()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;try/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:with-param&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:with-param name=&amp;quot;catch&amp;quot;
as=&amp;quot;element()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;t:error-handler/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:with-param&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:call-template&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/result&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template mode=&amp;quot;t:call&amp;quot; match=&amp;quot;try&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;xsl:param name=&amp;quot;value&amp;quot; tunnel=&amp;quot;yes&amp;quot; as=&amp;quot;xs:decimal&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;value&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;1 div $value&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/value&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
The sample prints values according to the formula &amp;quot;1/(i - 5)&amp;quot;, where &amp;quot;i&amp;quot;
is a variable varying from 1 to 10. Clearly, division by zero occurs when &amp;quot;i&amp;quot;
is equal to 5.
&lt;/p&gt;
&lt;p&gt;
Please notice how to access try/catch API through &lt;code&gt; &amp;lt;xsl:include href=&amp;quot;try-block.xslt&amp;quot;/&amp;gt;&lt;/code&gt;.
The main logic is executed in &lt;code&gt; &amp;lt;xsl:template mode=&amp;quot;t:call&amp;quot; match=&amp;quot;try&amp;quot;/&amp;gt;&lt;/code&gt;,
which recieves parameters using tunneling. A default error handler &lt;code&gt; &amp;lt;t:error-handler/&amp;gt;&lt;/code&gt; is
used to report errors.
&lt;/p&gt;
&lt;p&gt;
Error report:
&lt;/p&gt;
&lt;p style="color: red; padding-left: 1em;"&gt;
&lt;code&gt; Error: FOAR0001&lt;br /&gt;
Description:&lt;br /&gt;
Decimal divide by zero&lt;br /&gt;
&lt;br /&gt;
Location:&lt;br /&gt;
1. systemID: "file:///D:/style/try-block-test.xslt", line: 34&lt;br /&gt;
2. template mode="t:call" match="element(try, xs:anyType)"&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block-test.xslt", line: 30&lt;br /&gt;
&amp;nbsp; context node:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /*[1][local-name() = 'try']&lt;br /&gt;
3. template mode="t:call"&lt;br /&gt;
&amp;nbsp; match="element({http://www.nesterovsky-bros.com/xslt/private/try-block}try,
xs:anyType)"&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block.xslt", line: 53&lt;br /&gt;
&amp;nbsp; context node:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /*[1][local-name() = 'try']&lt;br /&gt;
4. systemID: "file:///D:/style/try-block.xslt", line: 40&lt;br /&gt;
5. call-template name="t:try-block"&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block-test.xslt", line: 17&lt;br /&gt;
6. for-each&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block-test.xslt", line: 16&lt;br /&gt;
&amp;nbsp; context item: 5 
&lt;br /&gt;
7. template mode="saxon:_defaultMode" match="document-node()"&lt;br /&gt;
&amp;nbsp; systemID: "file:///D:/style/try-block-test.xslt", line: 14&lt;br /&gt;
&amp;nbsp; context node:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; / &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Implementation details:
&lt;/p&gt;
&lt;p&gt;
You were not expecting this API to be pure xslt, weren&amp;#39;t you? &lt;img alt=":-)" src="http://www.nesterovsky-bros.com/weblog/smilies/happy.gif"&gt;
&lt;/p&gt;
&lt;p&gt;
Well, you&amp;#39;re right, there is an extension function. Its pseudo code is like this:
&lt;/p&gt;
&lt;p style="padding-left: 1em;"&gt;
&lt;code&gt;function tryBlock(tryItems, catchItems) 
&lt;br /&gt;
{ 
&lt;br /&gt;
&amp;nbsp; try&lt;br /&gt;
&amp;nbsp; { 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; execute xsl:apply-templates for tryItems. 
&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; catch&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; execute xsl:apply-templates for catchItems. 
&lt;br /&gt;
&amp;nbsp; } 
&lt;br /&gt;
}&lt;/code&gt;
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The last thing. Please get the implementation &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.zip"&gt; saxon.extensions.zip&lt;/a&gt;.
There you will find sources of the try/catch, and &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f05%2f18%2fTuplesAndMapsInSaxon.aspx"&gt;tuples/maps&lt;/a&gt; API.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=e394e0b8-d3c2-4261-aba9-c70ed03dea1d" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,e394e0b8-d3c2-4261-aba9-c70ed03dea1d.aspx</comments>
      <category>Announce</category>
      <category>Tips and tricks</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=cbd8e06a-80d4-42ae-90c1-80d8bfd3a567</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,cbd8e06a-80d4-42ae-90c1-80d8bfd3a567.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,cbd8e06a-80d4-42ae-90c1-80d8bfd3a567.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=cbd8e06a-80d4-42ae-90c1-80d8bfd3a567</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Right now we're inhabiting in the java world, thus all our tasks are (in)directly
related to this environment.
</p>
        <p>
We want to store stylesheets as resources of java application, and at the same time
to point to these stylesheets without jar qualification. In .NET this idea would not
appear at all, as there are well defined boundaries between assemblies, but java uses
rather different approach. Whenever you have a resource name, it's up to <code>ClassLoader</code> to
find this resource. To exploit this feature we've created an uri resolver for
the stylesheet transformation. The protocol we use has a following format: "<code>resource:/resource-path</code>".
</p>
        <p>
For example to store stylesheets in the <code>META-INF/stylesheets</code> folder we
use uri "<code>resource:/META-INF/stylesheets/java/main.xslt</code>". Relative path
is resolved naturally. A path "<code><a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=cbd8e06a-80d4-42ae-90c1-80d8bfd3a567&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f06%2f09%2fjxomUpdate.aspx">../jxom/java-serializer.xslt</a></code>"
in previously mentioned stylesheet is resolved to "<code><a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=cbd8e06a-80d4-42ae-90c1-80d8bfd3a567&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx">resource:/META-INF/stylesheets/jxom/java-serializer.xslt</a></code>". 
</p>
        <p>
We've created a small class <code>ResourceURIResolver</code>. You need to supply an
instance of <code>TransformerFactory</code> with this resolver:<br /><code>  transformerFactory.setURIResolver(new ResourceURIResolver());</code></p>
        <p>
The class itself is so small that we qoute it here:
</p>
        <p style="font-family: monospace; padding-left: 1em;">
import java.io.InputStream;<br /><br />
import java.net.URI;<br />
import java.net.URISyntaxException;<br /><br />
import javax.xml.transform.Source;<br />
import javax.xml.transform.TransformerException;<br />
import javax.xml.transform.URIResolver;<br /><br />
import javax.xml.transform.stream.StreamSource;<br /><br />
/**<br />
 * This class implements an interface that can be called by the processor<br />
 * to turn a URI used in document(), xsl:import, or xsl:include into a<br />
 * Source object.<br />
 */<br />
public class ResourceURIResolver implements URIResolver<br />
{<br />
  /**<br />
   * Called by the processor when it encounters 
<br />
   * an xsl:include, xsl:import, or document() function.<br />
   *<br />
   * This resolver supports protocol "resource:".<br />
   * Format of uri is: "resource:/resource-path", where "resource-path"
is an<br />
   * argument of a {@link ClassLoader#getResourceAsStream(String)} call.<br />
   * @param href - an href attribute, which may be relative or absolute.<br />
   * @param base - a base URI against which the first argument will be made<br />
   *   absolute if the absolute URI is required.<br />
   * @return a Source object, or null if the href cannot be resolved, and<br />
   *   the processor should try to resolve the URI itself.<br />
   */<br />
  public Source resolve(String href, String base)<br />
    throws TransformerException<br />
  {<br />
    if (href == null)<br />
    {<br />
      return null;<br />
    }<br /><br />
    URI uri;<br /><br />
    try<br />
    {<br />
      if (base == null)<br />
      {<br />
        uri = new URI(href);<br />
      } 
<br />
      else 
<br />
      {<br />
        uri = new URI(base).resolve(href); 
<br />
      }<br />
    } 
<br />
    catch(URISyntaxException e) 
<br />
    { 
<br />
      // Unsupported uri.<br />
      return null; 
<br />
    } 
<br /><br />
    if (!"resource".equals(uri.getScheme()))<br />
    {<br />
      return null;<br />
    } 
<br /><br />
    String resourceName = uri.getPath(); 
<br /><br />
    if ((resourceName == null) || (resourceName.length() == 0))<br />
    {<br />
      return null;<br />
    }<br /><br />
    if (resourceName.charAt(0) == '/')<br />
    {<br />
      resourceName = resourceName.substring(1);<br />
    }<br /><br />
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();<br />
    InputStream stream = classLoader.getResourceAsStream(resourceName);<br /><br />
    if (stream == null)<br />
    {<br />
      return null;<br />
    }<br /><br />
    return new StreamSource(stream, uri.toString()); 
<br />
  }<br />
}
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=cbd8e06a-80d4-42ae-90c1-80d8bfd3a567" />
      </body>
      <title>A "resource:" protocol to resolve documents in xslt.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,cbd8e06a-80d4-42ae-90c1-80d8bfd3a567.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/06/17/AResourceProtocolToResolveDocumentsInXslt.aspx</link>
      <pubDate>Tue, 17 Jun 2008 07:57:52 GMT</pubDate>
      <description>&lt;p&gt;
Right now we&amp;#39;re inhabiting in the java world, thus all our tasks are (in)directly
related to this environment.
&lt;/p&gt;
&lt;p&gt;
We want to store stylesheets as resources of java application, and at the same time
to point to these stylesheets without jar qualification. In .NET this idea would not
appear at all, as there are well defined boundaries between assemblies, but java uses
rather different approach. Whenever you have a resource name, it&amp;#39;s up to &lt;code&gt;ClassLoader&lt;/code&gt; to
find this resource. To exploit this feature we&amp;#39;ve created an uri resolver for
the stylesheet transformation. The protocol we use has a following format: "&lt;code&gt;resource:/resource-path&lt;/code&gt;".
&lt;/p&gt;
&lt;p&gt;
For example to store stylesheets in the &lt;code&gt;META-INF/stylesheets&lt;/code&gt; folder we
use uri "&lt;code&gt;resource:/META-INF/stylesheets/java/main.xslt&lt;/code&gt;". Relative path
is resolved naturally. A path &amp;quot;&lt;code&gt;&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=cbd8e06a-80d4-42ae-90c1-80d8bfd3a567&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f06%2f09%2fjxomUpdate.aspx"&gt;../jxom/java-serializer.xslt&lt;/a&gt;&lt;/code&gt;&amp;quot;
in previously mentioned stylesheet is resolved to &amp;quot;&lt;code&gt;&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=cbd8e06a-80d4-42ae-90c1-80d8bfd3a567&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx"&gt;resource:/META-INF/stylesheets/jxom/java-serializer.xslt&lt;/a&gt;&lt;/code&gt;&amp;quot;. 
&lt;/p&gt;
&lt;p&gt;
We've created a small class &lt;code&gt;ResourceURIResolver&lt;/code&gt;. You need to supply an
instance of &lt;code&gt;TransformerFactory&lt;/code&gt; with this resolver:&lt;br /&gt;
&lt;code&gt;&amp;nbsp; transformerFactory.setURIResolver(new ResourceURIResolver());&lt;/code&gt; 
&lt;/p&gt;
&lt;p&gt;
The class itself is so small that we qoute it here:
&lt;/p&gt;
&lt;p style="font-family: monospace; padding-left: 1em;"&gt;
import java.io.InputStream;&lt;br /&gt;
&lt;br /&gt;
import java.net.URI;&lt;br /&gt;
import java.net.URISyntaxException;&lt;br /&gt;
&lt;br /&gt;
import javax.xml.transform.Source;&lt;br /&gt;
import javax.xml.transform.TransformerException;&lt;br /&gt;
import javax.xml.transform.URIResolver;&lt;br /&gt;
&lt;br /&gt;
import javax.xml.transform.stream.StreamSource;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
&amp;nbsp;* This class implements an interface that can be called by the processor&lt;br /&gt;
&amp;nbsp;* to turn a URI used in document(), xsl:import, or xsl:include into a&lt;br /&gt;
&amp;nbsp;* Source object.&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
public class ResourceURIResolver implements URIResolver&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; /**&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Called by the processor when it encounters 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * an xsl:include, xsl:import, or document() function.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; *&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * This resolver supports protocol &amp;quot;resource:&amp;quot;.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * Format of uri is: &amp;quot;resource:/resource-path&amp;quot;, where &amp;quot;resource-path&amp;quot;
is an&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * argument of a {@link ClassLoader#getResourceAsStream(String)} call.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @param href - an href attribute, which may be relative or absolute.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @param base - a base URI against which the first argument will be made&lt;br /&gt;
&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; absolute if the absolute URI is required.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; * @return a Source object, or null if the href cannot be resolved, and&lt;br /&gt;
&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; the processor should try to resolve the URI itself.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; */&lt;br /&gt;
&amp;nbsp; public Source resolve(String href, String base)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; throws TransformerException&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (href == null)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; URI uri;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (base == null)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uri = new URI(href);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uri = new URI(base).resolve(href); 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; catch(URISyntaxException e) 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; { 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Unsupported uri.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null; 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!&amp;quot;resource&amp;quot;.equals(uri.getScheme()))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; String resourceName = uri.getPath(); 
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((resourceName == null) || (resourceName.length() == 0))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (resourceName.charAt(0) == &amp;#39;/&amp;#39;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resourceName = resourceName.substring(1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ClassLoader classLoader = Thread.currentThread().getContextClassLoader();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; InputStream stream = classLoader.getResourceAsStream(resourceName);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (stream == null)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return new StreamSource(stream, uri.toString()); 
&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=cbd8e06a-80d4-42ae-90c1-80d8bfd3a567" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,cbd8e06a-80d4-42ae-90c1-80d8bfd3a567.aspx</comments>
      <category>Tips and tricks</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=97e1ed84-de44-4c36-9a7b-2bfaa994697a</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,97e1ed84-de44-4c36-9a7b-2bfaa994697a.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,97e1ed84-de44-4c36-9a7b-2bfaa994697a.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=97e1ed84-de44-4c36-9a7b-2bfaa994697a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We've uploaded an <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip">update
for the jxom</a>.
</p>
        <p>
It has turned out that jxom schema is so powerful that you can do a great number of
manipulations over xml representation of java program.
</p>
        <p>
In our case this is an optimization of unreachable code, defined at <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a&amp;url=http%3a%2f%2fjava.sun.com%2fdocs%2fbooks%2fjls%2fsecond_edition%2fhtml%2fstatements.doc.html%23236365" rel="nofollow">Sun's
spec</a>. We're facing this problem as result of translation from other ancient language,
which also has well defined xml schema.
</p>
        <p>
We also have introduced an ability to annotate jxom elements (see meta element), which
in practice we use to annotate expressions with their types and perform "compile time"
expression evaluation.
</p>
        <p>
You may <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip">download
jxom version at usual place</a>.
</p>
        <p>
See also: <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f09%2fJavaXmlObjectModel.aspx">Java
Xml Object Model</a>.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a" />
      </body>
      <title>jxom update</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,97e1ed84-de44-4c36-9a7b-2bfaa994697a.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/06/09/jxomUpdate.aspx</link>
      <pubDate>Mon, 09 Jun 2008 06:47:54 GMT</pubDate>
      <description>&lt;p&gt;
We've uploaded an &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip"&gt;update
for the jxom&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
It has turned out that jxom schema is so powerful that you can do a great number of
manipulations over xml representation of java program.
&lt;/p&gt;
&lt;p&gt;
In our case this is an optimization of unreachable code, defined at &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a&amp;amp;url=http%3a%2f%2fjava.sun.com%2fdocs%2fbooks%2fjls%2fsecond_edition%2fhtml%2fstatements.doc.html%23236365" rel="nofollow"&gt;Sun's
spec&lt;/a&gt;. We're facing this problem as result of translation from other ancient language,
which also has well defined xml schema.
&lt;/p&gt;
&lt;p&gt;
We also have introduced an ability to annotate jxom elements (see meta element), which
in practice we use to annotate expressions with their types and perform "compile time"
expression evaluation.
&lt;/p&gt;
&lt;p&gt;
You may &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjxom.zip"&gt;download
jxom version at usual place&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
See also: &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f09%2fJavaXmlObjectModel.aspx"&gt;Java
Xml Object Model&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=97e1ed84-de44-4c36-9a7b-2bfaa994697a" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,97e1ed84-de44-4c36-9a7b-2bfaa994697a.aspx</comments>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=8696e822-24e5-4931-8c51-0f0f600cd130</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,8696e822-24e5-4931-8c51-0f0f600cd130.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,8696e822-24e5-4931-8c51-0f0f600cd130.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=8696e822-24e5-4931-8c51-0f0f600cd130</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The project we're working on requires us to generate a java web application from a
some ancient language. The code being converted, we have transformed into java classes
(thanks to <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8696e822-24e5-4931-8c51-0f0f600cd130&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx">jxom</a>),
the presentation is converted into JSF (facelets) pages.
</p>
        <p style="font-style: italic">
By the way, long before java (.net) platform has been conceived, there were languages
and environments, worked out so good that contemporary client - server paradigms (like
JSF, ASP.NET, and so on) are just their isomorphisms.
</p>
        <p>
The problem we were dealing with recently is JSF databinding for a bean properties
of types <code>java.sql.Date, java.sql.Time, java.sql.Timestamp</code>.
</p>
        <p>
At some point of design we have decided that these types are most natural representation
of data in the original language, as the program's activity is tightly connected
to the database. Later on it's became clear that JSF databinding does not like
these types at all. We were to decide either to fall back and use <code>java.util.Date</code> as
bean property types, or do something with databinding.
</p>
        <p>
It was not clear what's the best way until we have found an elegant solution,
namely: to create ELResolver to handle bean properties of these types. The solution
works because custom el resolvers are applied before standard resolvers (except implicit
one).
</p>
        <p>
The class <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8696e822-24e5-4931-8c51-0f0f600cd130&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjsf1.2%2fDateELResolver.java.txt" target="_blank">DateELResolver</a> is
rather simple extension of the BeanELResolver. To use it you only need to register
it the faces-config.xml:
</p>
        <p style="font-family: monospace; padding-left: 1em;">
&lt;faces-config version="1.2"<br />
  xmlns="http://java.sun.com/xml/ns/javaee"<br />
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br />
    http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"&gt;<br />
  &lt;application&gt;<br />
    &lt;el-resolver&gt;<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8696e822-24e5-4931-8c51-0f0f600cd130&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjsf1.2%2fDateELResolver.java.txt" target="_blank">com.nesterovskyBros.jsf.DateELResolver</a>&lt;/el-resolver&gt;<br />
  &lt;/application&gt;<br />
&lt;/faces-config&gt;
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=8696e822-24e5-4931-8c51-0f0f600cd130" />
      </body>
      <title>JSF 1.2 and java.sql.Date bean properties.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,8696e822-24e5-4931-8c51-0f0f600cd130.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/05/30/JSF12AndJavasqlDateBeanProperties.aspx</link>
      <pubDate>Fri, 30 May 2008 12:49:50 GMT</pubDate>
      <description>&lt;p&gt;
The project we're working on requires us to generate a java web application from a
some ancient language. The code being converted, we have transformed into java classes
(thanks to &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8696e822-24e5-4931-8c51-0f0f600cd130&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f02%2f16%2fXsltForTheJxomJavaXmlObjectModel.aspx"&gt;jxom&lt;/a&gt;),
the presentation is converted into JSF (facelets) pages.
&lt;/p&gt;
&lt;p style="font-style: italic"&gt;
By the way, long before java (.net) platform has been conceived, there were languages
and environments, worked out so good that contemporary client - server paradigms (like
JSF, ASP.NET, and so on) are just their isomorphisms.
&lt;/p&gt;
&lt;p&gt;
The problem we were dealing with recently is JSF databinding for a bean properties
of types &lt;code&gt;java.sql.Date, java.sql.Time, java.sql.Timestamp&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
At some point of design we have decided that these types are most natural representation
of data in the original language, as the program&amp;#39;s activity is tightly connected
to the database. Later on it&amp;#39;s became clear that JSF databinding does not like
these types at all. We were to decide either to fall back and use &lt;code&gt;java.util.Date&lt;/code&gt; as
bean property types, or do something with databinding.
&lt;/p&gt;
&lt;p&gt;
It was not clear what&amp;#39;s the best way until we have found an elegant solution,
namely: to create ELResolver to handle bean properties of these types. The solution
works because custom el resolvers are applied before standard resolvers (except implicit
one).
&lt;/p&gt;
&lt;p&gt;
The class &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8696e822-24e5-4931-8c51-0f0f600cd130&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjsf1.2%2fDateELResolver.java.txt" target="_blank"&gt;DateELResolver&lt;/a&gt; is
rather simple extension of the BeanELResolver. To use it you only need to register
it the faces-config.xml:
&lt;/p&gt;
&lt;p style="font-family: monospace; padding-left: 1em;"&gt;
&amp;lt;faces-config version=&amp;quot;1.2&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns=&amp;quot;http://java.sun.com/xml/ns/javaee&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
&amp;nbsp; xsi:schemaLocation=&amp;quot;http://java.sun.com/xml/ns/javaee&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;application&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;el-resolver&amp;gt;&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=8696e822-24e5-4931-8c51-0f0f600cd130&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fjsf1.2%2fDateELResolver.java.txt" target="_blank"&gt;com.nesterovskyBros.jsf.DateELResolver&lt;/a&gt;&amp;lt;/el-resolver&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/faces-config&amp;gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=8696e822-24e5-4931-8c51-0f0f600cd130" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,8696e822-24e5-4931-8c51-0f0f600cd130.aspx</comments>
      <category>Tips and tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=261fb587-c621-41e1-b0ac-3a722f7ab5f6</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,261fb587-c621-41e1-b0ac-3a722f7ab5f6.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,261fb587-c621-41e1-b0ac-3a722f7ab5f6.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=261fb587-c621-41e1-b0ac-3a722f7ab5f6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently I've proposed to add two new atomic types <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f04%2f04%2fWhatImMissingInXslt20xquery10.aspx"> tuple
and map</a> to the xpath/xslt/xquery type system (see "<a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.w3.org%2fBugs%2fPublic%2fshow_bug.cgi%3fid%3d5630">Tuples
an maps</a>"). Later I've implemented <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f04%2f05%2fTupleAndMapInTheXslt20.aspx"> tuple
and map pure xslt approximation</a>. Now I want to present <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip">java
implementation for Saxon</a>.
</p>
        <p>
I've created TupleValue and MapValue atomic types, and Collections class exposing
extension functions api. It's easy to use this api. I'll repeat an example
that I was showing earlier:
</p>
        <p style="padding-left: 1em">
          <code> &lt;xsl:stylesheet version="2.0" 
<br />
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<br />
  xmlns:xs="http://www.w3.org/2001/XMLSchema"<br />
  xmlns:f="http://www.nesterovsky-bros.com/xslt/functions/public"<br />
  xmlns:p="http://www.nesterovsky-bros.com/xslt/functions/private" 
<br />
  xmlns:c="java:com.nesterovskyBros.saxon.Functions" 
<br />
  exclude-result-prefixes="xs f p c"&gt;<br /><br />
&lt;xsl:template match="/"&gt; 
<br />
   &lt;root&gt;<br />
     &lt;xsl:variable name="tuples" as="item()*"
select="<br />
       for $i in 1 to 20<br />
         return c:tuple(1 to $i)"/&gt;<br /><br />
    &lt;total-items&gt;<br />
      &lt;xsl:sequence select="<br />
        sum<br />
        (<br />
          for $tuple in $tuples return<br />
            count(c:tuple-items($tuple))<br />
        )"/&gt;<br />
    &lt;/total-items&gt;<br />
    &lt;tuples-size&gt;<br />
      &lt;xsl:sequence select="count($tuples)"/&gt;<br />
    &lt;/tuples-size&gt;<br />
    &lt;sums-per-tuples&gt;<br />
      &lt;xsl:for-each select="$tuples"&gt;<br />
        &lt;xsl:variable name="index"
as="xs:integer" select="position()"/&gt;<br /><br />
        &lt;sum index="{$index}" value="{sum(c:tuple-items(.))}"/&gt;<br />
      &lt;/xsl:for-each&gt;<br />
    &lt;/sums-per-tuples&gt;<br /><br />
    &lt;xsl:variable name="cities" as="element()*"&gt;<br />
      &lt;city name="Jerusalem" country="Israel"/&gt;<br />
      &lt;city name="London" country="Great
Britain"/&gt;<br />
      &lt;city name="Paris" country="France"/&gt;<br />
      &lt;city name="New York" country="USA"/&gt;<br />
      &lt;city name="Moscow" country="Russia"/&gt;<br />
      &lt;city name="Tel Aviv" country="Israel"/&gt;<br />
      &lt;city name="St. Petersburg" country="Russia"/&gt;<br />
     &lt;/xsl:variable&gt;<br /><br />
    &lt;xsl:variable name="map" as="item()" select="<br />
      c:map<br />
      (<br />
        for $city in $cities return<br />
        (<br />
          $city/string(@country),<br />
          $city<br />
        )<br />
      )"/&gt;<br /><br />
    &lt;xsl:for-each select="c:map-keys($map)"&gt;<br />
      &lt;xsl:variable name="key" as="xs:string"
select="."/&gt;<br /><br />
      &lt;country name="{$key}"&gt;<br />
        &lt;xsl:sequence select="c:map-value($map,
$key)"/&gt;<br />
     &lt;/country&gt;<br />
    &lt;/xsl:for-each&gt;<br />
  &lt;/root&gt; 
<br />
&lt;/xsl:template&gt; 
<br /><br />
&lt;/xsl:stylesheet&gt;</code>
        </p>
        <p>
          <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip">Download
java source</a>.
</p>
        <p>
P.S. I would wish this api be integrated into Saxon, as at present java extension
functions are called through reflection.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6" />
      </body>
      <title>Tuples and maps in Saxon</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,261fb587-c621-41e1-b0ac-3a722f7ab5f6.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/05/18/TuplesAndMapsInSaxon.aspx</link>
      <pubDate>Sun, 18 May 2008 08:44:09 GMT</pubDate>
      <description>&lt;p&gt;
Recently I&amp;#39;ve proposed to add two new atomic types &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f04%2f04%2fWhatImMissingInXslt20xquery10.aspx"&gt; tuple
and map&lt;/a&gt; to the xpath/xslt/xquery type system (see &amp;quot;&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.w3.org%2fBugs%2fPublic%2fshow_bug.cgi%3fid%3d5630"&gt;Tuples
an maps&lt;/a&gt;&amp;quot;). Later I&amp;#39;ve implemented &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fweblog%2f2008%2f04%2f05%2fTupleAndMapInTheXslt20.aspx"&gt; tuple
and map pure xslt approximation&lt;/a&gt;. Now I want to present &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip"&gt;java
implementation for Saxon&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I&amp;#39;ve created TupleValue and MapValue atomic types, and Collections class exposing
extension functions api. It&amp;#39;s easy to use this api. I&amp;#39;ll repeat an example
that I was showing earlier:
&lt;/p&gt;
&lt;p style="padding-left: 1em"&gt;
&lt;code&gt; &amp;lt;xsl:stylesheet version=&amp;quot;2.0&amp;quot; 
&lt;br /&gt;
&amp;nbsp; xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:xs=&amp;quot;http://www.w3.org/2001/XMLSchema&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:f=&amp;quot;http://www.nesterovsky-bros.com/xslt/functions/public&amp;quot;&lt;br /&gt;
&amp;nbsp; xmlns:p=&amp;quot;http://www.nesterovsky-bros.com/xslt/functions/private&amp;quot; 
&lt;br /&gt;
&amp;nbsp; xmlns:c=&amp;quot;java:com.nesterovskyBros.saxon.Functions&amp;quot; 
&lt;br /&gt;
&amp;nbsp; exclude-result-prefixes=&amp;quot;xs f p c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;root&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;tuples&amp;quot; as=&amp;quot;item()*&amp;quot;
select=&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for $i in 1 to 20&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return c:tuple(1 to $i)&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;total-items&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for $tuple in $tuples return&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(c:tuple-items($tuple))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/total-items&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tuples-size&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;count($tuples)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tuples-size&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sums-per-tuples&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:for-each select=&amp;quot;$tuples&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;index&amp;quot;
as=&amp;quot;xs:integer&amp;quot; select=&amp;quot;position()&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sum index=&amp;quot;{$index}&amp;quot; value=&amp;quot;{sum(c:tuple-items(.))}&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/sums-per-tuples&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;cities&amp;quot; as=&amp;quot;element()*&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;Jerusalem&amp;quot; country=&amp;quot;Israel&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;London&amp;quot; country=&amp;quot;Great
Britain&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;Paris&amp;quot; country=&amp;quot;France&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;New York&amp;quot; country=&amp;quot;USA&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;Moscow&amp;quot; country=&amp;quot;Russia&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;Tel Aviv&amp;quot; country=&amp;quot;Israel&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;city name=&amp;quot;St. Petersburg&amp;quot; country=&amp;quot;Russia&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;map&amp;quot; as=&amp;quot;item()&amp;quot; select=&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c:map&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for $city in $cities return&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $city/string(@country),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $city&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:for-each select=&amp;quot;c:map-keys($map)&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:variable name=&amp;quot;key&amp;quot; as=&amp;quot;xs:string&amp;quot;
select=&amp;quot;.&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;country name=&amp;quot;{$key}&amp;quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;xsl:sequence select=&amp;quot;c:map-value($map,
$key)&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/country&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/root&amp;gt; 
&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt; 
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6&amp;amp;url=http%3a%2f%2fwww.nesterovsky-bros.com%2fdownload%2fsaxon.extensions.9.1.zip"&gt;Download
java source&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
P.S. I would wish this api be integrated into Saxon, as at present java extension
functions are called through reflection.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=261fb587-c621-41e1-b0ac-3a722f7ab5f6" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,261fb587-c621-41e1-b0ac-3a722f7ab5f6.aspx</comments>
      <category>Announce</category>
      <category>xslt</category>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=61ab6d44-d150-4d1e-8cf2-7387dd1a4108</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,61ab6d44-d150-4d1e-8cf2-7387dd1a4108.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,61ab6d44-d150-4d1e-8cf2-7387dd1a4108.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=61ab6d44-d150-4d1e-8cf2-7387dd1a4108</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Many times I was tempted to create my bests books list. 
</p>
        <p>
No, I dare not to create it. There are so many brilliant masterpieces; I allow to
make such lists to someone, who is wiser than myself. However, I cannot be silent
about a book I've read recently. This is <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=61ab6d44-d150-4d1e-8cf2-7387dd1a4108&amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fUlysses_%252528novel%252529" rel="nofollow"> Ulysses</a> by <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=61ab6d44-d150-4d1e-8cf2-7387dd1a4108&amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fJames_Joyce" rel="nofollow"> James
Joyce</a>.
</p>
        <p>
It's hard reading: you need to know all creative work of Joyce, Homer, state of
the affairs in the world in the year of 1904, map of city of Dublin in that year,
and many many other information. That is the reason why you must read annotated version.
</p>
        <p>
The labour of reading is compensated with intellectual pleasure from it, because it's
not a story that is catching you, but narration. Having imagination, you're immersing
into a world created by the author.
</p>
        <p>
I can believe that there are people for years living in the world created by Joyce.
</p>
        <img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=61ab6d44-d150-4d1e-8cf2-7387dd1a4108" />
      </body>
      <title>The best book I ever read.</title>
      <guid isPermaLink="false">http://www.nesterovsky-bros.com/weblog/PermaLink,guid,61ab6d44-d150-4d1e-8cf2-7387dd1a4108.aspx</guid>
      <link>http://www.nesterovsky-bros.com/weblog/2008/05/15/TheBestBookIEverRead.aspx</link>
      <pubDate>Thu, 15 May 2008 06:22:57 GMT</pubDate>
      <description>&lt;p&gt;
Many times I was tempted to create my bests books list. 
&lt;/p&gt;
&lt;p&gt;
No, I dare not to create it. There are so many brilliant masterpieces; I allow to
make such lists to someone, who is wiser than myself. However, I cannot be silent
about a book I&amp;#39;ve read recently. This is &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=61ab6d44-d150-4d1e-8cf2-7387dd1a4108&amp;amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fUlysses_%252528novel%252529" rel="nofollow"&gt; Ulysses&lt;/a&gt; by &lt;a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=61ab6d44-d150-4d1e-8cf2-7387dd1a4108&amp;amp;url=http%3a%2f%2fen.wikipedia.org%2fwiki%2fJames_Joyce" rel="nofollow"&gt; James
Joyce&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
It&amp;#39;s hard reading: you need to know all creative work of Joyce, Homer, state of
the affairs in the world in the year of 1904, map of city of Dublin in that year,
and many many other information. That is the reason why you must read annotated version.
&lt;/p&gt;
&lt;p&gt;
The labour of reading is compensated with intellectual pleasure from it, because it&amp;#39;s
not a story that is catching you, but narration. Having imagination, you&amp;#39;re immersing
into a world created by the author.
&lt;/p&gt;
&lt;p&gt;
I can believe that there are people for years living in the world created by Joyce.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.nesterovsky-bros.com/weblog/aggbug.ashx?id=61ab6d44-d150-4d1e-8cf2-7387dd1a4108" /&gt;</description>
      <comments>http://www.nesterovsky-bros.com/weblog/CommentView,guid,61ab6d44-d150-4d1e-8cf2-7387dd1a4108.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.nesterovsky-bros.com/weblog/Trackback.aspx?guid=6923dbd6-213a-41c9-a3f8-8a83f56bc368</trackback:ping>
      <pingback:server>http://www.nesterovsky-bros.com/weblog/pingback.aspx</pingback:server>
      <pingback:target>http://www.nesterovsky-bros.com/weblog/PermaLink,guid,6923dbd6-213a-41c9-a3f8-8a83f56bc368.aspx</pingback:target>
      <dc:creator>Vladimir Nesterovsky</dc:creator>
      <wfw:comment>http://www.nesterovsky-bros.com/weblog/CommentView,guid,6923dbd6-213a-41c9-a3f8-8a83f56bc368.aspx</wfw:comment>
      <wfw:commentRss>http://www.nesterovsky-bros.com/weblog/SyndicationService.asmx/GetEntryCommentsRss?guid=6923dbd6-213a-41c9-a3f8-8a83f56bc368</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today I've found another new language (working draft in fact). It's <a href="http://www.nesterovsky-bros.com/weblog/ct.ashx?id=6923dbd6-213a-41c9-a3f8-8a83f56bc368&amp;url=http%3a%2f%2fwww.w3.org%2fTR%2fxproc%2f">an
XML Pipeline Language</a>.
</p>
        <div style="font-style: italic; padding-left: 1em">
          <p>
XProc: An XML Pipeline Language, a language for describing operations to be performed
on XML documents.
</p>
          <p>
An XML Pipeline specifies a sequence of operations to be performed on zero or more
XML documents. Pipelines generally accept zero or more XML documents as input and
produce zero or more XML documents as output. Pipelines are made up of simple steps
which perform atomic operations on XML documents and constructs similar to conditionals,
iteration, and exception handlers which control which steps are executed.
</p>
        </div>
        <p>
An experience shows a process of language invention is an essential part of computer
industry from the very beginning, however...
</p>
        <p>
I must confess I must be too reluctant to any new language: I was happy with C++,
but then all these new languages like Delphi, Java, C#, and so many others started
to appear. It's correct to say that there is no efficient universal language,
however I think it's wrong to say that a domain s