blackbeam / rust-marc

Apache License 2.0
16 stars 5 forks source link

XML output always duplicates first indicator as second indicator #16

Closed rhigman closed 1 year ago

rhigman commented 1 year ago

Whenever a MARC data field is specified with two different indicators, generating MARCXML from it will always result in both indicators being identical (matching the first specified indicator).

e.g. b"0 " and b"01" will both be transformed into ind1="0" ind2="0".

Neither the generated MARC21 nor the generated MARC markup have this issue.

The cause appears to be that the logic for Indicator::first() and Indicator::second() have been defined identically, i.e. both taking the same (first) byte from the data slice:

https://github.com/blackbeam/rust-marc/blob/2a4ead409ee023430e3b734d20ce2d66e508e56c/src/indicator.rs#L20-L31

The tests in xml.rs have been set up to expect this incorrect output, and should also be changed, e.g.:

https://github.com/blackbeam/rust-marc/blob/2a4ead409ee023430e3b734d20ce2d66e508e56c/src/xml.rs#L287

where 041 field was specified above as having indicators b"0 ":

https://github.com/blackbeam/rust-marc/blob/2a4ead409ee023430e3b734d20ce2d66e508e56c/src/xml.rs#L255

blackbeam commented 1 year ago

@rhigman, thanks!