Feature #5013
Updated by Reynaud Sylvain about 12 years ago
+Refactoring steps+:
1) develop java class to invoke <processor> for all SELECTED and DESCENDANT_OF_SELECT events.
2) support new syntax:
* develop XSL to translate new syntax to current syntax (for pre-processing).
* develop XSL to translate current syntax to new syntax (for lavoisier-update-config.sh).
3) support Lavoisier XPath functions in PiXTL short notation (modify XSL to translate PiXTL short notation to new syntax).
4) support new syntax hidden parameters
* modify XSL to generate hidden parameters.
* instanciate plug-in from new syntax.
5) refactoring: move AbstractSAXPathProcessor to engine:
* modify adaptor interfaces.
* modify engine.
+Language modifications+:
* replace parameter "nodes" with attribute @match.
* replace parameter "namespaces" with xmlns:ns.
* replace parameters "variables" and "xml_variables" with <variable xml="true|FALSE"/>.
* support all XPath functions in both context, except function matched().
+Pre-processing steps+:
1) add parameter types from processors:
* constant: never evaluated.
* relative path: potentially evaluated for each node.
* expression: evaluated for each selected node (text() is converted to 'constant', and @eval is converted to $variable).
2) convert XPath to XML tree <eval>.
3) optimize:
* move the XPath functions that have no descendant::RelativeLocationPath (nor path relative to function matched()) to variables.
* add attribute @onEvents to <parameter>.
* convert XML tree <eval> to XPath @eval.
+Example with actual notation+:
<pre><code class="xml">
<processor type="ReplaceProcessor">
<parameter name="namespaces">
<entry key="e">http://software.in2p3.fr/lavoisier/entries.xsd</entry>
</parameter>
<parameter name="variables">
<entry key="prefix" eval="path('prefix')"/>
</parameter>
<parameter name="xml_variables">
<entry key="xml" eval="request()"/>
</parameter>
<parameter name="nodes">/e:entries/e:entry[@key < $xml/@value]</parameter>
<parameter name="node_prefix" eval="property('ns.entries')"/>
<parameter name="node_name">concat(path('prefix'),'-suffix')</parameter>
<parameter name="node_name_as_xpath">true</parameter>
<parameter name="node_value">'1'</parameter>
</processor>
</code></pre>
The same example with target notation:
<pre><code class="xml">
<processor type="ReplaceProcessor" xmlns:e="http://software.in2p3.fr/lavoisier/entries.xsd"
match="/e:entries/e:entry[@key < request()/@value]">
<parameter name="node_prefix" eval="property('ns.entries')"/>
<parameter name="node_name" eval="concat(path('prefix'),'-suffix')"/>
<parameter name="node_value">1</parameter>
</processor>
</code></pre>
The same example optimized by Lavoisier:
<pre><code class="xml">
<processor type="ReplaceProcessor" xmlns:e="http://software.in2p3.fr/lavoisier/entries.xsd"
match="/e:entries/e:entry[@key < $_match1]">
<variable name="_match1" eval="request()/@value"/>
<variable name="_node_name1" eval="concat(path('prefix'),'-suffix')"/>
<parameter name="node_prefix" eval="property('ns.entries')"/>
<parameter name="node_name">$_node_name1</parameter>
<parameter name="node_value">'1'</parameter> name="node_value">1</parameter>
</processor>
</code></pre>
+Example XPath expression+:
<pre>
choose(
$a != @id,
view('v', arguments() | entry('k', post()/*/*[@id=$a])),
view('v', arguments() | entry('k', post()/*/*[@id=current()/*/*[@name=property('name')]/@id]))
)
</pre>
Then the following expressions must be evaluated for each selected event:
* <code>@id</code>
* <code>current()/*/*[@name=$_4]/@id</code>
+Main benefits+:
* less verbose.
* same XPath functions in both contexts.
* any parameter can be evaluated as an XPath expression.