xsl-list
[Top] [All Lists]

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

2021-09-01 02:52:19
Yes, in XPath the "!" operator corresponds to the flatMap operation of other 
functional programming languages, not to the map operation, and you are quite 
right to point out that I failed to make this distinction. A filter operation 
can be expressed in terms of flatMap, but not in terms of a pure map operation 
which is always one-to-one.

Michael Kay
Saxonica

On 1 Sep 2021, at 03:03, Dimitre Novatchev dnovatchev(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

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&section=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)> [v0, v1, ..., vn] 
as arguments <https://en.wikipedia.org/wiki/Argument_of_a_function> and 
returns [f(v0), f(v1), ..., f(vn)] (where n ≥ 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(_at_)mitre(_dot_)org <mailto:costello(_at_)mitre(_dot_)org> 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com 
<mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>> 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.
 
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by 
email <>)
--~----------------------------------------------------------------
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>
  • Re: [xsl] What is the relationship between transforming, mapping, and filtering?, Michael Kay mike(_at_)saxonica(_dot_)com <=