We recently added a `format` method to the text tag that allows you
to format the content of a text tag using the standard printf-style
controls. We think this will be most useful when data binding a text
node. As an example, if you have an XML dataset of people with
firstName and lastName nodes, you currently would display each
element by saying:
1. <view datapath="person/" layout="axis: x">
<text text="$path{'firstName/text()'}" />
<text text="$path{'lastName/text()'}" />
</view>
With the addition of the format method, you can now say this more
compactly, using only 1 node, instead of 3 (which is also more
efficient):
2. <text datapath="person/"
ondata="format('%s %s', datapath.xpathQuery('firstName/text
()'), datapath.xpathQuery('lastName/text()'))"
/>
When the data gets bound to the text node, you fill in the text by
calling format and making the two xpath queries as arguments to the
format method.
But we are considering two other possible syntaxes:
3. <text datapath="person/"
dataformat="'%s %s'"
data=$path{'firstName/text()', 'lastName/text()'}
/>
Here you specify a format control string for the data associated with
the text node, and we allow you to make multiple queries in your
$path constraint.
4. <text datapath="person/" dataformat="'%{firstName/text()}1$q %
{lastName/text()}1$q'" />
Here the queries are embedded in the control string with a custom
extension.
Please cast your vote!