tailieunhanh - XML Step by Step- P11

XML Step by Step- P11:Extensible Markup Language, or XML, is currently the most promising language for storing and exchanging information on the World Wide Web. Although Hypertext Markup Language (HTML) is presently the most common language used to create Web pages, HTML has a limited capacity for storing information. In contrast, because XML allows you to create your own elements, attributes, and document structure, you can use it to describe virtually any kind of information from a simple recipe to a complex database | 174 XML Step by Step You could limit the permissible content to a set of specific strings by deriving the element s type from xsd string using xsd enumeration facets as shown here xsd element name BINDING xsd simpleType xsd restriction base xsd string xsd enumeration value hardcover xsd enumeration value mass market paperback xsd enumeration value trade paperback xsd restriction xsd simpleType xsd element A BINDING element containing anything other than one of the three strings specified by the value attributes of the xsd enumeration elements would be invalid. As a final example you can require that an element s content or an attribute s value match a particular pattern of characters by restricting the xsd string type using the xsd pattern facet as shown in this declaration xsd element name ISBN xsd simpleType xsd restriction base xsd string xsd pattern value d 1 - d 4 - d 4 - d 1 xsd restriction xsd simpleType xsd element You assign the value attribute of the xsd pattern facet a description of the required pattern which is known as a regular expression. The regular expression in the preceding example requires the content to consist of one digit followed by a hyphen four digits another hyphen four digits another hyphen and a single digit. Hence the following would be a valid ISBN element ISBN 0-7356-1020-7 ISBN For a description of the regular expressions you can use with the xsd pattern element see Appendix D Regular Expressions in the XML Schema Part 0 Primer page at http TR xmlschema-0 . The specific facets you can use depend on the particular type you are restricting. For a complete list of all the different facets you can use to restrict each of the Chapter 7 Creating Valid XML Documents Using XML Schemas 175 built-in simple types see the appendix B Simple Types their Facets in the XML Schema Part 0 Primer page at http TR xmlschema-0 . tip As an alternative to using an xsd restriction element inside xsd simpleType to derive a new simple .

TỪ KHÓA LIÊN QUAN