Chapter: Internet & World Wide Web HOW TO PROGRAM - The Ajax Client - XML and RSS

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail

XML Vocabularies

XML allows authors to create their own tags to describe data precisely.

XML Vocabularies

 

XML allows authors to create their own tags to describe data precisely. People and orga-nizations in various fields of study have created many different kinds of XML for structur-ing data. Some of these markup languages are: MathML (Mathematical Markup Language), Scalable Vector Graphics (SVG), Wireless Markup Language (WML), Ex-tensible Business Reporting Language (XBRL), Extensible User Interface Language (XUL) and Product Data Markup Language (PDML). Two other examples of XML vo-cabularies are W3C XML Schema and the Extensible Stylesheet Language (XSL), which we discuss in Section 14.8. The following subsections describe MathML and other custom markup languages.

 

1. MathML™

 

Until recently, computers typically required specialized software packages such as TeX and LaTeX for displaying complex mathematical expressions. This section introduces MathML, which the W3C developed for describing mathematical notations and expres-sions. One application that can parse, render and edit MathML is the W3C’s Amaya™ browser/editor, which can be downloaded from

 

www.w3.org/Amaya/User/BinDist.html

 

This page contains download links for several platforms. Amaya documentation and in-stallation notes also are available at the W3C website. Firefox also can render MathML, but it requires additional fonts. Instructions for downloading and installing these fonts are available at  www.mozilla.org/projects/mathml/fonts/. You can download a plug-in ( www.dessci.com/en/products/mathplayer/) to render MathML in Internet Explorer .

 

MathML markup describes mathematical expressions for display. MathML is divided into two types of markup—content markup and presentation markup. Content markup provides tags that embody mathematical concepts. Content MathML allows programmers to write mathematical notation specific to different areas of mathematics. For instance, the multiplication symbol has one meaning in set theory and another meaning in linear algebra. Content MathML distinguishes between different uses of the same symbol. Pro-grammers can take content MathML markup, discern mathematical context and evaluate the marked-up mathematical operations. Presentation MathML is directed toward for-matting and displaying mathematical notation. We focus on Presentation MathML in the MathML examples.

 

Simple Equation in MathML

Figure 14.16 uses MathML to mark up a simple expression. For this example, we show the expression rendered in Firefox.

 

1    <?xml version="1.0" encoding="iso-8859-1"?>

 

2    <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN"

 

3          "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">

4              

5    <!-- Fig. 14.16: mathml1.mml -->

 

6    <!-- MathML equation. -->

 

7    <math xmlns="http://www.w3.org/1998/Math/MathML">

 

8          <mn>2</mn>

 

9          <mo>+</mo>

 

10         <mn>3</mn>

 

11         <mo>=</mo>

 

12         <mn>5</mn>

 

13   </math>


 

Fig. 14.16 | Expression marked up with MathML and displayed in the Firefox browser.

 

By convention, MathML files end with the .mml filename extension. A MathML doc-ument’s root node is the math element, and its default namespace is  http://www.w3.org/  1998/Math/MathML (line 7). The mn element (line 8) marks up a number. The mo element (line 9) marks up an operator (e.g., +). Using this markup, we define the expression 2 + 3 = 5, which any MathML capable browser can display.

 

Algebraic Equation in MathML

Let’s consider using MathML to mark up an algebraic equation containing exponents and arithmetic operators (Fig. 14.17). For this example, we again show the expression ren-dered in Firefox.

 

1    <?xml version="1.0" encoding="iso-8859-1"?>

 

2    <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN"

 

3          "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">

4              

5    <!-- Fig. 14.17: mathml2.html -->

 

6    <!-- MathML algebraic equation. -->

 

7    <math xmlns="http://www.w3.org/1998/Math/MathML">

 

8          <mn>3</mn>

 

9          <mo>&InvisibleTimes;</mo>

 

10         <msup>

 

11                <mi>x</mi>

 

12                <mn>2</mn>

 

13         </msup>

<mo>+</mo>

 

14         <mn>x</mn>

 

15         <mo>&minus;</mo>

 

16         <mfrac>

 

17                <mn>2</mn>

 

18                <mi>x</mi>

 

19         </mfrac>

 

20         <mo>=</mo>

 

21         <mn>0</mn>

 

22   </math>

 


Fig. 14.17 | Algebraic equation marked up with MathML and displayed in the Firefox browser

 

Line 9 uses entity reference &InvisibleTimes; to indicate a multiplication operation without explicit symbolic representation (i.e., the multiplication symbol does not appear between the 3 and x). For exponentiation, lines 10–13 use the msup element, which rep-resents a superscript. This msup element has two children—the expression to be super-scripted (i.e., the base) and the superscript (i.e., the exponent). Correspondingly, the msub element represents a subscript. To display variables such as x, line 11 uses identifier ele-ment mi.

 

To display a fraction, lines 17–20 uses the mfrac element. Lines 18–19 specify the numerator and the denominator for the fraction. If either the numerator or the denomi-nator contains more than one element, it must appear in an mrow element.

 

Calculus Expression in MathML

Figure 14.18 marks up a calculus expression that contains an integral symbol and a square-root symbol.

 

1    <?xml version="1.0" encoding="iso-8859-1"?>

 

2    <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN"

 

3          "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd">

4              

5    <!-- Fig. 14.18 mathml3.html -->

 

6    <!-- Calculus example using MathML -->

 

7    <math xmlns="http://www.w3.org/1998/Math/MathML">

 

8          <mrow>

 

9                 <msubsup>

 

10                      <mo>&int;</mo>


 

11                      <mn>0</mn>

 

12                      <mrow>

 

13        <mn>1</mn>

14        <mo>&minus;</mo>

15                              <mi>y</mi>

 

16                      </mrow>

 

17                </msubsup>

 

18                <msqrt>

 

19                      <mn>4</mn>

 

20                      <mo>&InvisibleTimes;</mo>

 

21                      <msup>

22            <mi>x</mi>

 

23                            <mn>2</mn>

 

24                      </msup>

 

25                      <mo>+</mo>

 

26                      <mi>y</mi>

 

27                </msqrt>

 

28                <mo>&delta;</mo>

 

29                <mi>x</mi>

 

30         </mrow>

 

31   </math>


Fig. 14.18 | Calculus expression marked up with MathML and displayed in the Amaya browser. [Courtesy of World Wide Web Consortium (W3C).]

Lines 8–30 group the entire expression in an mrow element, which is used to group elements that are positioned horizontally in an expression. The entity reference &int; (line 10) represents the integral symbol, while the msubsup element (lines 9–17) specifies the subscript and superscript a base expression (e.g., the integral symbol). Element mo marks up the integral operator. The msubsup element requires three child elements—an operator (e.g., the integral entity, line 10), the subscript expression (line 11) and the superscript expression (lines 12–16). Element mn (line 11) marks up the number (i.e., 0) that represents the subscript. Element mrow (lines 12–16) marks up the superscript expression (i.e., 1-y).

 

Element msqrt (lines 18–27) represents a square-root expression. Line 28 introduces entity reference &delta; for representing a lowercase delta symbol. Delta is an operator, so line 28 places this entity in element mo. To see other operations and symbols in MathML, visit  www.w3.org/Math.

 

2. Other Markup Languages

 

Literally hundreds of markup languages derive from XML. Every day developers find new uses for XML. Figure 14.20 summarizes a few of these markup languages. The website

 

 www.service-architecture.com/xml/articles/index.html

 

provides a nice list of common XML vocabularies and descriptions.





Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.