Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include JSONPath and XPath usage in the documentation #129

Closed
mchlrch opened this issue Nov 9, 2023 · 1 comment
Closed

Include JSONPath and XPath usage in the documentation #129

mchlrch opened this issue Nov 9, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@mchlrch
Copy link
Member

mchlrch commented Nov 9, 2023

The documentation doesn't touch on the JSONPath or XPath topics yet.

Aliasing path expressions: The documentation currently only mentions the aliasing mechanism in general but not the combination with path expression for referenceables inside logical-source.

For example declaring recordId and descriptorId:

logical-source personen_desc {
  type json
  source "stdin"
  iterator "$..[?(@.thesaurus == 'Personenbegriffe')]"

  referenceables
    identifier
    title
    description
    recordId "records[*].id"
    descriptorId "related_descriptor_set[*].to_descriptor.identifier"
}

The following sample is from a customer ticket
https://gitlab.zazuko.tools/stabs/staatsarchiv-ld-pipeline/-/issues/14#note_128

Input JSON (reduced):

[
    {
        "identifier": "51725",
        "thesaurus": "Personenbegriffe",
        "title": "Ciba AG",
        "description": "",
        "records": [
            {
                "id": 727741,
                "title": "Anschluss der chemischen Grossindustrie an das st\u00e4dtische Verkehrsnetz: Ciba, Durand & Huguenin, Geigy, Roche, Sandoz"
            }
        ],
        "related_descriptor_set": [
            {
                "identifier": "376261-378711-siehe auch",
                "to_descriptor": {
                    "identifier": "54187",
                    "title": "Ciba-Geigy AG"
                },
                "role": "siehe auch",
                "reverse_role": "siehe auch"
            },
            {
                "identifier": "376261-378712-benutzt f\u00fcr",
                "to_descriptor": {
                    "identifier": "54188",
                    "title": "Ciba"
                },
                "role": "benutzt f\u00fcr",
                "reverse_role": "siehe unter"
            }
        ]
    }
]

Output data triples:

<https://ld.bs.ch/ais/Descriptor/54187> <http://schema.example.org/hasName> "Ciba-Geigy AG" .
<https://ld.bs.ch/ais/Descriptor/54187> <http://schema.example.org/hasIdentifier> "54187" .
<https://ld.bs.ch/ais/Descriptor/54188> <http://schema.example.org/hasName> "Ciba" .
<https://ld.bs.ch/ais/Descriptor/54188> <http://schema.example.org/hasIdentifier> "54188" .
<https://ld.bs.ch/ais/Agent/51725> <http://schema.example.org/hasRelatedRecord> <https://ld.bs.ch/ais/Record/727741> .
<https://ld.bs.ch/ais/Agent/51725> <http://schema.example.org/hasRelatedDescriptor> <https://ld.bs.ch/ais/Descriptor/54188> .
<https://ld.bs.ch/ais/Agent/51725> <http://schema.example.org/hasRelatedDescriptor> <https://ld.bs.ch/ais/Descriptor/54187> .
<https://ld.bs.ch/ais/Agent/51725> <http://schema.example.org/hasName> "Ciba AG" .
<https://ld.bs.ch/ais/Agent/51725> <http://schema.example.org/hasIdentifier> "51725" .

Mapping:

output carml

map agent from personen_desc {
  subject template "https://ld.bs.ch/ais/Agent/{0}" with identifier;

  properties
    ex.hasIdentifier from identifier;
    ex.hasName from title;
    ex.hasRelatedRecord template "https://ld.bs.ch/ais/Record/{0}" with recordId;
    ex.hasRelatedDescriptor template "https://ld.bs.ch/ais/Descriptor/{0}" with descriptorId;
}

map descriptor from descriptor_desc {
  subject template "https://ld.bs.ch/ais/Descriptor/{0}" with identifier;

  properties
    ex.hasIdentifier from identifier;
    ex.hasName from title;
}

logical-source personen_desc {
  type json
  source "stdin"
  iterator "$..[?(@.thesaurus == 'Personenbegriffe')]"

  referenceables
    identifier
    title
    description
    recordId "records[*].id"
    descriptorId "related_descriptor_set[*].to_descriptor.identifier"
}

logical-source descriptor_desc {
  type json
  source "stdin"
  iterator "$..[?(@.thesaurus == 'Personenbegriffe')].related_descriptor_set[*]"

  referenceables
    title "to_descriptor.title"
    identifier "to_descriptor.identifier"
}

vocabulary ex {
	prefix "ex" "http://schema.example.org/"

	classes

	properties
		hasIdentifier
		hasName
		hasRelatedRecord
		hasRelatedDescriptor
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant