Skip to main content

Crate zotero_rdf

Crate zotero_rdf 

Source
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
ErrorLocation
Location information during parsing
Extractor
RDF graph extractor for converting raw RDF data into structured ZoteroItem instances
Graph
An in-memory RDF graph.
Journal
Represents journal information
ParseOptions
Parse options controlling error handling behavior
ParseStats
Parsing statistics
ZoteroItem
Represents a Zotero item (journal article, book, etc.)

Enums§

ZoteroRdfError
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