From f16ecab4588a1095af25189ae9a2b0ba62c050a2 Mon Sep 17 00:00:00 2001 From: perro Date: Wed, 25 Jan 2023 19:30:33 -0800 Subject: [PATCH] Ajustes --- README.md | 133 ++++++++++++++++++++++++++++++++++++------------------ yasd.py | 0 2 files changed, 88 insertions(+), 45 deletions(-) mode change 100644 => 100755 yasd.py diff --git a/README.md b/README.md index 02088d5..9cd8cc4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ ---- -warn: This is just a prototype. ---- +\[TOC\] # YASD, Yet Another Schema Definition @@ -8,6 +6,36 @@ YASD is a YAML format for human writable XSDs (XML Schema Definition), humans declare what is indispensable, leaving the machines to do the rest of the unreadable ``. +## Workflow + +The following chart is the YASD CLI flow: + +``` mermaid +flowchart LR + direction LR + yasd --- convert + yasd --- check + yasd --- sample + yasd --- document + yasd --- man + convert --- |from| YASD1([YASD]) + YASD1 --> |to| XSD([XSD]) + check --- |validates| YASD2([YASD]) + sample --- |from| YASD3([YASD]) + YASD3 --> |to| XML([XML]) + document --- |from| YASD4([YASD]) + YASD4 --> |to| MD([Markdown]) + man --- |prints| README +``` + +## Example + +To better understad what YASD does, see the inputs and outputs: + +- Input: human workable schema in [YASD]. +- Output: computer processable schema in [XSD]. +- Output: human readable documentation in [Markdown]. + ## Structure General structure: @@ -77,27 +105,27 @@ Group (GRPS) structure: ## Reference -### `elementFormDefault`[^1] +### `elementFormDefault`[^1] {#elementformdefault1} Indicates that any elements used by the XML instance document which were declared in this schema must be namespace qualified. Optional; if not present by default is `unqualified`. -### `taget_namespace`[^1] +### `taget_namespace`[^2] {#taget_namespace1} Indicates that the elements defined by this schema come from the specified URL namespace. Optional. -### `xmlns`[^1] +### `xmlns`[^3] {#xmlns1} Indicates that the default namespace is the specified URL. Mandatory. -### `schemaLocation`[^1] +### `schemaLocation`[^4] {#schemalocation1} Indicates the location of the XML schema to use for that namespace. @@ -122,7 +150,8 @@ Naming rules: - Element names are case-sensitive - Element names must start with a letter or underscore - Element names cannot start with the letters xml (or XML, or Xml, etc) -- Element names can contain letters, digits, hyphens, underscores, and periods +- Element names can contain letters, digits, hyphens, underscores, and + periods - Element names cannot contain spaces ### `description` @@ -147,19 +176,19 @@ Allowed types: Chart: -|type | children elements | text node | attributes | -|------------|:-----------------:|:----------:|:----------:| -|simple | ✗ | ✓ | ✗ | -|empty | ✗ | ✗ | ✓ | -|no_text | ✓ | ✗ | ✓ | -|no_elements | ✗ | ✓ | ✓ | -|mixed | ✓ | ✓ | ✓ | +| type | children elements | text node | attributes | +|------------|:-----------------:|:---------:|:----------:| +|simple | ✗ | ✓ | ✗ | +|empty | ✗ | ✗ | ✓ | +|no_text | ✓ | ✗ | ✓ | +|no_elements | ✗ | ✓ | ✓ | +|mixed | ✓ | ✓ | ✓ | > **Note**: attributes are never mandatory; they could be zero or more. ### `datatype` -Indicates element or attribute data types.[^2] +Indicates element or attribute data types.[^5] Only mandatory for 'simple' and 'no_elements' elements, and attributes. @@ -169,8 +198,8 @@ Allowed String Data Types: - `ENTITY`.   - `ID`. A string that represents the ID attribute in XML (only used with schema attributes). -- `IDREF`. A string that represents the IDREF attribute in XML (only used with - schema attributes). +- `IDREF`. A string that represents the IDREF attribute in XML (only used + with schema attributes). - `IDREFS`. - `language`. A string that contains a valid language id. - `Name`. A string that contains a valid XML name. @@ -247,7 +276,7 @@ Optional. Only `required` is valid as value. -### `restriction`[^3] +### `restriction`[^6] {#restriction3} Indicates accepted constrained values for element or attribute. @@ -275,8 +304,8 @@ Allowed constrains: - `minLength`. Specifies the minimum number of characters or list items allowed; must be equal to or greater than zero. - `pattern`. Defines the exact sequence of characters that are acceptable. -- `totalDigits`. Specifies the exact number of digits allowed; must be greater - than zero. +- `totalDigits`. Specifies the exact number of digits allowed; must be + greater than zero. - `whiteSpace`. Specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled; accepted values are `preserve|replace|collapse`. @@ -340,8 +369,8 @@ Optional; if not present by default is `false`. Allowed values: -- `true`. -- `false`. +- `true`. +- `false`. ### `elements` @@ -363,37 +392,51 @@ Mandatory. ## Command-Line Interface -``` -usage: yasd [-h] [-q] [-l] [-n NUM] {convert,check,sample,document,man} [file] + usage: yasd [-h] [-q] [-l] [-n NUM] {convert,check,sample,document,man} [file] -YASD, Yet Another Schema Definition. YASD is a YAML format for human writable -XSDs (XML Schema Definition), humans declare what is indispensable, leaving -the machines to do the rest of the unreadable . + YASD, Yet Another Schema Definition. YASD is a YAML format for human writable + XSDs (XML Schema Definition), humans declare what is indispensable, leaving + the machines to do the rest of the unreadable . -positional arguments: - {convert,check,sample,document,man} - action to perform - file file in YAML format + positional arguments: + {convert,check,sample,document,man} + action to perform + file file in YAML format -options: - -h, --help show this help message and exit - -q, --quiet enable quiet mode - -l, --log write log - -n NUM, --num NUM number of XML samples; 1 by default + options: + -h, --help show this help message and exit + -q, --quiet enable quiet mode + -l, --log write log + -n NUM, --num NUM number of XML samples; 1 by default -(c) 2023 Perro Tuerto . Founded by Mexican Academy of -Language . Licensed under GPLv3 -. -``` + (c) 2023 Perro Tuerto . Founded by Mexican Academy of + Language . Licensed under GPLv3 + . [^1]: The following explanation is practically a copy-paste from "XSD - The - Element", W3Schools. Cfr. + ``{=html} Element", W3Schools. Cfr. . -[^2]: The following explanation is practically a copy-paste from "XSD Data +[^2]: The following explanation is practically a copy-paste from "XSD - The + ``{=html} Element", W3Schools. Cfr. + . + +[^3]: The following explanation is practically a copy-paste from "XSD - The + ``{=html} Element", W3Schools. Cfr. + . + +[^4]: The following explanation is practically a copy-paste from "XSD - The + ``{=html} Element", W3Schools. Cfr. + . + +[^5]: The following explanation is practically a copy-paste from "XSD Data Types", W3Schools. Cfr. . -[^3]: The following explanation is practically a copy-paste from "XSD +[^6]: The following explanation is practically a copy-paste from "XSD Restrictions/Facets", W3Schools. Cfr. . + + [YASD]: https://gitlab.com/amlengua/apal/esquema/-/blob/main/apal.yaml + [XSD]: https://gitlab.com/amlengua/apal/esquema/-/blob/main/apal.xsd + [Markdown]: https://gitlab.com/amlengua/apal/esquema/-/blob/main/apal.md diff --git a/yasd.py b/yasd.py old mode 100644 new mode 100755