init: xsd

This commit is contained in:
Mylloon 2024-04-26 21:22:36 +02:00
parent 2afbeacd4f
commit f5a16d824f
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 14 additions and 2 deletions

View file

@ -8,6 +8,8 @@ Le convertisseur est [converter.py](./converter.py).
$ python converter.py l-systems.csv
```
<!-- Pour valider : xmllint --schema data.xsd fichier.xml 1>/dev/null -->
## Rapport
<!-- TODO: Push le PDF uniquement quand il est finalisé. -->

View file

@ -49,7 +49,7 @@ class System:
break
def __repr__(self):
return pformat(self.__dict__, compact=True, width=120, sort_dicts=False)
return pformat(object=self.__dict__, compact=True, width=120, sort_dicts=False)
def to_xml(self) -> XMLElement:
"""Convert the current system into an XML element"""
@ -126,8 +126,11 @@ if __name__ == "__main__":
# Generate XML
xml = lsystems_xml(lsystems)
# Add XML model declaration
xml_string = '<?xml-model href="data.xsd"?>\n' + element_stringifier(xml).decode()
# Output XML
dom = xml_parser(element_stringifier(xml))
dom = xml_parser(xml_string)
pretty_xml = dom.toprettyxml(encoding="UTF-8").decode()
if args.output:
with open(args.output, "w") as output_file:

7
data.xsd Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Root -->
<xs:element name="lsystems"></xs:element>
</xs:schema>