Page 261 -
P. 261

228     Part 3  •  the analysis Process

              Figure 8.17
              A document type definition
              for the customer XML
              document.                       < !DOCTYPE   customers     [
                                              < !ELEMENT   customers
                                              < !ELEMENT   customer
                                                                             (customer) + >
                                             < !ATTLIST   customer number
                                             < !ELEMENT   name               (name, address, current_balance, order*) >
                                                                             ID #REQUIRED>
                                             < !ATTLIST   name type
                                             < !ELEMENT   lastname           (lastname, firstname, middle_initial?) >
                                                                             (I  C)  #REQUIRED>
                                             < !ELEMENT   firstname
                                                                             (#PCDATA) >
                                                                            (#PCDATA) >
                                             < !ELEMENT   middle_initial
                                            < !ELEMENT   address
                                                                            (#PCDATA) >
                                            < !ELEMENT   street
                                            < !ELEMENT   apartment          (street, apartment?, city, state, zip, country) >
                                                                            (#PCDATA) >
                                            < !ELEMENT   city
                                                                            (#PCDATA) >
                                            < !ELEMENT   state
                                                                            (#PCDATA) >
                                            < !ELEMENT   zip
                                                                           (#PCDATA) >
                                           < !ELEMENT   country
                                                                           (#PCDATA) >
                                                                           (#PCDATA) >
                                           < !ELEMENT   current_balance
                                           < !ELEMENT   order
                                                                           (#PCDATA) >
                                           < !ATTLIST   order customer_number
                                           < !ELEMENT   order_number       (order_number, order_date, ship_date, total) >
                                                                           IDREF  #REQUIRED>
                                           < !ELEMENT   order_date
                                                                          (#PCDATA) >
                                                                          (#PCDATA) >
                                          < !ATTLIST   order_date format
                                          < !ELEMENT   payment
                                          < !ELEMENT   check              (mmddyyyy  yyyymmdd  ddmmyyyy)  #REQUIRED>
                                                                          (check  credit_card) >
                                          < !ELEMENT   credit_card
                                                                          (check_number) >
                                          < !ATTLIST   credit_card type
                                                                          (credit_card_number, expiration_date) >
                                          < !ELEMENT   credit_card_number
                                                                         (M  V  A  D  O)  #REQUIRED>
                                                                         (#PCDATA) >
                                         < !ELEMENT   expiration_date
                                         < !ELEMENT   payment_date
                                                                         (#PCDATA) >
                                                                         (#PCDATA) >
                                         < !ATTLIST   payment_date format
                                         < !ELEMENT   payment_amt
                                                   ] >                   (mmddyyyy  yyyymmdd  ddmmyyyy)  #REQUIRED>
                                                                         (#PCDATA) >
                                         be present in an ID somewhere in the document. An attribute list containing values in paren-
                                         theses means that the attribute must contain one of the values. A DTD definition <!ATTLIST
                                         credit_card type (M|V|A|D|O) #REQUIRED> means that the credit card type must be either an
                                         M, V, A, D, or O.
                                         XML Schemas
                                         A schema is another, more precise way to define the content of an XML document. Schemas
                                         may include the exact number of times an element may occur as well as the type of data within
                                         elements, such as character or numeric values, including the length of the element, limits on the
                                         data, and the number of places to the left and right of a decimal number.
                                             A data dictionary is an excellent starting point for developing an XML document and a
                                         document type of definition or schema. The advantage of using XML to define data is that, in
                                         the XML format, data are stored in a pure text format and not dependent on any proprietary
                                         software. The document may be easily validated and transformed into many different output
                                         formats.
                                             Industry groups or organizations may be involved in defining an industry-specific XML
                                         structure so that all involved parties understand what the data mean. This is very important when
                                         an element name may have several meanings. An example is “state,” which may mean a postal
                                         state abbreviation or the state of an order or account. Examples of industry-specific XML docu-
                                         ment type definitions and schemas may be found at www.xml.org.
   256   257   258   259   260   261   262   263   264   265   266