tefra / xsdata-pydantic

Naive XML & JSON Bindings for python pydantic classes!
https://xsdata-pydantic.readthedocs.io/
MIT License
52 stars 10 forks source link

Error parsing object with aem schema #30

Closed Awerito closed 3 months ago

Awerito commented 3 months ago

I use this schema here: https://www.leychile.cl/esquemas/EsquemaIntercambioNorma-v1-0.xsd

xsdata EsquemaIntercambioNorma-v1-0.xsd

I can't convert the result of xsdata:

"""main.py"""
import httpx
from xsdata_pydantic.bindings import XmlParser
from generated.esquema_intercambio_norma_v1_0 import Norma

def get_norma(id_norma: int) -> Norma:
    url = "https://www.leychile.cl/Consulta/obtxml?opt=7&idNorma={}".format(id_norma)
    response = httpx.get(url)
    response.raise_for_status()

    parser = XmlParser()
    norma = parser.from_string(response.text, Norma)

    return norma

if __name__ == "__main__":
    norma = get_norma(206396)  # Works fine
    norma = get_norma(194194)  # Throws error for the aem:ArchivoBinario tag

Please some help :heart: