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

Formally specify PICA Path expression syntax #109

Open
nichtich opened this issue Jun 23, 2021 · 2 comments
Open

Formally specify PICA Path expression syntax #109

nichtich opened this issue Jun 23, 2021 · 2 comments

Comments

@nichtich
Copy link
Member

PICA::Path should include a formal grammar of PICA Path expression syntax. The current implementation is:

    ([012.][0-9.][0-9.][A-Z@.])     # tag
    (\[([0-9.]{2,3}|\d+-\d+)\])?    # occurrence
    (\$?([_A-Za-z0-9]+))?           # subfields
    (\/(\d+)?(-(\d+)?)?)?           # position

And some additionals checks on occurrence and position ranges.

The syntax will be extended by conditions/subspects (#108) and x-counters (#97).

@nichtich
Copy link
Member Author

nichtich commented Nov 29, 2021

Based on additions and different design choices by @niko2342 in pica-rs I tried to create a common subset to unify PICA Path expression syntax. The dev branch contains a new PICA Path expression syntax that should be like this:

path             ::=  tag occurrence? subfields? position?
tag              ::=  [012.] [0-9.] [0-9.] [A-Z@.]
occurrence       ::=  "/" occurenceValue | "[" occurrenceValue "]"
occurenceValue   ::=  number "-" number | occurrencePattern | "*"
occurencePattern ::=  [0-9.] [0-9.]? [0-9.]?
subfields        ::=  [$.]? ( [A-Za-z0-9]+ | "*" )
position         ::=  "/" ( number | range ) 
range            ::=  number "-" number? | "-" number
number           ::=  [0-9]+

Some features are not supported by pica-rs yet (deutsche-nationalbibliothek/pica-rs#346) and I am not sure whether occurrence in "[...]" and positions should be part of the core syntax or optional extensions, such as making the $ or . optional before subfield codes.

The introduction of / to start occurrences is a breaking change for pathes with position but no occurrence or subfields. To reference a position across all subfields add $* to explicitly refer to all subfields (e.g. 123X$*/3-7 or 123X*/3-7 instead of 123X/3-7).

In a path without occurrence, the occurrence is set to default value zero

  • zero if first character of tag is 0 or 1 (because occurrence matters as field identifier on level 0 and 1)
  • * (or 0-999) otherwise (to match all fields with or without occurrence)

This is also a breaking change. Until version 1.34 the path expression 0123 did also match 0123/01-99.

@nichtich
Copy link
Member Author

nichtich commented Dec 3, 2021

See http://format.gbv.de/query/picapath for current state.

@nichtich nichtich removed this from the 2.0.0 milestone Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant