xsl-list
[Top] [All Lists]

Re: [xsl] Modeling matrices in an XML environment

2020-07-13 17:23:07
Thanks, Liam. This is very helpful. I had used schema-aware processing,
*@as*, and *@type* attributes when I tried the *<cell row="x" col="y">*
approach in the hope of avoiding unwanted type instability. But even when
that works, I hadn't thought about the overhead of the invisible unwanted
properties, and neither had I thought of using maps, which are, I now
realize, a lighter-weight alternative to the *<cell>* elements, with the
same advantages.

On Mon, Jul 13, 2020 at 5:58 PM Liam R. E. Quin 
liam(_at_)fromoldbooks(_dot_)org <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

On Mon, 2020-07-13 at 17:26 +0000, David Birnbaum djbpitt(_at_)gmail(_dot_)com
wrote:
Dear XSL-list,

Roger's question invites a tangential one (for which reason I have
changed
the subject line): How might we usefully think about representing
matrices
in an XML environment?

“it depends”—for performance in XPath/XQuery/XSLT/Xcetera i’d probably
use arrays or, for sparse matrices, maps. This is because the
individual elements in mathematical matrices do not have intrinsic
significance beyond the positional.

For situations in which the elements _do_ have significant, there are
obvious (to this crows) benefits to using XML names, or maps with named
components,
   "x" : 4.2, "y" : 7.2, "z" : 9


The benefit to using maps or arrays over elements in XSLT or XQuery is
that element nodes are too heavyweight, and too prone to turning their
content back into strings. In XQuery in particular, constructors by
default do a terrible and dismal thing: <x>3</x> makes a text node
inside an x element. And XDM element nodes have a ton of properties,
such as next, previous, parent, schema type, is_happy, none  of which
are needed for a matrix of numbers.

This is entirely separate from the MathML apprach, of course, whether
content or presentational.

For performance i'd consider also a single flat array,
  [ r0c0 r0c1 .... r1c0.... ]
with accessor functions my:mget($matrix, $row, $col) or whatever.

It depends on the sort of manipulations you do.

Liam

--
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>