xml in 60 minutes a day phần 10 docx

72 220 0
xml in 60 minutes a day phần 10 docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Classroom Q & A Q: Hold it a second. There’s that word semantics again. Is this the same semantics we’ve seen in previous chapters, like Chapter 13, “RDF”? A: No, the term semantics is one that appears in several XML con- texts. It is used most generally when we just want to discuss the structure or display of a document versus the semantics of the document (that is, the content data found within the structure). In Chapter 13, we referred to the W3C’s Semantic Web objective, wherein Web search agents can examine standardized metadata to learn about the subject matter in Web resources. Semantics, as we use it here, has a narrower focus: the actual meaning of num- bers, constants, variables, and operators in the mathematical expressions in a document. The Web community clearly needs a way to render and transmit mathemati- cal expressions accurately and quickly. As more research and commerce are con- ducted and coordinated via the Web, the Web community has spotlighted the last issue: the development of math and science objects that are “active,” that provide for the automatic processing and manipulation described previously. Early Visual Presentation Solutions Since the mid-1970s, the IT industry has developed several visual presentation solutions, such as: eqn. Developed in 1975 by Bell Labs for use with the UNIX typesetting system named troff. It was an influence on EzMath, which is demon- strated in the Chapter 16 lab exercises. TeX. Developed by D. Knuth of Stanford University in the late 1970s. Became the most popular method for electronic typesetting of mathe- matical expressions. Provides more control over typesetting details and relies heavily on macros. Available as freeware or shareware, or from commercial vendors. LaTeX. Developed by L. Lamport in the mid-1980s. Available by anony- mous FTP from the LaTeX3 Project (which has continued development) Web site at www.latex-project.org/ftp.html. AMS-TeX. Developed by the American Mathematical Society in the 1990s. A set of fonts and macros for mathematical typesetting, above and beyond those available with TeX and LaTeX. 618 Chapter 16 422541 Ch16.qxd 6/19/03 10:14 AM Page 618 ISO12083:1994. A DTD for math expressions. One of four DTDs in ANSI/NISO/ISO 12083, the Electronic Manuscript Preparation and Markup standard. Others. From the 1980s to the present, several word processing and graphics applications provide the capability to create math and science expressions, which are usually converted to proprietary formats or into graphics formats like JPEG, GIF, or TIFF. However, those developments were capable only of visual presentation and were not capable of conveying the underlying semantics (that is, the actual meaning) of math and science expressions. Plus, the first five listed were con- sidered a little too esoteric and complex for ordinary Web page developers and end users. That’s why many opted for the “Others”: commercial word proces- sor and graphics applications that could be used to create mathematical expressions as graphic images, which would then be loaded as graphics into Web pages. In this way, browsers were less likely to misinterpret the code and would at least present something. This approach, however, is not ideal, since it has several drawbacks: ■■ Image-containing pages are slow to download and display in an end user’s browser. ■■ Once displayed on the screen, the images may not be satisfactory to look at. (In Chapter 11, “VML,” you learned that bitmap images espe- cially are not scalable.) ■■ Extra graphic files must be administered. ■■ Once transmitted and displayed, the math expressions cannot be manipulated (e.g., you cannot cut and paste the whole expression or parts of the expression; you also can’t fill in values and get answers). ■■ Expression fonts and formats are fixed and may not match an end user’s display settings. ■■ No alternatives exist for people who are visually handicapped. ISO 12083:1994 (the Electronic Manuscript Preparation and Markup stan- dard) only describes declarations for presentation syntax; however, it repre- sents a major step toward integrating presentation and semantic markup. The W3C and MathML From the discussion so far, it’s no surprise that Web and other technical appli- cation developers were searching for a mathematical expression application that would facilitate the automatic processing of the underlying mathematics while unambiguously displaying the concepts, constants, and operators. Thus, MathML 619 422541 Ch16.qxd 6/19/03 10:14 AM Page 619 documents would have to be clear and active. This basic requirement appears, on the surface, that it could be easily met, but it has proved to be a challenge. During the early 1990s, the W3C recognized the issues surrounding the expression of mathematics and the need for better support for scientific com- munication. In fact, Dave Raggett even included an HTML Math proposal in the Working Draft of HTML 3.0, in 1994. The W3C Math Working Group In mid-1996, the HTML Math Editorial Review Board was formed after a meet- ing of the Digital Library Initiative brought many interested parties together. That Board expanded and, in 1997, became the W3C Math Working Group. Over the years, the Working Group’s membership has included representa- tives from many organizations: the American Mathematical Society, the Boe- ing Company, Design Science, Inc., Geometry Technologies, Inc., IBM Corporation, the French National Institute for Research in Computer Science and Control (INRIA), MacKichan Software, Inc., MATH.EDU, Inc., Microsoft Corporation, the Numerical Algorithms Group Ltd. (NAG), Radical Flow Inc., Stilo Technology, Universita di Bologna (Italy), University of Western Ontario (Canada), Waterloo Maple Inc., Wolfram Research, Inc., and others. MathML continues to be produced by the Math Working Group as part of W3C Math Activity. MathML Design Goals To the W3C, math expressions make up just one of several kinds of structured data that have to be integrated into the Web. Originally, to integrate math expressions, they envisioned just a simple, straightforward extension to HTML, one that could be easily implemented in Web browsers, office suites, and other applications. The design goals included the following: ■■ Easy to implement and easy to use. ■■ Sophisticated enough to meet all math-related requirements. ■■ Able to interact with other applications so that expressions do not lose their meaning and do not have to be reentered or reconstructed. ■■ Capable of producing high-quality renderings in several media. ■■ Markup that embeds seamlessly into Web page documents. ■■ Existing authoring tools should require few modifications to generate MathML. ■■ Flexible enough to provide for tailored input and output; a sort of “all things to all developers” solution. 620 Chapter 16 422541 Ch16.qxd 6/19/03 10:14 AM Page 620 Check the W3C Goals, too. The design goals in the preceding list paraphrase those found at the W3C MathML Web site and in other literature. If you want to see a listing of the actual documented W3C MathML design goals, visit www.w3.org/TR/ 2002/WD-MathML2-20021219/chapter1.html#intro.goals. As the Math Working Group’s work progressed, it became apparent that the answer did not lie in extending HTML, but in extending XMLinstead. The W3C’s Math Working Group produced the following W3C MathML Recommendations: ■■ Mathematical Markup Language (MathML) 1.0 Specification (MathML 1.0), which was endorsed by the W3C in April 1998. ■■ Mathematical Markup Language (MathML) 1.01 Specification, endorsed as a revision of MathML 1.0 in July 1999. ■■ Mathematical Markup Language (MathML) Version 2.0 (MathML 2.0), endorsed in February 2001. ■■ The first Working Draft of Mathematical Markup Language (MathML) Version 2.0 (2nd Edition)—the second edition of MathML 2.0—in December 2002. The second edition of MathML 2.0 is a reissue of MathML 2.0 and incorpo- rates corrections resulting from MathML 2.0 errata into the main text. Also, for the first time, it includes a W3C XML Schema. In this version of MathML, all examples are included in the text (see it at www.w3.org/TR/2002/WD- MathML2-20021219/). MathML Implementations A veritable explosion of MathML implementations has occurred in the past year or two. We demonstrate three implementations (Amaya, EzMath, and WebEQ) in the lab exercises. For a comprehensive list of MathML implemen- tation, please visit the W3C MathML Software Web page (www.w3.org/ Math/implementations.html). However, please read the following caution. If you are looking for a MathML application/implementation, be careful to read the descriptions attached to those listed on the MathML Software Web page. Some are compliant with the most up-to-date MathML specifications (at this writing, MathML 2.0); some only comply with older versions, like MathML 1.01 or 1.0. Others provide both content and presentation markup, while others provide only one or the other. MathML 621 422541 Ch16.qxd 6/19/03 10:14 AM Page 621 To obtain a list of Web browsers that display MathML expressions, check the list provided by the W3C at their Putting Mathematics on the Web with MathML Web page at www.w3.org/Math/XSL/. MathML document validation services are available at the W3C, too. These provide the MarkUp Validation Service at validator.w3.org/ or the original W3C MathML validation service at www.w3.org/Math/validator/. These validation services are especially handy if the editor you use does not validate your code. What Is MathML? MathML consists of XML tags that can be used to mark up expressions so that they display properly and maintain their semantics. Approximately 30 of its elements are presentation elements that describe notational structures. Another 150 or so elements (the content elements) specify the intended meaning of math expressions. MathML also has interface elements (the main one is the <math> element) that facilitate the embedding of MathML into Web page documents. MathML can be used to encode math expressions for the following: ■■ Presentation in high-quality visual displays ■■ Mathematical semantics, to be used with applications where semantics play a major role (as in scientific software or voice synthesis) MathML expressions can be searched, indexed, and manipulated with a sci- entific or mathematical application; rendered with Web browsers; edited with office applications; displayed with projectors; and printed with printers or plotters. MathML is legible to humans but is not primarily intended for direct use by developers. In most cases, coding MathML data documents can be very complex—especially when a developer wishes to combine presentation and content elements—thus, it is better left to equation editors, conversion pro- grams, and other specialized applications. The W3C recognized early that any mathematical expression language that met all the design requirements would be complex. They concluded that a lay- ered architecture approach, such as that represented in Figure 16.2, would be appropriate. The bottom layer—Layer 1—provides a set of general, yet powerful platform-independent tools that Layer 2 applications use to exchange, process, encode, and render expressions. MathML constitutes Layer 1, since its features define a standard for interoperability, ease of implementation, ease of process- ing and rendering, and ease of maintenance. MathML is called a low-level XML application because its specification serves as a model and stimulus for writing and coordinating other math expression applications. 622 Chapter 16 422541 Ch16.qxd 6/19/03 10:14 AM Page 622 Figure 16.2 Layered architecture model. The top layer of the Layered Architecture Model—Layer 2—consists of the specialized software tools used to generate coded mathematical data and expressions, such as those listed at the W3C’s MathML Software page at www.w3.org/Math/implementations.html. When you read the descriptions on that Web page, you see that the applications are fairly specialized, aimed at specific user groups or toward accomplishing specific tasks. In fact, some of the MathML-compliant applications listed at the W3C Web site are already integrated into other office and technical application suites. The Logical Structure of a MathML Document If you build a dedicated MathML document, it should come as no surprise that it must have a prolog and root data element, just like other XML-related documents. The Prolog The only mandatory statement is the XML declaration, which should resemble: <? xml version=”1.0” encoding=”iso-8859-1” ?> All other statements are considered optional. However, to achieve various objectives, you may want to include document type declarations (DTDs), pro- cessing instructions (PIs), or comments. MathML DTDs or Schemas MathML does not provide the capability to create your own arbitrarily named element types. However, the W3C Math Working Group works continually to create new element types to provide us with more flexibility so that you can Layer 2 — Specialized Software Applications C o n T e X t B r a M a N e t A m a y a M a t h T y p e M a t h P l a y e r WebEQ J a d e E - L i t e E z M a t h G t k M a t h V i e w t e c h e x p l o r e r J E u c l i d S c i e n t i f i c W o r k p l a c e M a p l e M a t h c a d M a t h e m a t i c a M a t h M L t o S V G m a t h m l e d M o z i l l a M e d i t o r L a T e X 2 H T M L P u b l i c o n S o f t L i n e t b o o k T e X 4 h t T I M a t h M L T t M Y a r o s h e v i c h ' s t r a n s l a t o r w e b M a t h e m a t i c a W e M Layer 1 — MathML "Power Tools" e x c h a n g e p r o c e s s e n c o d e r e n d e r I n t e r n e t E x p l o r e r ORCCA O p e n M a t h Omega xmltex M at h C a d REDUCE S t i l o M a t h w r i t e r MathMLc2p i M a t h m m l c t o p MathML 623 422541 Ch16.qxd 6/19/03 10:14 AM Page 623 display and manipulate more math expressions. Those element types and other components are declared in two DTDs and one schema. The two MathML.DTDs correspond to MathML 1.01 and MathML 2.0. The schema was introduced with MathML 2.0, second edition. You can view and copy them from the following Web sites: ■■ DTD for MathML 1.01: www.w3.org/TR/REC-MathML/ appendixA.html ■■ DTD for MathML 2.0: www.w3.org/TR/2002/WD-MathML2- 20021219/appendixa.html#parsing.dtd ■■ Schema for MathML 2.0: www.w3.org/Math/XMLSchema/ mathml2/mathml2.xsd To create a MathML-dedicated data document, include the following in the DTD statement: <!DOCTYPE math PUBLIC “-//W3C//DTD MathML 2.0//EN” “http://www.w3.org/Math/DTD/mathml2/mathml2.dtd”> If you copy the DTD to a local site, you should provide the appropriate URI instead of the www.w3.org URI that appears in the third line of code. Most of the time, however, your MathML expressions will not require their own dedicated document. If the MathML expression will be used in an XHTML document, you can take advantage of the XHTML DTD, extended with this MathML module. This DTD includes all the necessary declarations included in one file. To use it, insert the following doctype declaration: <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN” “http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd”> Again, if you copied the DTD to a local site, you should provide the appro- priate URI. You can also validate MathML expressions using the XML Schema for MathML, located at www.w3.org/Math/XMLSchema/mathml2/mathml2 .xsd. Although the declaration does not appear in the prolog, we think it’s still appropriate to mention it here. Thus, to link our MathML expressions to the XML Schema for MathML, use the following declarations in the <math> element: <mml:math xmlns:mml=”http://www.w3.org/1998/Math/MathML” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://www.w3.org/1998/Math/MathML http://www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd”> </mml:math> 624 Chapter 16 422541 Ch16.qxd 6/19/03 10:14 AM Page 624 If you need to review these terms, refer back to Chapter 5, “XML Schemas.” Remember that the value of the schemaLocation attribute is a pair of URIs. The first is the MathML namespace URI; the second, the location of the schema for that namespace. If you use a local copy of the schema, you must adjust the sec- ond URI accordingly. If you need to validate your MathML documents, validation services are available from the W3C. Please refer back to the MathML Implementations sec- tion earlier in this chapter. MathML and Style Sheets If you wish to use MathML in a dedicated document or in an XHTML docu- ment, insert the following processing instruction into the prolog: <?xml-stylesheet type=”text/xsl” href=”http://www.w3.org/Math/XSL/mathml.xsl”?> <html xmlns=” Unfortunately, because of its security configuration, Internet Explorer will not allow an XSLT style sheet to be applied to a data document unless both documents are located on the same server. If that is possible, and the expres- sion will be displayed without connecting to the Internet, consider using the following: <?xml-stylesheet type=”text/xsl” href=”mathml.xsl”?> For further information regarding styles and other MathML display issues, please visit the W3C’s Putting Mathematics on the Web with MathML Web page at www.w3.org/Math/XSL/. MathML Markup Specifications MathML markup consists of presentation elements, content elements, and interface elements. Some specifications pertain to all MathML elements, and some pertain to each of the three component types. Two main W3C markup specifications exist: MathML 1.0 and MathML 2.0. If you create small, uncomplicated math expressions according to either, the results are similar. Differences begin to appear when you try to create more complex expressions. However, even with fairly simple expressions, you can see differences between the MathML 1.0 and MathML 2.0 specifications. For example, look at the MathML presentation markup examples in Figure 16.3. MathML 625 422541 Ch16.qxd 6/19/03 10:14 AM Page 625 The <math> Element In Figure 16.3, all three of the MathML 2.0-compliant presentation markup examples contain top-level <math> elements, but the MathML 1.0 example doesn’t. MathML 2.0 specifies the need for a single root <math> element, which provides a number of improvements: ■■ It provides for an island of MathML markup within a Web page docu- ment, resolves some presentation issues, and produces improvements in functionality and interoperability. ■■ It provides an attachment point for information, which affects a MathML expression as a whole (for example, in the future, a <math> element will be the logical place to attach style sheet or macro informa- tion, when these facilities become available for MathML). Figure 16.3 Presentation markup comparison: MathML 1.0 versus MathML 2.0. <mrow> <mi>A</mi><mo>=</mo><mi>&pi;</mi> <msup> <mi>r</mi> <mn>2</mn> </msup> </mrow> <m:math display='block'> <m:mrow> <m:mi>A</m:mi><m:mo>=</m:mo><m:mi>&pi;</m:mi> <m:msup> <m:mi>r</m:mi> <m:mn>2</m:mn> </m:msup> </m:mrow> </m:math> <math display='block' xmlns='http://www.w3.org/1998/Math/MathML'> <mrow> <mi>A</mi><mo>=</mo><mi>&pi;</mi> <msup> <mi>r</mi> <mn>2</mn> </msup> </mrow> </math> <math display='block'> <mrow> <mi>A</mi><mo>=</mo><mi>&pi;</mi> <msup> <mi>r</mi> <mn>2</mn> </msup> </mrow> </math> MathML 1.0/1.01 MathML 2.0 No namespace MathML 2.0 m namespace MathML 2.0 Default namespace A = πr 2 626 Chapter 16 422541 Ch16.qxd 6/19/03 10:14 AM Page 626 ■■ If the MathML document will be used by an application that conforms to the W3C Namespaces in XML Recommendation, you can place a MathML namespace declaration in the <math> element start tag, since the <math> element is an interface element. The namespace syntax would resemble the following: <math xmlns=”http://www.w3.org/1998/Math/MathML”> ■■ It can contain various attributes that affect all the elements nested within the <math> element’s entire enclosed expression (inward- looking attributes). ■■ It can contain various attributes that may be used to integrate with third-party rendering software, to render expressions properly in a browser, and to integrate them into XHTML documents (outward- looking attributes). Table 16.1 lists the <math> element’s attributes. Table 16.1 The <math> Element Attributes ATTRIBUTE EXPLANATION Inward-looking attributes class=”value” Provided for CSS support. style=”value” Provided for CSS support. id=”value” Provided for CSS support. macros=”URI” Provides a pointer to external macro definition files. Macros are not part of the MathML specification, but a macro mechanism is anticipated as a future extension to MathML. mode=”display/inline” Specifies whether the enclosed MathML expression should be rendered in a display style or an in-line style. The default is mode=”inline”. Deprecated in MathML 2.0. display=”block/inline” Replaces the deprecated mode attribute. Specifies whether the enclosed MathML expression should be rendered in a display style or an in-line style. Allowed values are block and inline (default). xref=”URI” With id, provided for use with XSL processing. (continued) MathML 627 422541 Ch16.qxd 6/19/03 10:14 AM Page 627 [...]... accelerating Implementations are proliferating MathML shows great promise as it begins to answer issues that have faced technical publishers for many years and the Internet since its inception Following are some key concepts to remember about the MathML specification: ■ ■ The W3C defines MathML as a “ .specification for describing mathematics as a basis for machine-to-machine communication It provides a. .. to link to non-Windows binary code You must use the executable Windows code for this lab MathML 3 Click the amaya-WinNT-7. 2a. exe link 4 Download and save the executable file to your hard disk 5 Go to the directory where the amaya-WinNT-7. 2a. exe file is located and double-click the file to start the installation 6 Accept all defaults during the installation 7 Reboot if necessary 8 Start the Amaya editor... to a base Attaches an underscript to a base Attaches an underscript-overscript pair to a base (continued) 631 632 Chapter 16 Table 16.2 (continued) ELEMENT NAME EXPLANATION Table and matrix elements For matrix, array, and other tablelike mathematical notation; similar to HTML table elements except that, with these, you can use specialized attributes for finer layout control ... clicking Start, Programs, Amaya, Amaya 9 On the top menu bar, go to File, New, New MathML document 10 Rename the file from New.mml to MathML-Lab1.mml and click Confirm 11 Enter your example area of a circle expression: A equals pi “r” squared To do this, first make sure that the Amaya editor window, now named MathML-Lab1.mml, is the active window Type in an uppercase letter A If the window is inactive,... math editors are somewhat similar to use The approach we chose for these labs is to demonstrate a few editors and demonstrate some very basic instruction so that you can quickly become familiar with them and productive Lab 16.1: Install and Use Amaya for MathML In this lab, we download, install, and use the presentation-oriented Amaya editor, which was developed and is currently maintained by the W3C... take a look at it to see what it can do Be aware that currently only Netscape, Mozilla, and Amaya itself can display the MathML expressions we create with it 1 Activate a browser and go to www.w3.org/Amaya/ 2 Locate the link on the side navigation bar called Distributions under the Download Amaya section The most current version as of this writing is 7.2 Download the most current release shown Be careful... eventual transcription into input for computer applications that calculate and otherwise manipulate the expressions Content markup looks like presentation markup, but it uses a different set of 150 elements and an even greater number of attributes to convey the same expressions while maintaining their mathematical semantics The MathML content markup elements available with MathML 2.0 are listed in Table... horizontally Forms a square root sign (radical without an index) Style change Script and limit schemata elements Positions one or more scripts around a base level script Attaches prescripts and tensor indices to a base Attaches an overscript to a base Attaches a subscript to a base Attaches a subscript-superscript pair to a base Attaches a. .. were in the opposite order (for example, A, instead of A), that is postfix notation When we use pen and paper for arithmetic calculations, we usually use a scheme called infix notation, in which the operands and operators are mixed In fact, the familiar A= πr2 is an example of infix notation Consider the PN processing algorithm as a series of scans from left to right, as... Alignment group marker (declared empty element) Alignment point marker (declared empty element) A row in a table or matrix with a label or equation number Table or matrix One entry in a table or matrix Row in a table or matrix Enlivening expression element(s) Provides a mechanism for binding actions to expressions or subexpressions Binds actions . process- ing and rendering, and ease of maintenance. MathML is called a low-level XML application because its specification serves as a model and stimulus for writing and coordinating other math expression. be used by an application that conforms to the W3C Namespaces in XML Recommendation, you can place a MathML namespace declaration in the <math> element start tag, since the <math> element. following W3C MathML Recommendations: ■■ Mathematical Markup Language (MathML) 1.0 Specification (MathML 1.0), which was endorsed by the W3C in April 1998. ■■ Mathematical Markup Language (MathML)

Ngày đăng: 14/08/2014, 11:21

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan