Fix: Citavi XML importer now preserves citation keys (#14658)#15257
Conversation
322ef30 to
84d7a00
Compare
Previously, citation keys defined in Citavi (stored as <CitationKey> in the XML) were silently discarded during import, leaving all entries with empty citation keys. Now the importer reads the <CitationKey> element and sets it on the imported BibEntry (with whitespace stripped, as BibTeX does not allow spaces in keys).
84d7a00 to
9fa39b5
Compare
Review Summary by QodoCitavi XML importer now preserves citation keys from XML
WalkthroughsDescription• Citavi XML importer now reads and preserves citation keys from XML • Citation keys are stripped of whitespace to comply with BibTeX format • Empty or blank citation keys are ignored during import • Added comprehensive unit tests for citation key handling Diagramflowchart LR
A["Citavi XML<br/>CitationKey element"] -->|"Read element"| B["CitaviXmlImporter<br/>parseReference"]
B -->|"Extract & strip<br/>whitespace"| C["Reference record<br/>citationKey field"]
C -->|"Set on entry"| D["BibEntry<br/>with citation key"]
File Changes1. jablib/src/main/java/org/jabref/logic/importer/fileformat/CitaviXmlImporter.java
|
Code Review by Qodo
1.
|
* Strip BibTeX-disallowed characters (comma, braces, etc.) from
imported citation keys, not just whitespace
* Use Optional-based assertions instead of orElse("") sentinel
* Add test for disallowed character stripping
This comment has been minimized.
This comment has been minimized.
✅ All tests passed ✅🏷️ Commit: 1fc7f78 Learn more about TestLens at testlens.app. |
|
Your code currently does not meet JabRef's code guidelines. We use OpenRewrite to ensure "modern" Java coding practices. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Source Code Tests / OpenRewrite (pull_request)" and click on it. The issues found can be automatically fixed. Please execute the gradle task |
…rg.openrewrite.recipe-rewrite-recipe-bom-3.25.0 * upstream/main: (35 commits) Chore: add dependency-management.md (#15278) Chore(deps): Bump dev.langchain4j:langchain4j-bom in /versions (#15277) New Crowdin updates (#15274) Chore(deps): Bump actions/upload-artifact from 6 to 7 (#15271) Chore(deps): Bump actions/download-artifact from 7 to 8 (#15270) Chore(deps): Bump docker/login-action from 3 to 4 (#15268) Fix threading issues in citations relations tab (#15233) Fix: Citavi XML importer now preserves citation keys (#14658) (#15257) Preserve no break spaces in Latex to Unicode conversion (#15174) Fix: open javafx.scene.control.skin to controlsfx (#15260) Reduce complexity in dependencies setup (restore) (#15194) New translations jabref_en.properties (French) (#15256) Fix: exception dialog shows up when moving sidepanel down/up (#15248) Implement reset for Name Display Preferences (#15136) Chore(deps): Bump net.bytebuddy:byte-buddy in /versions (#15252) Chore(deps): Bump io.zonky.test.postgres:embedded-postgres-binaries-bom (#15253) Chore(deps): Bump io.zonky.test:embedded-postgres in /versions (#15254) Chore(deps): Bump net.ltgt.errorprone from 5.0.0 to 5.1.0 in /jablib (#15251) New Crowdin updates (#15247) Refined the "Select files to import" page in "Search for unlinked local files" dialog (#15110) ...
Related issues and pull requests
Closes #14658
PR Description
Previously, citation keys defined in Citavi (stored as in the XML) were silently discarded during import, leaving all entries with empty citation keys.
Now the importer reads the element and sets it on the imported BibEntry (with whitespace stripped, as BibTeX does not allow spaces in keys).
Steps to test
UI test: Import the file we added

jabref/jablib/src/test/resources/org/jabref/logic/importer/fileformat/CitaviXmlImporterTest4.ctv6bakBehavior before the fix: The citiation key is empty
Behavior after the fix: The citation key is present

Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)