This tool enables converting FIX message to FIXML and vice versa. The following sample code demonstrates how simple it is.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | final Engine engine = Engine.init(); final FixmlConverter converter = new FixmlConverter( "sample/schema/fixml-main-4-4.xsd" , Version.FIX44); // final String inFixFile = "site/Order.txt" ; LOG.info( "Loading FIX message from file: {}" , inFixFile); final Message inFixMessage = Utils.readFixMessage(inFixFile); LOG.info( "Input FIX message: {}" , inFixMessage); final String fixmlMessage = converter.fix2fixml(inFixMessage); LOG.info( "Output converted FIXML message: {}" , fixmlMessage); // final String inFixmlFile = "site/ExecRpt.xml" ; LOG.info( "Loading FIXML message from file: {}" , inFixmlFile); final String inFixmlMessage = Utils.readFixmlMessage(inFixmlFile); LOG.info( "Input FIXML message: {}" , inFixmlMessage); final Message outFixMessage = converter.fixml2fix(fixmlMessage); LOG.info( "Output converted FIX message: {}" , outFixMessage); // engine.shutdown(); |
FixmlConverter class has the second constructor with the schemaPath parameter. This parameter should specify the path to the custom FIXML DTD file.
To convert custom FIXML messages the following steps should be taken:
Custom FIXML dictionaries can be used for new tags addition or standard group using in different FIX messages. If you would use a new custom FIX message or repeating group then you need, additionally, to add it in your code by the biz.onixs.fix.fixml.FixmlConverter.addCustomMessage(String, String) and biz.onixs.fix.fixml.FixmlConverter.addCustomRepeatingGroup(int, String) methods before converting.
In order to add a custom tag (1903) in SettlInstructions component block the following steps should be performed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <? xml version = "1.0" encoding = "UTF-8" ?> < xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" targetNamespace = "http://www.fixprotocol.org/FIXML-4-4" attributeFormDefault = "unqualified" > < xs:simpleType name = "CustomType_enum_t" > < xs:annotation > < xs:documentation >Trade identifier required by government regulators or other regulatory organizations for regulatory reporting purposes. For example, unique swap identifer (USI) as required by the U.S. Commodity Futures Trading Commission.</ xs:documentation > < xs:Xref Protocol = "FIX" name = "CustomID" ComponentType = "Field" Tag = "1903" Type = "String" AbbrName = "ID" /> </ xs:appinfo > </ xs:annotation > < xs:restriction base = "xs:string" /> </ xs:simpleType > </ xs:schema > |
1 2 3 4 5 6 7 8 9 10 11 | <? xml version = "1.0" encoding = "UTF-8" ?> < xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" targetNamespace = "http://www.fixprotocol.org/FIXML-4-4" attributeFormDefault = "unqualified" > < xs:include schemaLocation = "fields_base.xsd" /> < xs:simpleType name = "CustomType_t" > < xs:restriction base = "CustomType_enum_t" /> </ xs:simpleType > </ xs:schema > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <? xml version = "1.0" encoding = "UTF-8" ?> < xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" targetNamespace = "http://www.fixprotocol.org/FIXML-4-4" attributeFormDefault = "unqualified" > < xs:include schemaLocation = "fields_impl.xsd" /> < xs:group name = "SettlInstructionsDataElements" > < xs:sequence > < xs:element name = "DlvInst" type = "DlvyInstGrp_Block_t" minOccurs = "0" maxOccurs = "unbounded" /> </ xs:sequence > </ xs:group > < xs:attributeGroup name = "SettlInstructionsDataAttributes" > < xs:attribute name = "DlvryTyp" type = "SettlDeliveryType_t" use = "optional" /> < xs:attribute name = "StandInstDbTyp" type = "StandInstDbType_t" use = "optional" /> < xs:attribute name = "StandInstDbName" type = "StandInstDbName_t" use = "optional" /> < xs:attribute name = "StandInstDbID" type = "StandInstDbID_t" use = "optional" /> <!-- Add custom tag --> < xs:attribute name = "CustomField" type = "CustomType_t" use = "optional" /> </ xs:attributeGroup > < xs:complexType name = "SettlInstructionsData_Block_t" final = "#all" > < xs:annotation > < xs:documentation xml:lang = "en" >SettlInstructionsData is a component </ xs:documentation > < xs:Xref Protocol = "FIX" name = "SettlInstructionsData" ComponentType = "Block" /> < xs:Xref Protocol = "ISO_15022_XML" /> </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:group ref = "SettlInstructionsDataElements" /> </ xs:sequence > < xs:attributeGroup ref = "SettlInstructionsDataAttributes" /> </ xs:complexType > </ xs:schema > |
In order to add a custom repeating group which consist of the following field(s) in UnderlyingInstrument component block the following steps should be performed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <? xml version = "1.0" encoding = "UTF-8" ?> < xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" targetNamespace = "http://www.fixprotocol.org/FIXML-4-4" attributeFormDefault = "unqualified" > <!-- Custom repeating group definition --> < xs:complexType name = "CustomIdGrp_Block_t" final = "#all" > < xs:annotation > < xs:appinfo > < xs:Xref Protocol = "FIX" name = "CustomIdGrp" ComponentType = "ImplicitBlockRepeating" /> < xs:Xref Protocol = "ISO_15022_XML" /> </ xs:appinfo > </ xs:annotation > < xs:sequence > < xs:group ref = "CustomIdGrpElements" /> </ xs:sequence > < xs:attributeGroup ref = "CustomIdGrpAttributes" /> </ xs:complexType > < xs:group name = "CustomIdGrpElements" > < xs:sequence /> </ xs:group > < xs:attributeGroup name = "CustomIdGrpAttributes" > < xs:attribute name = "Id" type = "CustomIdType_t" use = "optional" /> </ xs:attributeGroup > < xs:group name = "UnderlyingInstrumentElements" > < xs:sequence > < xs:element name = "UndAID" type = "UndSecAltIDGrp_Block_t" minOccurs = "0" maxOccurs = "unbounded" /> < xs:element name = "Stip" type = "UnderlyingStipulations_Block_t" minOccurs = "0" maxOccurs = "unbounded" /> <!-- Custom repeating group is added into UnderlyingInstrument component block --> < xs:element name = "CustomId" type = "CustomIdGrp_Block_t" minOccurs = "0" maxOccurs = "unbounded" /> </ xs:sequence > </ xs:group > </ xs:schema > |
51 52 53 54 | final File file = new File( "conf/sample/schema2/fixml-main-4-4.xsd" ); final FixmlConverter converter = new FixmlConverter(file.toURI().toString(), Version.FIX44); // Adding custom repeating group converter.addCustomRepeatingGroup( 10000 , "CustomIdGrp_Block_t" ); |
Check also Samples :: FIXML Converter.