kizzx2 / sbe-python

Easy-to-use Python SBE decoder and encoder
https://pypi.org/project/sbe
MIT License
18 stars 15 forks source link

AssertionError: Unknown tag 'ref' #2

Closed orbli closed 1 year ago

orbli commented 2 years ago

Hello

I think it does not support referencing custom data type. The xml i fail to parse is here:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
                   package="proper.market.api"
                   id="1"
                   version="1"
                   semanticVersion="1.0"
                   description="for market data transfer"
                   byteOrder="littleEndian">
    <types>
        <composite name="messageHeader" description="Message identifiers and length of message root">
            <type name="blockLength" primitiveType="uint16"/>
            <type name="templateId" primitiveType="uint16"/>
            <type name="schemaId" primitiveType="uint16"/>
            <type name="version" primitiveType="uint16"/>
        </composite>

        <enum name="innerthing" encodingType="uint8" description="trading exchange">
            <validValue name="value0">0</validValue>
            <validValue name="value1">1</validValue>
        </enum>
        <composite name="something">
            <ref name="innerthing" type="innerthing"/>
        </composite>
    </types>
    <sbe:message name="someMsg" id="1">
        <field name="something" id="1" type="something"/>
    </sbe:message>

</sbe:messageSchema>
threewholefish commented 2 years ago

This is a limitation of SBE, not of the parser. Any custom type must be made up of type elements, which in turn may only be one of the primitiveTypes.

You can read more about it here.

orbli commented 2 years ago

Although I agree with you when reading section about composite, I think also from the link I have read some examples that composite does have some child tag of ref. Attached with what I see:

image

threewholefish commented 2 years ago

I hadn't seen that, I stand corrected!

orbli commented 2 years ago

just for extra piece of information, i would stick with xsd here: https://github.com/real-logic/simple-binary-encoding/blob/master/sbe-tool/src/main/resources/fpl/sbe.xsd , in case you didnt notice