def length_from_str(src):
    """A simple restriction of integer:

    <xs:simpleType name="Length">
            <xs:restriction base="xs:integer">
                    <xs:maxInclusive value="32767"/>
                    <xs:minInclusive value="-32768"/>
            </xs:restriction>
    </xs:simpleType>"""
    value = int(src)
    if value < -32768 or value > 32767:
        raise ValueError('Value exceeds bounds for Length: %i' % value)
    return value
