1 / 26

XML_2

XML_2. Ch. 7. XML Vocabularies. MathML An application to parse, render, and edit MathML : Amaya http://www.w3.org/Amaya/User/BinDist.html. Rendering with Amaya. Mathml1.xml Mathml2.xml Mathml3.xml. Mathml1.xml. <?xml version="1.0" encoding="iso-8859-1"?>

makya
Download Presentation

XML_2

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_2 Ch. 7 Comp Sci 346

  2. XML Vocabularies • MathML • An application to parse, render, and edit MathML: Amaya • http://www.w3.org/Amaya/User/BinDist.html Comp Sci 346

  3. Comp Sci 346

  4. Rendering with Amaya • Mathml1.xml • Mathml2.xml • Mathml3.xml Comp Sci 346

  5. Mathml1.xml <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd"> <!-- Fig. 14.16: mathml1.mml --> <!-- MathML equation. --> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mn>2</mn> <mo>+</mo> <mn>3</mn> <mo>=</mo> <mn>5</mn> </math> Comp Sci 346

  6. Mathml2.xml <math xmlns="http://www.w3.org/1998/Math/MathML"> <mn>3</mn> <mo>&InvisibleTimes;</mo> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <mi>x</mi> <mo>&minus;</mo> <mfrac> <mn>2</mn> <mi>x</mi> </mfrac> <mo>=</mo> <mn>0</mn> </math> Comp Sci 346

  7. Mathml3.xml <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <msubsup> <mo>&int;</mo> <mn>0</mn> <mrow> <mn>1</mn> <mo>&minus;</mo> <mi>y</mi> </mrow> </msubsup> <msqrt> <mn>4</mn> <mo>&InvisibleTimes;</mo> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <mi>y</mi> </msqrt> <mi>&delta;</mi> <mi>x</mi> </mrow> </math> Comp Sci 346

  8. Rendering with Firefox and IE • Download and install additional fonts for Firefox • www.mozilla.org/projects/mathml/fonts/ or • https://developer.mozilla.org/en/Mozilla_MathML_Project/Fonts • Internet Explorer, get a plug in (Exercise) • www.dessci.com/en/products/mathplayer/ Comp Sci 346

  9. Comp Sci 346

  10. Plug-in Mathplayer for IE Comp Sci 346

  11. Comp Sci 346

  12. How to render an XML Document? • Extensible Stylesheet Language (XSL) • Specify how programs should render XML document data • XSL-FO (XSL Formatted Objects) • Vocabulary for specifying formatting • XSLT (XSL Transformation) • Defines rules for transforming one XML documment to another • From Source tree to Result tree • Xpath • Locate parts of the source tree document that match templates defined in the XSL stylesheet Comp Sci 346

  13. <?xml version = "1.0"?> <?xml:stylesheet type = "text/xsl" href = "games.xsl"?> <!-- Fig. 20.28 : games.xml --> <!-- Sports Database --> <sports> <game id = "783"> <name>Cricket</name> <paragraph> Popular in Commonwealth nations. </paragraph> </game> Processing Instruction (PI) references the XSL stylesheet games.xsl Specifies location of XSLT <? ?> delimits a PI target Comp Sci 346

  14. Games.xml continued <game id = "239"> <name>Baseball</name> <paragraph> Popular in America. </paragraph> </game> <game id = "418"> <name>Soccer (Football)</name> <paragraph> Popular sport in the world. </paragraph> </game> </sports> Comp Sci 346

  15. XSL style sheet <?xml version = "1.0"?> <!-- Fig. 20.29 : games.xsl --> <!-- A simple XSLT transformation --> <!-- reference XSL stylesheet URI --> <xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl:output method = "html" omit-xml-declaration = "no" doctype-system = "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"/> <xsl:template match = "/"> <!-- match root element --> Start style sheet Binds namespace xsl to W3C XSLT URI Output as xhtml file. Doctype as xhtml “/” is used to select the root Comp Sci 346

  16. Extensible Stylesheet Language (XSL) Comp Sci 346

  17. Rendering games.xml Comp Sci 346

  18. Using XSLT to Sort and Format Data Compare the source in sorting.xml (chapters are out of order) and the rendering Comp Sci 346

  19. Comp Sci 346

  20. Other applications using XML • DOM • PHP Comp Sci 346

  21. DOM • Document Object Model • Syntax tree for XML document • Tree is passed to application (e.g.browser) • Application can modify the document via the tree • Browser-independent JavaScript functionality Comp Sci 346

  22. Use XML with PHP • XML functionality is based on libxml2 library • Enabled by default on Windows and Linux/Unix • Check for the following with phpinfo() • dom • libxml • simplexml Comp Sci 346

  23. Parsing XML with PHP • Example 1: Load an xml file into the XML parser and dump the contents • Use 25-2xmlload.php to load 25-1messages.xml as an object • Dump the contents of the object Comp Sci 346

  24. Parsing XML with PHP • Example 2: Load an xml file into the XML parser and display the contents • Load 25-3 books.xml into XML parser 25-4xmlparse.php • Break up the elements • and display the contents • Reference on objects in PHP http://us2.php.net/manual/en/language.oop5.php#op5.intro Comp Sci 346

  25. Parsing XML with PHP • Example 3: Rewrite example 1 to load an xml file into the XML parser and display the contents • Use 25-4xmlload1.php to load 25-1messages.xml as an object • Display the contents of the object • What are the changes? Comp Sci 346

  26. Summary • Conclusions? • Description of data • Method of data exchange • Well structured files Comp Sci 346

More Related