1 / 14

Using XML to present computer program

This article explains how XML can be used to present computer programs, including its extensibility and separation of content from presentation. It also discusses the benefits of using XML for universal computing and provides examples of XML implementation in a bookstore and a programming language.

kjavier
Download Presentation

Using XML to present computer program

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. Using XML to present computer program Qingsong Yao Department of Computer Science York University qingsongy@cs.yorku.ca

  2. What is XML? • eXtensible Markup Language Language for creating other languages • XML is extensible (compared to HTML) user can create new tag and use DTD or Schema to describe the structure of XML file • XML separate content from presentation

  3. WHY XML? • three prerequisites for universal computing: global communication, portable software, and portable data • Java : platform-independent program • Internet :platform-independent networking • XML : platform-independent data.

  4. An example of XML and DTD Bookstore.XML <?xml version="1.0" encoding="GB2312"??> <!DOCTYPE bookstore SYSTEM “Bookstore.DTD”> <bookstore name="Chapters"> <book> <name>Beginning XML</name> <author>David Hunter</author> <price>59.95</price> </book> <book> <name>Professional XML</name> <author>Wrox Author Team</author> <price>74.95</price> </book> </bookstore> Bookstore.DTD <?xml version="1.0"?> <!ELEMENT bookstore (book*)> <!ATTLIST bookstore name (#PCDATA) > <!ELEMENT book (name,author+,price) > <!ELEMENT name (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT price (#PCDATA)>

  5. XML STANDARD • MathML Mathematical Markup Language • SVG (Scalable Vector Graphics) Describe two-dimensional graphics • XML QUERY Access ,query and manipulate the XML • RDF(Resource Description Framework) Interoperable ,machine understandable metadata • more standard can be found on W3C

  6. Using XML • Data Exchange and Translation • e-Commerce Messaging (B2B) • Identical description of data format • Powerful Search Engine and more…

  7. Programming With XML • XML can be represent by an DOM tree element attribute value bookstore book book name=“chapters” name author price name author price Beginning XML 59.95 David Hunter Professional XML Wrox Author Team 74.95

  8. Using XML to present computer language • Background • most computer languages have the same data structure and library • integer , string ,array, and object .. • Searching and Sorting algorithm… • Goals • Present logic ,algorithm or program using XML • Can be transfered into other languages

  9. Data Flow uml corba xml XML Parser Xml Transformer Language Generator Optimizer Dom xml Dom • XML Transformer read source files and convert it to XML File • XML Parser read the XML file, converting it to a DOM tree • XML Optimizer can take grammar check and optimize the DOM tree • Language Generator generate source code from the DOM tree Pascal Java C file

  10. Key Point • For Object -Orient language , use Java’s grammar to define DTD • For Non-Object-Orient language ,use Pascal ‘s grammar • Each element should have an attribute “ID” in order to be referenced

  11. DTD Example <?xml version="1.0"?> <!ELEMENT variable_define data_type> <!ATTLIST variable_define id (ID | IDREF | IDREFS) #REQUIRED> <!ELEMENT data_type (#PCDATA)> <!ATTLIST data_type id (ID|IDREF|IDREFS) #REQUIRED > <!ELEMENT procedure_declare (parameter*,result*)> <!ATTLIST result data_type> <!ELEMENT procedure (parameters,statements)> <!ATTLIST procedure id (ID|IDREF|IDREFS)

  12. XML Language Example < ?xml version=“1.0” ?> < procedure id=“square”> <parameter id=“a”> <data_type id=“integer”> </parameter> <variable_define id=“c”> <data_type id=“integer”> </variable_define> <assignment id=“c”> <value> < variable id=“a” /> <operator id=“*” /> <variable id=“a” /> </value> </assignment> <procedure_return> <value > <variable id=“c” /> </value> </procedure_return> </procedure>

  13. Pascal and C Language File PASCAL Function square(a:integer):integer begin var c: integer; c:=a * a; result:=c; end; C int square(int a) { int c; c=a*a; return c; }

  14. References • W3C XML GROUP (xml standard) http://www.w3.org/XML/ • The XML Industry Portal http://www.xml.org • IBM XML (xml tools and articles) http://www.ibm.com/developer/xml/ http://www.alphaworks.ibm.com/ • SUN XML (java and XML) http://java.sun.com/xml/

More Related