22 april 041 xml: an introduction what is xml? what is a well-formed xml document? this session will...
TRANSCRIPT
22 April 04 1
XML: An IntroductionXML: An Introduction
What is XML? What is a well-formed XML document? This session What is XML? What is a well-formed XML document? This session will introduce you to XML by providing a brief history of the will introduce you to XML by providing a brief history of the protocol. Learn XML Syntax and work through examples to protocol. Learn XML Syntax and work through examples to understand what constitutes a well formed XML documentunderstand what constitutes a well formed XML document
22 April 04 2
Introduction to XMLIntroduction to XMLJim NortheyJim Northey
Jordan and JordanJordan and Jordan Chair, FPL Global Derivatives CommitteeChair, FPL Global Derivatives Committee
22 April 04 3
Making the Transition to FIXML
What is XML?What is XML?
It’s A Floor Wax!!
It’s a DessertTopping!!
The BEST NEW thing since RDBMS’ and Objects!!!
22 April 04 4
Making the Transition to FIXML
What is XML?What is XML?
• HistoryHistory• Move beyond the closed Move beyond the closed
markup language HTML to add markup language HTML to add semanticsemantic
• eeXXtensible tensible MMarkup arkup LLanguageanguage– Open ended mark up languageOpen ended mark up language
• XML is a Meta markup XML is a Meta markup languagelanguage– Markup language used to create Markup language used to create
other markup languagesother markup languages
• Just like HTML uses Just like HTML uses TagsTags to to organize dataorganize data– The tags describe the content of the The tags describe the content of the
messagemessage
• Self describing dataSelf describing data– Description of the message with the Description of the message with the
message provides for considerable message provides for considerable flexibilityflexibility
SGML
HTML
XML
XHTML
1994
1998
1999
1980s
22 April 04 5
Making the Transition to FIXML
Driving force behind XMLDriving force behind XML
• W3C - World Wide Web Consortium W3C - World Wide Web Consortium http://www.w3c.orghttp://www.w3c.org– founded in October 1994 to lead the World Wide Web to its full potential by founded in October 1994 to lead the World Wide Web to its full potential by
developing common protocols that promote its evolution and ensure its developing common protocols that promote its evolution and ensure its interoperability. Today, W3C has over 450 Members and nearly 70 full-time staff interoperability. Today, W3C has over 450 Members and nearly 70 full-time staff around the world who contribute to the development of W3C specifications and around the world who contribute to the development of W3C specifications and software.software.
– http://www.w3.org/Consortium/Points/http://www.w3.org/Consortium/Points/
22 April 04 6
Making the Transition to FIXML
HTML - A Closed Markup LanguageHTML - A Closed Markup Language<HTML><HEAD><TITLE>Futures Industry Association - The FIA is the only association representative of all organizations that have an interest in the futures market.</TITLE></HEAD>
<BODY BGCOLOR="#333333" ALINK=#000000 VLINK=#E9E7A7 LINK=#E9E7A7 TOPMARGIN=0 LEFTMARGIN=0 RIGHTMARGIN=0 BOTTOMMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0>
<DIV ALIGN="center"><P> <P> <P>
<!-- START LOGO TABLE --><TABLE BORDER=0 WIDTH=770 CELLPADDING=0 CELLSPACING=0><TR HEIGHT=65><TD ALIGN=center><STRONG><FONT SIZE=3 COLOR=#ffff00>www.futuresindustry.org</FONT></STRONG><BR><FONT SIZE=5 COLOR=white>FUTURES INDUSTRY ASSOCIATION</EM></FONT></TD></TR></TABLE><!-- END LOGO TABLE --> ...
<FONT SIZE=1 COLOR=#333333>The Futures Industry Association and the Futures Industry Institute. Futures, Markets, Volume, CFTC, SEC, Trade, Show, Boca, Electronic, Trading, Expo, Exhibit, Education, Optech, Market, Commission, Merchant, Finance, FCM, Commodities, Commodity, Trading, Advisor, CTA, Derivatives, Risk, Management, Options, Hedge, Trading, y2k, FII, FIA, De-regulation, Regulation, Contract, Specifications, Clearing, Series, 31, 32, 33, Alternative, Investments, Ethics, Factbook, Data, Investor, Managed</FONT></DIV>
</BODY></HTML>
22 April 04 7
Making the Transition to FIXML
A note on terminologyA note on terminology
• In this presentation “In this presentation “XML MessageXML Message” and “” and “XML DocumentXML Document” are used ” are used interchangeablyinterchangeably
22 April 04 8
Making the Transition to FIXMLQuick Overview on XMLQuick Overview on XML
• An XML Document or Message An XML Document or Message is made up of Elementsis made up of Elements
• Elements are composed ofElements are composed of– All tags contain a nameAll tags contain a name– An Opening TagAn Opening Tag– optional attributesoptional attributes– optional contentoptional content– A Closing TagA Closing Tag
• Elements can be emptyElements can be empty– Meaning the Opening Tag can be Meaning the Opening Tag can be
terminated with a backslash terminated with a backslash charactercharacter
• Elements are nestedElements are nested– Elements can contain other Elements can contain other
elements containing other elements containing other elements ….elements ….
– Forms a tree of informationForms a tree of information• White space is ignored with the White space is ignored with the
exception of the information exception of the information between the element opening between the element opening tag and closing tagtag and closing tag
<ThisIsAn-ElementName> this is the data <ThisIsAn-ElementName> this is the data for this elementfor this element</ThisIsAn-ElementName></ThisIsAn-ElementName>
<AnEmpty_ElementLooksLikeThis/><AnEmpty_ElementLooksLikeThis/>
<AnyOldElement><AnyOldElement> <AnyOldNestedElementHere><AnyOldNestedElementHere> <AnotherElement><AnotherElement> </AnotherElement></AnotherElement> </AnyOldNestedElementHere></AnyOldNestedElementHere></AnyOldElement></AnyOldElement>
<RejectReason>Customer <RejectReason>Customer Unknown</RejectReason>Unknown</RejectReason>
<RejectReason>Customer <RejectReason>Customer Unknown</RejectReason>Unknown</RejectReason>
22 April 04 9
Making the Transition to FIXML
Well Formed XML MessagesWell Formed XML Messages
• There are only a handful of rules that need to be followed to create There are only a handful of rules that need to be followed to create XML messagesXML messages
• XML messages that follow the simple rules are considered to be:XML messages that follow the simple rules are considered to be:
Well Formed XML Messages
Well Formed Messages are good
A Well Formed XML document is not to be confused with a Valid XML document
22 April 04 10
Making the Transition to FIXMLAnatomy of an XML MessageAnatomy of an XML Message
<?xml version='1.0'?><FIXML> <FIXMLMessage> <ApplicationMessage> <Order> <ClOrdID>12345</ClOrdID> <HandlInst Value="1"/> <Instrument> <Security> <Symbol>EK</Symbol> </Security> </Instrument> <Side Value="1"/> <OrderQuantity> <OrderQty>10000</OrderQty> </OrderQuantity> <OrderType> <MarketOrder OrdType="1"/> </OrderType> <Currency Value="USD"/> </Order> </ApplicationMessage> </FIXMLMessage></FIXML>
XML Declaration
Root Element
Value
Opening Tag
Empty Tag
Attribute
Attribute Value
Closing Tag
Nested Elements
What’s This?
Ele
men
t
22 April 04 11
Making the Transition to FIXML
XML DeclarationXML Declaration
• First line in XML documentFirst line in XML document• Delimited by Delimited by <?<? and and ?>?>• Three properties that you can setThree properties that you can set
– versionversion• Always use this propertyAlways use this property• There is only one version now “1.0”There is only one version now “1.0”
– encodingencoding• Use if you require support of an alternative character setUse if you require support of an alternative character set• Usually not neededUsually not needed• Default character set is UTF-8, which is the ~ASCII part of UnicodeDefault character set is UTF-8, which is the ~ASCII part of Unicode
– standalonestandalone• Use this property to tell an XML processor if there are other files required to process this Use this property to tell an XML processor if there are other files required to process this
XML documentXML document• Valid values “yes” or “no”Valid values “yes” or “no”
22 April 04 12
Making the Transition to FIXML
ElementsElements
• Have an Have an Opening TagOpening Tag and a and a Closing TagClosing Tag• XML Elements are nested - into a tree structureXML Elements are nested - into a tree structure• The outer most (top level) element is called the The outer most (top level) element is called the Root ElementRoot Element• Content for the element is contained between the Opening Tag and Content for the element is contained between the Opening Tag and
the Closing Tagthe Closing Tag• Tag names (element names)Tag names (element names)
– cannot have embedded spaces or punctuation characters other than - and _cannot have embedded spaces or punctuation characters other than - and _– are case sensitiveare case sensitive
<?xml version='1.0' encoding = "UTF-8" standalone = 'no' ?><our_root_element> <our_main_element/> <element-names-can-be-very-long-indeed-as-this-one-is-here_notice-that_hyphens-and_underscores_work></element-names-can-be-very-long-indeed-as-this-one-is-here_notice-that_hyphens-and_underscores_work></our_root_element>
22 April 04 13
Making the Transition to FIXML
AttributesAttributes
• Can be added to the Can be added to the Opening TagOpening Tag of an of an ElementElement• name=“value” or name=‘value’ formatname=“value” or name=‘value’ format• White space ignoredWhite space ignored
– name = ‘value’name = ‘value’
• No embedded spaces or punctuation in an attribute nameNo embedded spaces or punctuation in an attribute name– except “-” and “_”except “-” and “_”
• IMHO: Think of elements as objects, think of attributes as urrrr..., IMHO: Think of elements as objects, think of attributes as urrrr..., well attributes of the objects (elements)well attributes of the objects (elements)– Sometimes objects contain other objects (elements)Sometimes objects contain other objects (elements)– Sometimes they just have attributes (data elements, member variables)Sometimes they just have attributes (data elements, member variables)– In fact the ISO 15022 Working Group 10 creating ISO/XML uses object modeling In fact the ISO 15022 Working Group 10 creating ISO/XML uses object modeling
(UML) to create their XML definitions(UML) to create their XML definitions
22 April 04 14
Making the Transition to FIXML
Defining our own XML MessageDefining our own XML Message
<?xml version="1.0" encoding="UTF-8"?><!-- Trade information --><Trade>
<Instrument symbol="IBM" securityType="Stock"/><Quantity>100</Quantity><TradePrice>80.00</TradePrice><TradeDate>20020130</TradeDate><Sides>
<Side type="buy"><Customer>John Doe</Customer><Account>102435</Account><OrderID>ABC-1453-20020130</OrderID>
</Side><Side type="sell">
<Firm>SSB</Firm></Side>
</Sides></Trade>
Is this Well Formed???
22 April 04 15
Making the Transition to FIXML
Defining our own markup languagesDefining our own markup languages
• We said earlier that XML is a We said earlier that XML is a meta markup languagemeta markup language• XML is used to create domain specific markup languagesXML is used to create domain specific markup languages• How do we agree upon a dialect and then share this with others?How do we agree upon a dialect and then share this with others?• How do we know if an XML message complies with our XML dialect How do we know if an XML message complies with our XML dialect
(a *ML if you will) ?(a *ML if you will) ?• There has to be … There has to be …
– some mechanism we can use to describe our particular markup language (be it some mechanism we can use to describe our particular markup language (be it FIXML, FpML, JimML, EdML, MathML, AgXML, …)FIXML, FpML, JimML, EdML, MathML, AgXML, …)
– some way to share this description of our *MLsome way to share this description of our *ML– some way automate the process of making sure an incoming XML message is a some way automate the process of making sure an incoming XML message is a
valid *ML messagevalid *ML message
Good News There Is!!!!
22 April 04 16
Making the Transition to FIXML
Describing XML MessagesDescribing XML Messages
• Document Type Definitions (DTDs)Document Type Definitions (DTDs)• XML SchemaXML Schema• Relax NGRelax NG• ……
The Bad News is there is more than one way!
22 April 04 17
Making the Transition to FIXML
Describing XML MessagesDescribing XML Messages• Document Type Definitions (DTDs)Document Type Definitions (DTDs)
– Provided with the original definition of SGML as defined by GoldfarbProvided with the original definition of SGML as defined by Goldfarb– Think of DTD statements as control statements for defining XML documentsThink of DTD statements as control statements for defining XML documents– DTD statements are not really XML statementsDTD statements are not really XML statements– Cannot use XML tools to manipulate DTD statementsCannot use XML tools to manipulate DTD statements– Some consider the DTD statements as a separate languageSome consider the DTD statements as a separate language
• In practice it is a separate language though it is a fundamental part of XMLIn practice it is a separate language though it is a fundamental part of XML
• XML SchemaXML Schema– An XML based language for defining XML documentsAn XML based language for defining XML documents– Permits manipulation of the schema using standard XML toolsPermits manipulation of the schema using standard XML tools– This is like defining the database schema in tables in a relational databaseThis is like defining the database schema in tables in a relational database– A recursion...A recursion...
22 April 04 18
Making the Transition to FIXML
<FIXML v="4.4" r="20030618" s="20031218"><Order ID="123456" Side="1"
TxnTm="2003-12-18T12:00:00" Typ="2" Px="85.00"><Hdr TID="SSB" SID="FCM"SeqNum="1" Snt="2003-12-18T12:00:00"/><Instrmt Sym="IBM"/><OrdQty Qty="100"/>
</Order></FIXML>
A Very Simple Order in FIXML Schema VersionA Very Simple Order in FIXML Schema Version
22 April 04 19
Making the Transition to FIXML
Example Allocation ReportExample Allocation Report<?xml version="1.0" encoding="UTF-8"?><FIXML><AllocRpt AcrdIntAmt="55000.0" AvgPx="110.74080" Ccy="USD" GrossTrdAmt="11074080.0" ID="20013212" LastFragment="Y" LastMkt="TRWB" NetMny="11129080.0" NoOrdsTyp="1" PxTyp="1" Qty="10000000.000000" RptID="3349GCMXAG000671" RptTyp="3" SettlDt="2003-12-18" Side="1" Stat="0" TransTyp="0" TrdDt="2003-12-15" TxnTm="2003-12-15T20:29:03">
<Hdr SID="TRADEWEB" SeqNum="544" Snt="2003-12-15T20:29:05.827" TID="XYZFI"/><OrdAlloc ClOrdID="NONREF" OrdID2="3349GCMXAG00067"/><AllExc ExecID="3349GCMXAG000671" LastPx="110.74080" LastQty="10000000.000000"/><Instrmt CpnRt="0.06" Desc="FNMA 6.000 05/15/2008" ID="31359MDU4" Issr="FNMA"
Issued="1998-05-11" MatDt="2008-05-15" Prod="1" SecTyp="FAC" Src="1" Sym="[N/A]"/><Pty ID="GRNWUS33" R="1" Src="B"/><Yield Typ="MATURITY" Yld="0.033575"/><Alloc Acct="ACCT 2" AcrdIntAmt="44000.0" NetMny="8903264.0" Qty="8000000">
<Pty ID="DTC" R="4" Src="C"/></Alloc>
</AllocRpt></FIXML>
Example courtesy Lisa Taikitsadaporn [[email protected]] and Nikhil Bose [[email protected]]
22 April 04 20
Making the Transition to FIXML
Another Order ExampleAnother Order Example
<FIXML><Order ID="123456" Side="2"
TxnTm="2001-09-11T09:30:47-05:00" Typ="2" Px="93.25" Acct="26522154"><Hdr Snt="2001-09-11T09:30:47-05:00" PosDup="N" PosRsnd="N"
SeqNum="521"SID="AFUNDMGR" TID="ABROKER"/>
<Instrmt Sym="IBM" ID="459200101" Src="1"/><OrdQty Qty="1000"/>
</Order></FIXML>
Example courtesy Nikhil Bose (AssistSoft)
22 April 04 21
Making the Transition to FIXML
Resources on the webResources on the web
• XML Tutorials: XML Tutorials: http://www.zvon.orghttp://www.zvon.org• XML Tutorials and Specifications: XML Tutorials and Specifications: http://www.w3c.orghttp://www.w3c.org• XML General: http://www.xml.comXML General: http://www.xml.com• XML plus general IT coverage: XML plus general IT coverage: http://www.informIT.comhttp://www.informIT.com