metafacture / metafacture-core

Core package of the Metafacture tool suite for metadata processing.
https://metafacture.org
Apache License 2.0
71 stars 34 forks source link

Encode "leader" also if it's passed as one literal (#454) #526

Closed dr0i closed 5 months ago

dr0i commented 5 months ago

Resolves #454 and resolves #524.

"leader" can be given as top-level literal or as literal in an entity. This makes the claim "The stream expected by the encoder is compatible to the streams emitted by the { Marc21Decoder} and the {MarcXmlHandler}." true again.

dr0i commented 5 months ago

functional review: @TobiasNx . Deployed to test-playground. Test from https://github.com/metafacture/metafacture-core/issues/454#issuecomment-2063800461 : c) handle-marcxml -> encode-marc21 (which should work now).

Also note that we don't need to set the emitleaderaswhole explicitly for these cases: a) marc21 -> marc21 works ( just do | decode-marc21) b) marc21-> marcxml works (just do | decode-marc21)

TobiasNx commented 5 months ago

functional review: @TobiasNx . Deployed to test-playground. Test from #454 (comment) : c) handle-marcxml -> encode-marc21 (which should work now).

Also note that we don't need to set the emitleaderaswhole explicitly for these cases: a) marc21 -> marc21 works ( just do | decode-marc21) b) marc21-> marcxml works (just do | decode-marc21)

This does not seem to work yet: https://test.metafacture.org/playground/?flux=%22https%3A//raw.githubusercontent.com/metafacture/metafacture-core/master/metafacture-runner/src/main/dist/examples/read/marc21/10.marc21%22%0A%7C+open-http%0A%7C+as-lines%0A%7C+decode-marc21%0A%7C+encode-marcxml%0A%7C+print%0A%3B

decode-marc21(emitLeaderAsWhole="false")` -> encode-marcxml => the separated elements are kept:

        <marc:leader>p</marc:leader>
        <marc:leader>a</marc:leader>
        <marc:leader>m</marc:leader>
        <marc:leader> </marc:leader>
        <marc:leader>a</marc:leader>
        <marc:leader> </marc:leader>
        <marc:leader>c</marc:leader>
        <marc:leader> </marc:leader>

leader should be combined.

dr0i commented 5 months ago

decode-marc21(emitLeaderAsWhole="false")` -> encode-marcxml => the separated elements are kept:

They are kept as separated elements because you told it to do so by using (emitLeaderAsWhole="false"). If you want to have one leader string, set it to true.

TobiasNx commented 5 months ago

decode-marc21(emitLeaderAsWhole="false")` -> encode-marcxml => the separated elements are kept:

They are kept as separated elements because you told it to do so by using (emitLeaderAsWhole="false"). If you want to have one leader string, set it to true.

But this creates invalid marc xml data. I am confused. I thought encode-marcxml should behave in the same way as encode-marc21, if the data is seperated the encoder should combine them.

It creates invalid marc xml data. See the leader spec here in the schema: https://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd

TobiasNx commented 5 months ago

decode-marc21(emitLeaderAsWhole="false")` -> encode-marcxml => the separated elements are kept:

They are kept as separated elements because you told it to do so by using (emitLeaderAsWhole="false"). If you want to have one leader string, set it to true.

But this creates invalid marc xml data. I am confused. I thought encode-marcxml should behave in the same way as encode-marc21, if the data is seperated the encoder should combine them.

It creates invalid marc xml data. See the leader spec here in the schema: loc.gov/standards/marcxml/schema/MARC21slim.xsd

Discussed with @dr0i of board that I will open a new issue for this scenario. To be fixed after this PR.

So +1 from me.