Skip to content

Commit a25532e

Browse files
authored
Move Fix Playbook-Part into Fix User Guide #37 (#48)
Also adjust the links in the documentation
1 parent 0d125bf commit a25532e

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed

docs/Getting-Started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The easiest way to get started with Metafacture is the Playground. Take a look a
1212

1313
For commands available in the Flux, see [the Flux commands documentation](flux/flux-commands.html).
1414

15-
For functions and usage of the Fix, see [the Fix functions and cookbook](fix/Fix-functions-and-Cookbook.html).
15+
For functions of the Fix, see [the Fix functions](fix/Fix-functions-and-Cookbook.html).
1616

1717
For next steps get familar with [FLUX](flux/Flux-User-Guide.html) and [FIX](fix/Fix-User-Guide.html). And try out some Metafacture workflows.
1818

docs/MF-in-5-min.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ $ cat yaml2json.flux
9393

9494
## FIX LANGUAGE
9595

96-
Many data conversions need a mapping from one field to another field plus optional conversions of the data inside these fields. Metafacture provides the transformation module `fix` that uses the Catmandu-inspired Fix language to assist in these mappings. See the [full list of Fix functions](fix/Fix-functions-and-Cookbook.html#functions).
96+
Many data conversions need a mapping from one field to another field plus optional conversions of the data inside these fields. Metafacture provides the transformation module `fix` that uses the Catmandu-inspired Fix language to assist in these mappings. See the [full list of Fix functions](fix/Fix-functions.html#functions).
9797

9898
Fixes can be provided inline as text argument of the fix module in the Flux script, or as a pointer to a Fix script. A Fix script groups one or more fixes in a file.
9999

docs/fix/Fix-User-Guide.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ vars.put("rights", "CC-0");
230230
final Metafix metafix = new metafix("fixdef.fix", vars);
231231
```
232232

233-
234-
235233
## Splitting Fixes for Reuse
236234

237235
In a complex project setting there may be several Fixes in use,
@@ -244,7 +242,7 @@ Another scenario would be to reduce the size of a single fix file and create sev
244242

245243
To accomodate for such reuse, Fix offers an include mechanism:
246244

247-
``````
245+
```perl
248246
# Setup adds maps, macros and vars once
249247
do once("setup")
250248
include ("./fix/maps.fix")
@@ -254,3 +252,43 @@ end
254252
```
255253

256254
For performance reasons it is useful to integrate macros and maps that are used often in a `do once` bind.
255+
256+
## Cookbook
257+
258+
This page is a replication of the passages [Best practices and guidelines for working with Metafacture Fix](https://github.com/metafacture/metafacture-fix?tab=readme-ov-file#best-practices-and-guidelines-for-working-with-metafacture-fix) and [Glossary](https://github.com/metafacture/metafacture-fix?tab=readme-ov-file#glossary) of the Fix Readme.md. Status: [Fix Release 1.1.2](https://github.com/metafacture/metafacture-fix/releases/tag/1.1.2)
259+
260+
### Best practices and guidelines for working with Metafacture Fix
261+
262+
- We recommend to use double quotation marks for arguments and values in functions, binds and conditionals.
263+
- If using a `list` bind with a variable, the `var` option requires quotation marks (`do list(path: "<sourceField>", "var": "<variableName>")`).
264+
- Fix turns repeated fields into arrays internally but only marked arrays (with `[]` at the end of the field name) are also emitted as "arrays" (entities with indexed literals), all other arrays are emitted as repeated fields.
265+
- Every Fix file should end with a final newline.
266+
267+
### Glossary
268+
269+
#### Array wildcards
270+
271+
Array wildcards resemble [Catmandu's concept of wildcards](http://librecat.org/Catmandu/#wildcards).
272+
273+
When working with arrays and repeated fields you can use wildcards instead of an index number to select elements of an array.
274+
275+
| Wildcard | Meaning |
276+
|----------|:--------|
277+
| `*` | Selects _all_ elements of an array. |
278+
| `$first` | Selects only the _first_ element of an array. |
279+
| `$last` | Selects only the _last_ element of an array. |
280+
| `$prepend` | Selects the position _before_ the first element of an array. Can only be used when adding new elements to an array. |
281+
| `$append` | Selects the position _after_ the last element of an array. Can only be used when adding new elements to an array. |
282+
283+
#### Path wildcards
284+
285+
Path wildcards resemble [Metamorph's concept of wildcards](https://github.com/metafacture/metafacture-core/wiki/Metamorph-User-Guide#addressing-pieces-of-data). They are not supported in Catmandu (it has [specialized Fix functions](https://librecat.org/Catmandu/#marc-mab-pica-paths) instead).
286+
287+
You can use path wildcards to select fields matching a pattern. They only match path _segments_ (field names), though, not _whole_ paths of nested fields. These wildcards cannot be used to add new elements.
288+
289+
| Wildcard | Meaning |
290+
|----------|:--------|
291+
| `*` | Placeholder for zero or more characters. |
292+
| `?` | Placeholder for exactly one character. |
293+
| `\|` | Alternation of multiple patterns. |
294+
| `[...]` | Enumeration of characters. |

docs/fix/Fix-functions-and-Cookbook.md renamed to docs/fix/Fix-functions.md

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,11 @@
11
---
22
layout: default
3-
title: Fix Functions and Cookbook
3+
title: Fix Functions
44
parent: Fix
55
nav_order: 2
66
---
77

8-
This page is a replication of the passage [Fix Functions and Cookbook](https://github.com/metafacture/metafacture-fix?tab=readme-ov-file#functions-and-cookbook) of the Fix Readme.md. Status: [Fix Release 1.1.2](https://github.com/metafacture/metafacture-fix/releases/tag/1.1.2)
9-
10-
## Functions and cookbook
11-
12-
### Best practices and guidelines for working with Metafacture Fix
13-
14-
- We recommend to use double quotation marks for arguments and values in functions, binds and conditionals.
15-
- If using a `list` bind with a variable, the `var` option requires quotation marks (`do list(path: "<sourceField>", "var": "<variableName>")`).
16-
- Fix turns repeated fields into arrays internally but only marked arrays (with `[]` at the end of the field name) are also emitted as "arrays" (entities with indexed literals), all other arrays are emitted as repeated fields.
17-
- Every Fix file should end with a final newline.
18-
19-
### Glossary
20-
21-
#### Array wildcards
22-
23-
Array wildcards resemble [Catmandu's concept of wildcards](http://librecat.org/Catmandu/#wildcards).
24-
25-
When working with arrays and repeated fields you can use wildcards instead of an index number to select elements of an array.
26-
27-
| Wildcard | Meaning |
28-
|----------|:--------|
29-
| `*` | Selects _all_ elements of an array. |
30-
| `$first` | Selects only the _first_ element of an array. |
31-
| `$last` | Selects only the _last_ element of an array. |
32-
| `$prepend` | Selects the position _before_ the first element of an array. Can only be used when adding new elements to an array. |
33-
| `$append` | Selects the position _after_ the last element of an array. Can only be used when adding new elements to an array. |
34-
35-
#### Path wildcards
36-
37-
Path wildcards resemble [Metamorph's concept of wildcards](https://github.com/metafacture/metafacture-core/wiki/Metamorph-User-Guide#addressing-pieces-of-data). They are not supported in Catmandu (it has [specialized Fix functions](https://librecat.org/Catmandu/#marc-mab-pica-paths) instead).
38-
39-
You can use path wildcards to select fields matching a pattern. They only match path _segments_ (field names), though, not _whole_ paths of nested fields. These wildcards cannot be used to add new elements.
40-
41-
| Wildcard | Meaning |
42-
|----------|:--------|
43-
| `*` | Placeholder for zero or more characters. |
44-
| `?` | Placeholder for exactly one character. |
45-
| `\|` | Alternation of multiple patterns. |
46-
| `[...]` | Enumeration of characters. |
8+
This page is a replication of the passage [Functions](https://github.com/metafacture/metafacture-fix?tab=readme-ov-file#functions) of the Fix Readme.md. Status: [Fix Release 1.1.2](https://github.com/metafacture/metafacture-fix/releases/tag/1.1.2)
479

4810
### Functions
4911

docs/fix/fix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ If you are using **Metafacture as a Java library**, create a Metafix object and
1313

1414
The transformation itself is declared in a fix-object which can be a file. For more information on how to declare transformations see [Metafix User Guide](Fix-User-Guide.html).
1515

16-
See [here a list for all available FIX functions and a cookbook for using fix](Fix-functions-and-Cookbook.html).
16+
See [here a list for all available FIX functions](Fix-functions.html).
1717

1818
{: .note }
1919
PS: There is also the transformation module MORPH. Have a look at [the old documentation](https://github.com/metafacture/metafacture-core/wiki/Metamorph-User-Guide) and the German cookbook by [Swissbib](https://swissbib.gitlab.io/metamorph-doku/).

0 commit comments

Comments
 (0)