Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(draft) dte.parse: _set_dte_xml_missing_xmlns does not support a non-root DTE XML element #42

Open
glarrain opened this issue May 14, 2019 · 0 comments
Assignees
Labels
bug Something isn't working component: dte

Comments

@glarrain
Copy link
Contributor

The following will trigger an error:

import pathlib
from cl_sii.libs import xml_utils
from cl_sii.dte.parse import _set_dte_xml_missing_xmlns, DTE_XMLNS_MAP

file_path = pathlib.Path('SET_DTE_76408488-8_33_591.xml')
envio_dte_xml_doc = xml_utils.parse_untrusted_xml(file_path.read_bytes())
assert envio_dte_xml_doc.tag == '{http://www.sii.cl/SiiDte}EnvioDTE'

set_dte_em = xml_em.find('sii-dte:SetDTE', namespaces=DTE_XMLNS_MAP)
set_dte_em = envio_dte_xml_doc.find('sii-dte:SetDTE', namespaces=DTE_XMLNS_MAP)

dte_em_list = set_dte_em.findall('sii-dte:DTE', namespaces=DTE_XMLNS_MAP)
dte_em = dte_em_list[0]

_set_dte_xml_missing_xmlns(dte_em)
Exception: ('XML root element tag does not match the expected simple or namespaced name.', 'DTE', '{http://www.sii.cl/SiiDte}DTE', '{http://www.sii.cl/SiiDte}EnvioDTE')

For a file like this one (download this example set_dte_76408488-8_33_591.xml)

<?xml version="1.0" encoding="ISO-8859-1"?>
<EnvioDTE version="1.0" xmlns="http://www.sii.cl/SiiDte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sii.cl/SiiDte EnvioDTE_v10.xsd">
<SetDTE ID="IDfc7f3b7ee3af4c078d300fd530656928">
<Caratula version="1.0">...</Caratula>
<DTE version="1.0">
<Documento ID="T33F591">...</Documento>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
</Signature>
</DTE>
</SetDTE>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
</Signature>
</EnvioDTE>
@glarrain glarrain added bug Something isn't working component: dte labels May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: dte
Projects
None yet
Development

No branches or pull requests

2 participants