XML (eXtended Markup Language) là một cách rất phổ biến của thể hiện định dạng của dữ liệu. XML bao gồm các thẻ giới thiệu các thuộc tính và giá trị liên quan trong một ký hiệu đơn giản lồng nhau và tuần tự. Hãy xem xét ví dụ trong hình 10-4 - (a) cho thấy một mô tả XML của một giao diện được mô tả trong (b). | Illustration XML extended Markup Language is a very popular way of expressing the format of data. XML consists of tags that introduce attributes and associated values in a simple nested and sequential notation. Consider the example in Figure 10-4 a shows an XML description of a GUI depicted in b . The XML corresponds to the controls and parameters of a Windows form. Thus the following TextBox Top 10 Left 100 Name eurobox specifies a TextBox control followed by pixel values for its top-left corner and the name by which it will be known in the program eurobox . The corresponding label at top 10 pixels has the text Paid on hols so that will be opposite the eurobox control when it is laid out on the form. Form Text Currency calculator Width 250 Height 180 I Label Top 10 Text Paid on hols I Label Top 40 Text charged I Label Top 70 Text Exchange rate is I Button Top 100 Name equals Text I TextBox Top 10 Left TOO Name eurobox I TextBox Top 40 Left 100 Name GBPbox I cTextBox Top 70 Left lOO Name ratebox I Button Top 100 Left 100 Name clear Text Reset Form Figure 10-4. Interpreter pattern illustration XML description of a GUI The XML specification is read into a program checked and interpreted into GUI objects to be displayed on the screen. Thus this example illustrates the essence of the Interpreter pattern. Grammars Languages can be expressed in other notations as well. A familiar form is a grammar of terms. Terms written in sequence must follow each other alternatives are indicated with a and repetition by recursive definitions. Given this scheme we could specify a grammar for the course rules laid out earlier in Example 10-2 as 234 Chapter 10 Behavioral Patterns Visitor Interpreter and Memento 1 course name restcourse 2 restcourse terminalpart nonterminalpart restcourse empty 3 nonterminalpart group terminalpart restterminalpart 4 terminalpart lab test group 5 restterminalpart terminalpart restterminalpart empty 6 group midterm exam 7 lab L weight 8 text T weight 9 .