Expand description
§zotero-rdf
A Rust library for parsing Zotero RDF/XML export files.
§Overview
This library provides a simple and efficient way to parse Zotero library exports in RDF/XML format. It extracts structured bibliographic data including authors, DOIs, abstracts, and attachments.
§Quick Start
use zotero_rdf::{parse_file, Extractor};
// Parse a Zotero RDF export file
let graph = parse_file("my_library.rdf")?;
// Extract structured items
let extractor = Extractor::new(&graph);
let items = extractor.extract_all();
for item in items {
println!("Title: {:?}", item.title);
println!("Authors: {}", item.authors.iter()
.map(|a| a.display_name())
.collect::<Vec<_>>()
.join(", "));
}§Logging
The library uses tracing for structured logging. To see what’s happening during parsing:
ⓘ
use tracing_subscriber;
// Initialize logging (default: info level)
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"))
)
.init();
// Set RUST_LOG=debug for more verbose output§Log Levels
INFO: Key operations (file parsing, item extraction, completion stats)DEBUG: Detailed info (each item extracted, attachment counts)TRACE: Most verbose (each author, each attachment extraction)
Structs§
- Attachment
- Represents attachment information (PDFs, etc.)
- Author
- Represents author information
- Error
Location - Location information during parsing
- Extractor
- RDF graph extractor for converting raw RDF data into structured
ZoteroIteminstances - Graph
- An in-memory RDF graph.
- Journal
- Represents journal information
- Parse
Options - Parse options controlling error handling behavior
- Parse
Stats - Parsing statistics
- Zotero
Item - Represents a Zotero item (journal article, book, etc.)
Enums§
- Zotero
RdfError - Zotero RDF parsing error types
Constants§
- DEFAULT_
BASE_ IRI - Default base IRI for resolving relative IRIs in Zotero export files
Functions§
- parse_
file - Parses a Zotero RDF file from a file path into an in-memory graph
- parse_
file_ with_ base - Parses a Zotero RDF file from a file path with a specified base IRI
- parse_
file_ with_ options - Parses a file with custom options
- parse_
file_ with_ options_ and_ base - Parses a file with custom options and base IRI
- parse_
file_ with_ stats - Parses a file and returns detailed statistics
- parse_
reader - Parses RDF from any Reader (core logic)
- parse_
reader_ with_ base - Parses RDF from any Reader with a specified base IRI
- parse_
reader_ with_ options - Parses RDF from a Reader with custom options
- parse_
reader_ with_ stats - Parses from a Reader and returns detailed statistics