Re: [xsl] What is the relationship between transforming, mapping, and filtering?

Subject: Re: [xsl] What is the relationship between transforming, mapping, and filtering?
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 1 Sep 2021 02:03:06 -0000
Wikipedia:
In mathematics <https://en.wikipedia.org/wiki/Mathematics>, a *function*[note
1] <https://en.wikipedia.org/wiki/Function_(mathematics)#cite_note-1>
is a binary
relation <https://en.wikipedia.org/wiki/Binary_relation> between two sets
<https://en.wikipedia.org/wiki/Set_(mathematics)> that associates each
element of the first set to exactly one element of the second set. Typical
examples are functions from integers <https://en.wikipedia.org/wiki/Integer>
to
integers, or from the real numbers
<https://en.wikipedia.org/wiki/Real_number> to real numbers.

In computer science[edit
<https://en.wikipedia.org/w/index.php?title=Map_(mathematics)&action=edit&sec
tion=6>
]

In the communities surrounding programming languages
<https://en.wikipedia.org/wiki/Programming_language> that treat functions
as first-class citizens <https://en.wikipedia.org/wiki/First-class_citizen>,
a map <https://en.wikipedia.org/wiki/Map_(higher-order_function)> is often
referred to as the binary
<https://en.wikipedia.org/wiki/Binary_function> higher-order
function <https://en.wikipedia.org/wiki/Higher-order_function> that takes a
function *f* and a list
<https://en.wikipedia.org/wiki/List_(abstract_data_type)> [*v*0, *v*1, ...,
*v**n*] as arguments <https://en.wikipedia.org/wiki/Argument_of_a_function>
and
returns [*f*(*v*0), *f*(*v*1), ..., *f*(*v**n*)] (where *n* b	% 0).


As we see from these definitions, filtering is not mapping, because the
result of filtering may have fewer items than the source upon which
filtering is applied. For me "mapping" is synonymous to "projection". Both
are in a sense "preserving" or "non-destructive". Filtering on the other
hand is generally destructive: the result-set of (2, 4, 6)[. mod 2 ] is the
empty sequence () .

Unfortunately, XPath allows "functions"  that can return nothing (the empty
sequence) and this leads to the possibility to confuse mapping (strictly
defined) with filtering and other malformations. As mentioned in the 2nd
Wikipedia citation above, well-thought programming languages maintain the
important property of mapping that the number of items (or cardinality of)
the input is the same as the number of items (or cardinality of) the output.

This is why I would prefer to work with XPath arrays, because even the
empty array is something, it is not the empty sequence. Thus if a function
could produce an empty array, but not the empty sequence, this function is
still a mapping, as the number of result items in the input and result
sequences is the same.

Transformation (as in XSLT transformation) is synonymous to performing any
program on an input (including input which is the empty sequence). As some
people have proven, XSLT is Turing-complete, thus any program (Turing
machine) is a transformation.



On Tue, Aug 31, 2021 at 10:58 AM Roger L Costello costello@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Folks,
>
> How do you define those terms? Are they synonymous? Is one a subset of
> another?
>
> By "mapping" I mean populating XML instances of one data standard with
> data from another data standard. For example, I am currently mapping a
> military air navigation data standard to a civilian air navigation data
> standard.
>
> By "filtering" I mean performing actions on data such as redacting,
> fuzzing, and zeroing. One could think of these actions as mapping: if I
> fuzz a lat/long location, I am essentially mapping the location to another
> location.
>
> By "transforming" I mean all the kinds of things you can do with XSLT.
>
> Is filtering a subset of mapping? Is mapping a subset of transforming?
>
> /Roger
>
>
>

--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write
all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

Current Thread