Skip to content

Commit

Permalink
chore: readme updates including example code and adding a screenshot …
Browse files Browse the repository at this point in the history
…of files named with hashes
  • Loading branch information
mcarvin8 committed Feb 21, 2024
1 parent 8d153fc commit 3fa7692
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Binary file added .github/images/disassembled-hashes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

[![NPM](https://img.shields.io/npm/v/xml-disassembler.svg?label=xml-disassembler)](https://www.npmjs.com/package/xml-disassembler) [![Downloads/week](https://img.shields.io/npm/dw/xml-disassembler.svg)](https://npmjs.org/package/xml-disassembler)

A JS package to disassemble XML files into smaller, more manageable files and re-assemble them when needed.

This package is in active development and may have bugs. Once this is deemed stable, this plugin will be released as v1.0.0.
A TS package to disassemble XML files into smaller, more manageable files and re-assemble them when needed.

## Background

Expand Down Expand Up @@ -40,6 +38,8 @@ FLAGS
- xmlPath: Directory containing the XML files to disassemble (must be directory). This will only disassemble files in the immediate directory.
- uniqueIdElements: (Optional) Comma-separated list of unique and required ID elements used to name disassembled files for nested elements. Defaults to SHA-256 hash if unique ID elements are undefined or not found.
*/
import { DisassembleXMLFileHandler } from "xml-disassembler";

const handler = new DisassembleXMLFileHandler();
await handler.disassemble({
xmlPath: "test/baselines/general",
Expand Down Expand Up @@ -102,13 +102,17 @@ An XML with the following nested and leaf elements

will be diassembled as such:

- Each nested element (`<recordTypeVisibilities>`, `<applicationVisibilities>`, `pageAccesses`, etc.) will be disassembled into sub-directories by the nested element name. If a unique & required ID element (`application` is the unique ID element for `<applicationVisibilities>`) is found, the disassembled file will be named using it.
- Each nested element (`<recordTypeVisibilities>`, `<applicationVisibilities>`, `pageAccesses`, etc.) will be disassembled into sub-directories by the nested element name. If a unique & required ID element (`application` is the unique ID element for `<applicationVisibilities>`) is found, the disassembled file will be named using it. Otherwise, the disassembled files for nested elements will be named using the SHA-256 of the element contents.
- Each leaf element (`<description>`, `<label>`, `<userLicense>`) will be disassembled into the same file.

<img src="https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled.png">

<br>

<img src="https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled-hashes.png">

<br>

### File Handlers

It is up to the user to add additional file handlers before they run the `DisassembleXMLFileHandler` class.
Expand All @@ -125,6 +129,8 @@ FLAGS
- xmlNamespace: (Optional) Namespace for the final XML (default: None)
- fileExtension: (Optional) Desired file extension for the final XML (default: `.xml`)
*/
import { ReassembleXMLFileHandler } from "xml-disassembler";

const handler = new ReassembleXMLFileHandler();
await handler.reassemble({
xmlPath: "test/baselines/general/HR_Admin",
Expand Down

0 comments on commit 3fa7692

Please sign in to comment.