Skip to content

devasudanT/transfer_verses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Bible Verse Transfer Script

This Python script facilitates the transfer of Bible verses from one XML file to another while preserving the hierarchical structure and formatting. It's designed to work with XML files that follow a specific structure of testament > book > chapter > verse.

Features

  • Preserves XML hierarchy and structure
  • Maintains verse attributes during transfer
  • Performs verse count validation
  • Handles XML parsing errors gracefully

How It Works

The script follows these steps to transfer verses:

  1. XML Loading: Loads both input and output XML files using ElementTree
  2. Hierarchical Traversal: Iterates through the XML structure in parallel
  3. Verse Transfer: Copies verse text while preserving attributes
  4. Validation: Verifies the total number of verses transferred (expected: 31,102)

Process Flow

graph TD
    A[Load Input XML] --> C{Parse Successful?}
    B[Load Output XML] --> C
    C -->|Yes| D[Traverse XML Structure]
    C -->|No| E[Error Handling]
    D --> F[Testament Level]
    F --> G[Book Level]
    G --> H[Chapter Level]
    H --> I[Verse Level]
    I --> J[Transfer Verse Text]
    J --> K[Update Count]
    K --> L{All Verses Done?}
    L -->|No| I
    L -->|Yes| M[Save Output XML]
    M --> N[Verify Verse Count]
Loading

XML Structure

graph TD
    A[XML Root] --> B[Testament]
    B --> C[Book]
    C --> D[Chapter]
    D --> E[Verse]
    E --> F[Verse Text & Attributes]
Loading

Usage

  1. Prepare your input XML file (input-bible.xml) with the source verses
  2. Create an output XML file (output-file.xml) with the desired structure
  3. Run the script:
    python transfer_verses.py
  4. The script will transfer verses and display the results

Requirements

  • Python 3.x
  • xml.etree.ElementTree (built-in Python library)

Functions

load_xml(file_path)

  • Loads and parses XML file
  • Returns root element or None if error occurs
  • Handles parsing and file not found errors

transfer_verses(input_root, output_root)

  • Traverses XML structure in parallel
  • Transfers verse text while preserving attributes
  • Returns total number of verses transferred

main()

  • Orchestrates the overall process
  • Performs validation and error checking
  • Displays transfer statistics

Validation

The script includes built-in validation:

  • Verifies successful XML parsing
  • Counts total verses transferred
  • Compares against expected verse count (31,102)
  • Warns if verse count doesn't match expected total

Error Handling

The script handles common errors:

  • XML parsing errors
  • Missing input/output files
  • Structure mismatches
  • Invalid XML format

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages