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

Scenario Selective Inheritance support #212

Open
wants to merge 4 commits into
base: v1-1-RC2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 148 additions & 4 deletions repository/src/main/resources/xsd/repositorytypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@
</xs:simpleType>
<xs:complexType name="codeSetType">
<xs:sequence>
<xs:element name="code" type="fixr:codeType" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice maxOccurs="unbounded">
<xs:element name="code" type="fixr:codeType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="codeUndef" type="fixr:codeUndefType"/>
</xs:choice>
<xs:element name="annotation" type="fixr:annotation" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="fixr:oidGrp"/>
Expand Down Expand Up @@ -167,13 +170,13 @@
<xs:documentation>The XML processor will remove line feeds, carriage returns, tabs, leading and trailing spaces, and multiple spaces. However, single internal spaces are allowed. May be further restricted by an external style.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="sort" type="xs:nonNegativeInteger">
<xs:attribute name="group" type="xs:string">
<xs:annotation>
<xs:documentation>Sort and group may be used to organize visualization of a code set.</xs:documentation>
<xs:documentation>Group may be used to organize visualization of a code set.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="group" type="xs:string"/>
<xs:attributeGroup ref="fixr:entityAttribGrp"/>
<xs:attributeGroup ref="fixr:positionRefGrp"/>
</xs:complexType>
<xs:simpleType name="CompID_t">
<xs:restriction base="xs:positiveInteger">
Expand Down Expand Up @@ -209,6 +212,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="fixr:positionRefTypedGrp"/>
</xs:complexType>
<xs:complexType name="componentRuleType">
<xs:sequence>
Expand All @@ -231,6 +235,9 @@
<xs:element name="componentRef" type="fixr:componentRefType"/>
<xs:element name="groupRef" type="fixr:groupRefType"/>
<xs:element name="fieldRef" type="fixr:fieldRefType"/>
<xs:element name="componentUnref" type="fixr:componentUnrefType"/>
<xs:element name="groupUnref" type="fixr:groupUnrefType"/>
<xs:element name="fieldUnref" type="fixr:fieldUnrefType"/>
</xs:choice>
<xs:element name="annotation" type="fixr:annotation" minOccurs="0"/>
</xs:sequence>
Expand Down Expand Up @@ -417,6 +424,53 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="fixr:positionRefTypedGrp"/>
</xs:complexType>
<xs:complexType name="codeUndefType">
<xs:sequence>
<xs:element name="annotation" type="fixr:annotation" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id" type="fixr:id_t">
<xs:annotation>
<xs:documentation>Identifier of a code to undefine</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="elementUnrefType">
<xs:sequence>
<xs:element name="annotation" type="fixr:annotation" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id" type="fixr:id_t">
<xs:annotation>
<xs:documentation>Identifier of an element to unreference</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="scenarioId" type="fixr:id_t">
<xs:annotation>
<xs:documentation>Identifier of a scenario of an element to unreference</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="instanceName" type="fixr:Name_t">
<xs:annotation>
<xs:documentation>Optional instance name if a reference to remove has it's name overridden.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="fieldUnrefType">
<xs:complexContent>
<xs:extension base="fixr:elementUnrefType"/>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="groupUnrefType">
<xs:complexContent>
<xs:extension base="fixr:elementUnrefType"/>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="componentUnrefType">
<xs:complexContent>
<xs:extension base="fixr:elementUnrefType"/>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="fieldRuleType">
<xs:sequence>
Expand Down Expand Up @@ -556,6 +610,9 @@
<xs:element name="componentRef" type="fixr:componentRefType"/>
<xs:element name="groupRef" type="fixr:groupRefType"/>
<xs:element name="fieldRef" type="fixr:fieldRefType"/>
<xs:element name="componentUnref" type="fixr:componentUnrefType"/>
<xs:element name="groupUnref" type="fixr:groupUnrefType"/>
<xs:element name="fieldUnref" type="fixr:fieldUnrefType"/>
</xs:choice>
<xs:element name="annotation" type="fixr:annotation" minOccurs="0"/>
</xs:sequence>
Expand Down Expand Up @@ -717,6 +774,9 @@
<xs:element name="componentRef" type="fixr:componentRefType"/>
<xs:element name="groupRef" type="fixr:groupRefType"/>
<xs:element name="fieldRef" type="fixr:fieldRefType"/>
<xs:element name="componentUnref" type="fixr:componentUnrefType"/>
<xs:element name="groupUnref" type="fixr:groupUnrefType"/>
<xs:element name="fieldUnref" type="fixr:fieldUnrefType"/>
</xs:choice>
<xs:attribute name="which" type="fixr:memberType"/>
</xs:complexType>
Expand Down Expand Up @@ -790,7 +850,91 @@
<xs:documentation>Unique identifier of a scenario. Default is '1' for base scenario.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="inheritsScenarioId" type="fixr:id_t">
<xs:annotation>
<xs:documentation>An identifier of a scenario to inherit from.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:attributeGroup name="positionRefGrp">
<xs:annotation>
<xs:documentation>The reference to a message element used while positioning additions</xs:documentation>
</xs:annotation>
<xs:attribute name="position" type="fixr:positionType_t">
<xs:annotation>
<xs:documentation>Where the new element should be placed, e.g., before the referenced element</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="positionRefId" type="fixr:id_t">
<xs:annotation>
<xs:documentation>The identifier of the referenced element</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="positionRefScenarioId" type="fixr:id_t" default="1">
<xs:annotation>
<xs:documentation>The identifier of the scenario of the referenced element. Default is '1' for base scenario.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:attributeGroup name="positionRefTypedGrp">
<xs:annotation>
<xs:documentation>The reference to a message element used while positioning additions</xs:documentation>
</xs:annotation>
<xs:attributeGroup ref="fixr:positionRefGrp"/>
<xs:attribute name="positionRefType" type="fixr:positionRefType_t">
<xs:annotation>
<xs:documentation>The type of the referenced element (component, group, or field)</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="positionRefInstanceName" type="fixr:Name_t">
<xs:annotation>
<xs:documentation>The instanceName of the reference</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:simpleType name="positionType_t">
<xs:restriction base="xs:string">
<xs:enumeration value="first">
<xs:annotation>
<xs:documentation>Place first.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="after">
<xs:annotation>
<xs:documentation>Place after the referenced element</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="before">
<xs:annotation>
<xs:documentation>Place before the referenced element</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="last">
<xs:annotation>
<xs:documentation>Place last</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="positionRefType_t">
<xs:restriction base="xs:string">
<xs:enumeration value="field">
<xs:annotation>
<xs:documentation>The referenced element is a field</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="component">
<xs:annotation>
<xs:documentation>The referenced element is a component</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="group">
<xs:annotation>
<xs:documentation>The referenced element is a group</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="presence_t">
<xs:restriction base="xs:string">
<xs:enumeration value="optional">
Expand Down
3 changes: 3 additions & 0 deletions repository/src/test/resources/examples/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ Some features to note:
* An orderAck response of NewOrderSingle starts an expiration timer for the accepted order. When the timer fires, it triggers Expired transition in the OrderState state machine.
* The attribute `which="oneOf"` on a component indicates that exactly one of its members must be present.

