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

Code runs in infinite loop if base type of complex type is simple #5

Open
dhumeniuk opened this issue Sep 14, 2011 · 3 comments
Open

Comments

@dhumeniuk
Copy link

In XSDParser.parseComplexType():

At some point parent will be simple type so the loop just runs forever.

       while (parent != sset.getAnyType()) {
            if (parent.isComplexType()) {
                write(st, parent.asComplexType(), true, sset);
                parent = parent.getBaseType();
            }
        }
@thomie
Copy link

thomie commented Apr 10, 2012

Here is an example schema on which xsd2thrift gets stuck.
Jeff Murphy's clone seems to be on the way to fixing this.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="MultilingualString">
        <xs:sequence>
            <xs:element name="value" type="MultilingualStringValue" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:simpleType name="MultilingualStringValueType">
        <xs:restriction base="xs:string">
            <xs:maxLength value="1024"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="MultilingualStringValue">
        <xs:simpleContent>
            <xs:extension base="MultilingualStringValueType">
                <xs:attribute name="lang" type="xs:language"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>

@tranchis
Copy link
Owner

True, it gets into an infinite loop. Do you know how far jeffmurphy's fork has gotten so far?

@thomie
Copy link

thomie commented Apr 20, 2012

This is the protobuf output on the above xml using @jeffmurphy's fork from March 1st:

message MultilingualStringValue
{
    optional string lang = 1;
}

message MultilingualString
{
    repeated MultilingualStringValue value = 1;
}

The simpleType seems to get completely ignored, but at least it doesn't get stuck.

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

No branches or pull requests

3 participants