FIXTradingCommunity / fix-simple-binary-encoding

A FIX standard for binary message encoding
Other
253 stars 67 forks source link

Common message parts in different projects #91

Closed puiuvlad closed 5 years ago

puiuvlad commented 6 years ago

Hi,

Here is my use case:

Project A defines a set of messages with a common base (BasePub is a <types><composite> that is referenced in every <sbe:message> object in project A).

Project B which depends on A and uses the objects defined in A adds new messages that have the same base BasePub. Project A does not need to be aware of Project B objects, and project B need only be aware of the 'common' objects.

Is there a way to generate the objects of project B without copying all the common objects from project A in B's schema, maybe via an include? (It appears that the SBE tool is able to generate codecs from a single schema.xml file.)

Thanks, Vladimir

donmendelson commented 6 years ago

I agree that you should be able to reuse standard definitions rather than reinvent the wheel for every SBE message schema. That in fact was the motivation for allowing multiple <types> elements in the XML schema.

So far, we have left it up to users to compose the XML infoset to be parsed according to their own methodology. Possible solutions are W3C standards XInclude and XPointer. Here's an article that discusses both: Combining XML Documents with XInclude. XPointer is not common but is used in Extensible Business Reporting Language (XBRL).

puiuvlad commented 6 years ago

XInclude seems to require additional coding and each user will be forced to reinvent the wheel :-). I was thinking of an sbe include element similar to Spring’s import.

There is an additional level of complexity related to the package in which the codecs are generated. It would be nice if the common objects were generated in a common package, project A objects in a project A package, and so on.

donmendelson commented 6 years ago

An outline of XInclude for a message schema is as follows. The result is a single XML infoset that can theoretically be passed to a SBE application. Note that some XML processors have a switch to enable XInclude processing, and whether this works with your application is implementation dependent.

Base file

<?xml version="1.0" encoding="UTF-8"?>
<sbe:messageSchema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xi="http://www.w3.org/2001/XInclude" version="0" 
xmlns:sbe="http://fixprotocol.io/2017/sbe"
xsi:schemaLocation="http://fixprotocol.io/2017/sbe sbe.xsd">
    <types>
        <type name="A" primitiveType="char"/>
    </types>
    <xi:include href="standard-types.xml" parse="xml"/>
    <sbe:message name="A" id="65535"/>
</sbe:messageSchema>

Included file

<?xml version="1.0" encoding="UTF-8"?>
<types>
    <type name="B" primitiveType="uint8"/>
</types>