Changes

Jump to navigation Jump to search
1,273 bytes added ,  15:35, 16 November 2023
no edit summary
=Arrow map operator=
<pstyle="white-space: pre-wrap;padding: 1em; border: 1px solid #eaecf0; background-color: #f8f9fa; color: #000; font-family: monospace;"><code>"The cat sat on the mat"<br/> => tokenize()<br/> <span style="color:#C00000">=!></span> concat(".")<br/> <span style="color:#C00000">=!></span> upper-case()<br/> => string-join(" ")</code>
</p>
<p><code>fn:iterate-while($number, <span style="color:#C00000">fn { . </span> < 100 <span style="color:#C00000">}</span>, <span style="color:#C00000">fn { . </span> * <span style="color:#C00000">. }</span>)</code></p>
 
=Optional arguments=
 
<p style="white-space: pre-wrap;padding: 1em; border: 1px solid #eaecf0; background-color: #f8f9fa; color: #000; font-family: monospace;">declare function strings:get(
$value,
$default <span style="color:#C00000">:= "EMPTY"</span>
) {
$value otherwise $default
}
strings:get('john')
</p>
 
=Keyword arguments=
 
<p style="white-space: pre-wrap;padding: 1em; border: 1px solid #eaecf0; background-color: #f8f9fa; color: #000; font-family: monospace;">declare function coordinates(
$x := 0,
$y := 0
) {
map { "x" : $x, "y" : $y }
}
coordinates(<span style="color:#C00000">y :=</span> 123)
</p>
 
=String templates=
 
<p><code><span style="color:#C00000">`</span>Name: <span style="color:#C00000">{</span> $name <span style="color:#C00000">}</span>, <span style="color:#C00000">{</span> $age <span style="color:#C00000">}`</span>
</code></p>
 
… is equivalent to …
 
<p><code>"Name: " || $name || ", " || $age</code></p>
 
… or …
 
<p><code>``[Name: `{ $name }`, `{ $age }`]``</code></p>
 
=Union node tests=
 
<p><code>/xml/child::<span style="color:#C00000">(a|b)</span></code></p>
 
<p><code>/xml/element::<span style="color:#C00000">(c|d)</span></code></p>
 
=Compact lookup syntax=
 
<p style="white-space: pre-wrap;padding: 1em; border: 1px solid #eaecf0; background-color: #f8f9fa; color: #000; font-family: monospace;">$address<span style="color:#C00000">?$name</span>,
$city<span style="color:#C00000">?"city code"</span>
</p>
 
… is equivalent to …
 
<p style="white-space: pre-wrap;padding: 1em; border: 1px solid #eaecf0; background-color: #f8f9fa; color: #000; font-family: monospace;">$address?($name),
$city?("city code")
</p>
=Maps=
20 6 new map functions have been added in [https://qt4cg.org/specifications/xpath-functions-40/Overview.html#maps XPath and XQuery Functions and Operators 4.0], namely
<ul>
<li><code>fn:atomic-equal</code></li>
<li><code>map:build</code></li>
<li><code>map:contains</code></li>
<li><code>map:entries</code></li>
<li><code>map:entry</code></li>
<li><code>map:filter</code></li>
<li><code>map:find</code></li>
<li><code>map:for-each</code></li>
<li><code>map:get</code></li>
<li><code>map:keys</code></li>
<li><code>map:merge</code></li>
<li><code>map:of-pairs</code></li>
<li><code>map:pair</code></li>
<li><code>map:pairs</code></li>
<li><code>map:put</code></li>
<li><code>map:remove</code></li>
<li><code>map:replace</code></li>
<li><code>map:size</code></li>
<li><code>map:substitute</code></li>
<li><code>map:values</code></li>
</ul>
=Arrays=
30 8 new array functions have been added in [https://qt4cg.org/specifications/xpath-functions-40/Overview.html#array XPath and XQuery Functions and Operators 4.0], namely * [[Array_Module#array:build|{{Code|array:build}}]]* [[Array_Module#array:foot|{{Code|array:foot}}]]* <code>array:members</code>* <code>array:of-members</code>* <code>array:replace</code>* <code>array:slice</code>* <code>array:split</code>* <code>array:trunk</code></li> 1 array function has been updated:
<ul>
<li><code>array:append</code></li><li><code>array:build</code></li><li><code>array:empty</code></li><li><code>array:exists</code></li><li><code>array:filter</code></li><li><code>array:flatten</code></li><li><code>array:fold-left</code></li><li><code>array:fold-right</code></li><li><code>array:foot</code></li><li><code>array:for-each</code></li><li><code>array:for-each-pair</code></li><li><code>array:get</code></li><li><code>array:head</code></li><li><code>array:index-where</code></li><li><code>array:insert-before</code></li><li><code>array:join</code></li><li><code>array:members</code></li><li><code>array:of-members</code></li><li><code>array:put</code></li><li><code>array:remove</code></li><li><code>array:replace</code></li><li><code>array:reverse</code></li><li><code>array:size</code></li><li><code>array:slice</code></li><li><code>array:sort</code></li><li><code>array:split</code></li><li><code>array:subarray</code></li><li><code>array:tail</code></li><li><code>array:trunk</code></li><li><code>array:values</code></li>
</ul>
;Version 11.0
* Added operator {{Code|otherwise}} operator* Added function <code>map:build</code>* Added function <code>map:filter</code>* Added function <code>map:of-pairs</code>* Added function <code>map:pair</code>* Added function <code>map:replace</code>* Added function <code>map:substitute</code>* Added function [[Array_Module#array:build|{{Code|array:build}}]]* Added function [[Array_Module#array:foot|{{Code|array:foot}}]]* Added function <code>array:members</code>* Added function <code>array:of-members</code>* Added function <code>array:replace</code>* Added function <code>array:slice</code>* Added function <code>array:split</code>* Added function <code>array:trunk</code>
administrator, Bureaucrats, editor, reviewer, Administrators
57

edits

Navigation menu