Package 'tab2xml'

Title: XML Generation from Tables
Description: Converting structured data from tables into XML format using predefined templates ensures consistency and flexibility, making it ideal for data exchange, reporting, and automated workflows.
Authors: Jose Samos [aut, cre] , Universidad de Granada [cph]
Maintainer: Jose Samos <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0.9000
Built: 2025-02-27 06:28:50 UTC
Source: https://github.com/josesamos/tab2xml

Help Index


Validate and Check Spreadsheet Data

Description

This function validates the structure of a spreadsheet file by checking its sheets, primary keys (PKs), and foreign keys (FKs). If a template file is provided, it also checks the column definitions.

Usage

check_tab(file_path, template_path = NULL)

Arguments

file_path

Character. Path to the spreadsheet file to be validated.

template_path

Character (optional). Path to the template file for validation. If 'NULL', only the sheet structure is checked.

Value

Logical. Returns "TRUE" but warns of possible errors.


Convert a Spreadsheet to XML

Description

It reads a spreadsheet file (Excel or ODS), processes it using a provided XML template, and generates an XML output file.

Usage

sheet2xml(file_path, template_path, xml_path = NULL, optimize = FALSE)

Arguments

file_path

Character. Path to the spreadsheet file to be converted. Supports Excel (.xlsx) and ODS formats.

template_path

Character. Path to the XML template file to guide the transformation process.

xml_path

Character (optional). Output path for the generated XML file. If NULL, it is considered an XML file with the same name and location as the spreadsheet file.

optimize

Boolean. Remove empty nodes from the xml file.

Value

Character. The file path of the generated XML document.

Examples

source_xml <- system.file("extdata", "schema_template.xml", package = "tab2xml")

source_xlsx <- system.file("extdata", "schema.xlsx", package = "tab2xml")
temp_file1 <- tempfile(fileext = ".xml")
sheet2xml(source_xlsx, source_xml, temp_file1)

source_ods <- system.file("extdata", "schema.ods", package = "tab2xml")
temp_file2 <- tempfile(fileext = ".xml")
sheet2xml(source_ods, source_xml, temp_file2)