## scenario_inheritance.xml

This example shows scenario selective inheritance, which is used to define variations of entities.
2 changes: 1 addition & 1 deletion repository/src/test/resources/examples/mit_2016.xml

Large diffs are not rendered by default.

156 changes: 156 additions & 0 deletions repository/src/test/resources/examples/scenario_inheritance.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<fixr:repository xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:fixr="http://fixprotocol.io/2023/orchestra/repository"
xsi:schemaLocation="http://fixprotocol.io/2023/orchestra/repository ../../../main/resources/xsd/repository.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="FIX.Latest_EP282" name="FIX.Latest">

<fixr:messages>
<!-- The base scenario of a message -->
<fixr:message msgType="D" id="14" name="NewOrderSingle">
<fixr:structure>
<fixr:fieldRef id="11" name="ClOrdID"/>
<fixr:fieldRef id="55" name="Symbol"/>
<fixr:fieldRef id="54" name="Side"/>
<fixr:fieldRef id="40" name="OrdType"/>
<fixr:fieldRef id="40" name="OrdType" instanceName="OrdType2"/>
<fixr:fieldRef id="38" name="OrderQty"/>
<fixr:fieldRef id="44" name="Price"/>
<fixr:componentRef id="1012" name="Parties">
<fixr:annotation>
<fixr:documentation purpose="SYNOPSIS">Parties component description</fixr:documentation>
</fixr:annotation>
</fixr:componentRef>
<fixr:fieldRef id="1" name="Account" scenarioId="2"/>
</fixr:structure>
</fixr:message>

<fixr:message msgType="D" id="14" name="NewOrderSingle" scenario="A" scenarioId="2" inheritsScenarioId="1">
<!-- At this point the scenario A is the same as base -->
</fixr:message>

<!-- Remove elements -->
<fixr:message msgType="D" id="14" name="NewOrderSingle" scenario="B" scenarioId="3" inheritsScenarioId="1">
<fixr:structure>
<fixr:fieldUnref id="40" instanceName="OrdType2"/>
<fixr:componentUnref id="1012"/>
</fixr:structure>
</fixr:message>

<!-- Change elements -->
<fixr:message msgType="D" id="14" name="NewOrderSingle" scenario="C" scenarioId="4" inheritsScenarioId="1">
<fixr:structure>
<!-- Change optional field to required -->
<fixr:fieldRef id="44" name="Price" presence="required"/>

