LP#
1379815 Fetch tag data as a table using tag/xpath combo
New function: oils_xpath_tag_to_table()
This function is adapted from oils_xpath_table() with the goal of being
more targeted and simpler to use.
The main issue with oils_xpath_table() is that it relies on peer
UNNEST() functions, and that leads to unexpected behavior whenever the
xpath arguments result in uneven or "gapped" selections. In the first
type of case, the resulting table includes rows representing the least
common multiple of the underlying xpath selections. In the second
type, though the xpaths may sometimes return the same number of values,
those values are not correlated except by order in the marc, which does
not account for the real possibility of null values in the set.
Crude Example:
999 $d ABC $e 123
999 $d DEF
999 $d GHI
999 $e 456
We need a table representing subfields 'd' and 'e' of the '999' fields,
so we might try an xpath like:
//*[@tag="999"]/*[@code="d"]|//*[@tag="999"]/*[@code="e"]
We want:
d | e
---------
ABC | 123
DEF |
GHI |
| 456
but we get:
d | e
---------
ABC | 123
DEF | 456
GHI | 123
ABC | 456
DEF | 123
GHI | 456
This example illustrates both negative behaviors (non-correlated fields
and least-common-multiple row multiplication).
The new method, while internally quite similar, has a different
signature, with the most significant change being a 'tag' argument
which serves as a common base element for the xpaths (now an array
rather than a pipe-delimited string).
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Ben Shum <bshum@biblio.org>