1 / 21

XML: An Introduction

Learn about XML and what constitutes a well-formed XML document through examples and understanding of XML syntax.

phelan
Download Presentation

XML: An Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML: An Introduction What is XML? What is a well-formed XML document? This session will introduce you to XML by providing a brief history of the protocol. Learn XML Syntax and work through examples to understand what constitutes a well formed XML document

  2. Introduction to XML Jim Northey Jordan and Jordan Chair, FPL Global Derivatives Committee

  3. What is XML? It’s a Dessert Topping!! XML It’s A Floor Wax!! The BEST NEW thing since RDBMS’ and Objects!!!

  4. What is XML? 1980s • History • Move beyond the closed markup language HTML to add semantic • eXtensible Markup Language • Open ended mark up language • XML is a Meta markup language • Markup language used to create other markup languages • Just like HTML uses Tags to organize data • The tags describe the content of the message • Self describing data • Description of the message with the message provides for considerable flexibility SGML 1994 HTML 1998 XML 1999 XHTML

  5. Driving force behind XML • W3C - World Wide Web Consortium http://www.w3c.org • 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 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 software. • http://www.w3.org/Consortium/Points/

  6. HTML - 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>&nbsp;<P>&nbsp;<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>

  7. A note on terminology • In this presentation “XML Message” and “XML Document” are used interchangeably

  8. An XML Document or Message is made up of Elements Elements are composed of All tags contain a name An Opening Tag optional attributes optional content A Closing Tag Elements can be empty Meaning the Opening Tag can be terminated with a backslash character Elements are nested Elements can contain other elements containing other elements …. Forms a tree of information White space is ignored with the exception of the information between the element opening tag and closing tag <ThisIsAn-ElementName> this is the data for this element </ThisIsAn-ElementName> <AnEmpty_ElementLooksLikeThis/> <AnyOldElement> <AnyOldNestedElementHere> <AnotherElement> </AnotherElement> </AnyOldNestedElementHere> </AnyOldElement> <RejectReason>Customer Unknown</RejectReason> <RejectReason>Customer Unknown</RejectReason> Quick Overview on XML

  9. Well Formed XML Messages • There are only a handful of rules that need to be followed to create XML messages • 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

  10. Anatomy of an XML Message XML Declaration <?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> Root Element Empty Tag Opening Tag Attribute Value Element Value Attribute Closing Tag Nested Elements What’s This?

  11. XML Declaration • First line in XML document • Delimited by <? and ?> • Three properties that you can set • version • Always use this property • There is only one version now “1.0” • encoding • Use if you require support of an alternative character set • Usually not needed • Default character set is UTF-8, which is the ~ASCII part of Unicode • standalone • Use this property to tell an XML processor if there are other files required to process this XML document • Valid values “yes” or “no”

  12. Elements • Have an Opening Tag and a Closing Tag • XML Elements are nested - into a tree structure • The outer most (top level) element is called the Root Element • Content for the element is contained between the Opening Tag and the Closing Tag • Tag names (element names) • cannot have embedded spaces or punctuation characters other than - and _ • are 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>

  13. Attributes • Can be added to the Opening Tag of an Element • name=“value” or name=‘value’ format • White space ignored • name = ‘value’ • No embedded spaces or punctuation in an attribute name • except “-” and “_” • IMHO: Think of elements as objects, think of attributes as urrrr..., well attributes of the objects (elements) • Sometimes objects contain other objects (elements) • Sometimes they just have attributes (data elements, member variables) • In fact the ISO 15022 Working Group 10 creating ISO/XML uses object modeling (UML) to create their XML definitions

  14. Defining 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???

  15. Defining our own markup languages • We said earlier that XML is a meta markup language • XML is used to create domain specific markup languages • 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 (a *ML if you will) ? • There has to be … • some mechanism we can use to describe our particular markup language (be it FIXML, FpML, JimML, EdML, MathML, AgXML, …) • some way to share this description of our *ML • some way automate the process of making sure an incoming XML message is a valid *ML message Good News There Is!!!!

  16. Describing XML Messages • Document Type Definitions (DTDs) • XML Schema • Relax NG • … The Bad News is there is more than one way!

  17. Describing XML Messages • Document Type Definitions (DTDs) • Provided with the original definition of SGML as defined by Goldfarb • Think of DTD statements as control statements for defining XML documents • DTD statements are not really XML statements • Cannot use XML tools to manipulate DTD statements • Some consider the DTD statements as a separate language • In practice it is a separate language though it is a fundamental part of XML • XML Schema • An XML based language for defining XML documents • Permits manipulation of the schema using standard XML tools • This is like defining the database schema in tables in a relational database • A recursion...

  18. A Very Simple Order in FIXML Schema Version <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>

  19. Example 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 [tai@brookpath.com] and Nikhil Bose [AssistSoft@yahoo.com]

  20. Another 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)

  21. Resources on the web • XML Tutorials: http://www.zvon.org • XML Tutorials and Specifications: http://www.w3c.org • XML General: http://www.xml.com • XML plus general IT coverage: http://www.informIT.com

More Related