<!-- Change scenario of component, also change synopsis -->
<fixr:componentRef id="1012" scenarioId="2">
<fixr:annotation>
<fixr:documentation purpose="SYNOPSIS">Specific Parties component description</fixr:documentation>
</fixr:annotation>
</fixr:componentRef>
</fixr:structure>
</fixr:message>

<!-- Add elements -->
<fixr:message msgType="D" id="14" name="NewOrderSingle" scenario="D" scenarioId="5" inheritsScenarioId="1">
<fixr:structure>
<!-- After the specified field -->
<fixr:fieldRef id="20002" name="Client2UDF" position="after" positionRefType="field" positionRefId="44"/>

<!-- After the specified field, refining the name -->
<fixr:fieldRef id="20003" name="Client2KLC" position="after" positionRefType="field" positionRefId="40" positionRefInstanceName="OrdType2"/>

<!-- Before the specified field, which references the scenario -->
<fixr:fieldRef id="20013" name="Client2NAC" position="before" positionRefType="field" positionRefId="1" positionRefScenarioId="2"/>

<!-- Before the specified component -->
<fixr:fieldRef id="20009" name="Client2IDK" position="before" positionRefType="component" positionRefId="1012"/>

<!-- After Price in this order -->
<fixr:fieldRef id="20027" name="NewField1" position="after" positionRefType="field" positionRefId="44"/>
<fixr:fieldRef id="20028" name="NewField2" position="after" positionRefType="field" positionRefId="44"/>
<fixr:fieldRef id="20029" name="NewField3" position="after" positionRefType="field" positionRefId="44"/>

<!-- At the very beginning of the message (container) -->
<fixr:fieldRef id="20010" name="Client2ADK" position="first"/>

<!-- At the very end of the message (container) -->
<fixr:fieldRef id="20011" name="Client2DKE" position="last"/>

<!-- This is the same as the one above, adding the field to the end of the message
<fixr:fieldRef id="20011" name="Client2DKE"/>
-->
</fixr:structure>
</fixr:message>

<!-- Replace elements -->
<fixr:message msgType="D" id="14" name="NewOrderSingle" scenario="E" scenarioId="6" inheritsScenarioId="1">
<fixr:structure>
<fixr:fieldUnref id="44"/>
<fixr:fieldRef id="66" position="after" positionRefType="field" positionRefId="38"/>
</fixr:structure>
</fixr:message>

<fixr:message msgType="D" id="14" name="NewOrderSingle" scenario="F" scenarioId="7" inheritsScenarioId="1">
<fixr:structure>
<fixr:fieldRef id="44" scenarioId="2" presence="required"/>
</fixr:structure>
</fixr:message>
</fixr:messages>

<fixr:codeSets>
<fixr:codeSet type="char" id="13" name="CommTypeCodeSet">
<fixr:code value="1" id="13001" name="PerUnit"/>
<fixr:code value="2" id="13002" name="Percent"/>
<fixr:code value="3" id="13003" name="Absolute"/>
<fixr:code value="4" id="13004" name="BasisPoints"/>
<fixr:code value="5" id="13005" name="AmountPerContract"/>
</fixr:codeSet>

<fixr:codeSet type="char" id="13" name="CommTypeCodeSet" scenario="A" scenarioId="2" inheritsScenarioId="1">
<fixr:codeUndef id="13004"/>
<fixr:code value="11" id="13011" name="PerBond" position="after" positionRefId="13001"/>
</fixr:codeSet>
</fixr:codeSets>

<fixr:fields>
<fixr:field name="Symbol" type="String" id="55">
<fixr:annotation>
<fixr:documentation purpose="SYNOPSIS">
Ticker symbol.
</fixr:documentation>
</fixr:annotation>
</fixr:field>

<fixr:field name="Symbol" id="55" codeSet="CommTypeCodeSet" implLength="4" scenario="A" scenarioId="2" inheritsScenarioId="1">
<fixr:annotation>
<fixr:documentation purpose="SYNOPSIS">
Four-character ticker symbol.
</fixr:documentation>
</fixr:annotation>
</fixr:field>
</fixr:fields>

<fixr:datatypes>
<fixr:datatype name="String"></fixr:datatype>
</fixr:datatypes>

<fixr:scenarios>
<fixr:scenario id="1" name="base"/>
<fixr:scenario id="2" name="A"/>
<fixr:scenario id="3" name="B"/>
<fixr:scenario id="4" name="C"/>
<fixr:scenario id="5" name="D"/>
<fixr:scenario id="6" name="E"/>
<fixr:scenario id="7" name="F"/>
</fixr:scenarios>

<fixr:concepts></fixr:concepts>
<fixr:categories></fixr:categories>
<fixr:actors></fixr:actors>
<fixr:groups></fixr:groups>
<fixr:sections></fixr:sections>
<fixr:annotation><fixr:documentation></fixr:documentation></fixr:annotation>
<fixr:metadata></fixr:metadata>
</fixr:repository>
Loading