CDISC Define-XML v2.1 utilities
Project description
defineutils
CDISC Define-XML v2.1 utilities
The defineutils package currently includes 2 modules:
definehtml.py: transforms a define.xml into a define.html using the stylesheetvalidate.py: schema validates a define.xml file
The definehtml.py module includes the Define-XML v2.1 style sheet to simplify usage. It generates a define.html file,
or alternatively will generate an HTML string.
The validate.py module includes the Define-XML v2.1 schema to simplify usage. It schema validates a define.xml file
and returns a define.xml is valid message to indicate success, or a detailed message documenting the schema validation
issues.
Using defineutils
Currently, defineutils contains 2 modules, one for generating an HTML rendition and one for schema validation.
Example code used to generate a define.html from a define.xml:
from pathlib import Path
from definehtml.definehtml import DefineHtml, DefineHtmlGenerationError
out_file = Path(__file__).parent.joinpath("define.html")
dh = DefineHtml(Path(__file__).parent.joinpath("define.xml"))
dh.transform_to_html_file(out_file)
The above code applies the Define-XML v2.1 stylesheet to the define.xml to generation the define.html file. The stylesheet is embedded in the module. For error handling, use the custom DefineHtmlGenerationError exception.
Example code used to schema validate a define.xml:
from pathlib import Path
from validate.validate import DefineSchemaValidator, DefineSchemaValidationError
validator = DefineSchemaValidator(Path(__file__).parent.joinpath("define.xml"))
try:
result = validator.validate_define_file()
except DefineSchemaValidationError as e:
print(e)
The above code schema validates the specified define.xml file. The Define-XML v2.1 schema is embedded into the module. The schema validation errors are reported via the DefineSchemaValidationError exception.
Running defineutils from the Command-line
When you run a module with the -m switch it will execute the defineutils modules from the command-line. For example, to transform a define.xml file into HTML using the stylesheet, the following command-line example executes the module to generate define.html. The -m parameter instructs Python to run the module as an application. The definehtml program uses the -d parameter to specify the define.xml file path, and the -o to specify the define.html file path.
python3 -m definehtml -d tests/define.xml -o tests/define.html
The validate command can be executed using the command-line the same way. For validate, only the -d parameter is required to indicate the file path of the define.xml to validate.
python3 -m validate -d tests/define.xml
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file defineutils-0.1.0.tar.gz.
File metadata
- Download URL: defineutils-0.1.0.tar.gz
- Upload date:
- Size: 59.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
771603b8cde5e5705b0faa9dea25feb21a88311790ac039da88f6546987a3c26
|
|
| MD5 |
0d1254139b636e4943979a02fda1d1d2
|
|
| BLAKE2b-256 |
89bcb14bf73b3805f5a8a1d2333d2944d7716371279554c91e4c561808aff2fb
|
File details
Details for the file defineutils-0.1.0-py3-none-any.whl.
File metadata
- Download URL: defineutils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 65.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e01eb2394b7fa28faac98a4c00a19b5442b82bf432aca924502316a29b7daa0
|
|
| MD5 |
aa87cee452c9dfa6f85aac3015ff132b
|
|
| BLAKE2b-256 |
2e79c7eb0e647d17a5d5de9400ace20ab8109cb29b2b2dfb304a8e04f692589a
|