Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Invalid XML can be generated with extension elements #115

Open
fteule opened this issue May 17, 2019 · 2 comments
Open

Invalid XML can be generated with extension elements #115

fteule opened this issue May 17, 2019 · 2 comments

Comments

@fteule
Copy link

fteule commented May 17, 2019

PyXB can generate an invalid xml file without any error if you use an extended element instead of the base element (see sample in attachment).

In the sample, I have 2 complexTypes, with templateExt an extension of template:

    <xs:complexType name="templateExt">
        <xs:complexContent>
            <xs:extension base="template">
                <xs:sequence>
                    <xs:element name="Filter" type="filterName"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

From the generated bindings, if you use templateExt instead of template you will be able to generate the xml file. But if you try to read the generated xml with the same binding, an exception will be raised (normal because xml is really invalid).

Bindings have been generated by pyxbgen like this:
pyxbgen -u pyxb.xsd -m mybinding

BugPyXB.zip

@pabigot
Copy link
Owner

pabigot commented May 17, 2019

This is almost certainly #32 and you're using an old version of PyXB.

With the current next branch the generation for not_correct.xml includes the necessary tag to identify the content type:

<?xml version="1.0" ?>
<MyRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<el1 xsi:type="templateExt">
...
</MyRoot>

The xsi:type tag is missing from the el1 in the output you provided.

Your reproducer (and thank you for providing one) works correctly with the current next version.

Please confirm what PyXB version you're using. If it's not at least 1.2.5 this should be closed.

@fteule
Copy link
Author

fteule commented May 17, 2019 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants