/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to xml/info/dtd.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
***************************************************
 
2
***** .dtd (Document Type Definition)
 
3
***************************************************
 
4
* Including in XML
 
5
******************
 
6
<?xml version = "1.0" encoding = "UTF-8"?>
 
7
_
 
8
|<!DOCTYPE address SYSTEM "address.dtd"> 
 
9
|<!DOCTYPE address PUBLIC "URL/address.dtd">
 
10
_
 
11
....
 
12
*********************************
 
13
* Something like class definition
 
14
*********************************
 
15
<?xml version='1.0' encoding='UTF-8' ?>
 
16
<!ELEMENT name (first,midle,last)>
 
17
<!ELEMENT contact (address, phone)>
 
18
 
 
19
<!ELEMENT first (#PCDATA)>
 
20
<!ELEMENT middle (#PCDATA)>
 
21
<!ELEMENT last (#PCDATA)>
 
22
<!ELEMENT address (#PCDATA)>
 
23
<!ELEMENT phone (#PCDATA)>
 
24
*******************
 
25
* adding attributes
 
26
*******************
 
27
<!ATTLIST name type (current|past) #REQUIRED id ID #IMPLIED
 
28
<!ATTLIST mobile type CDATA #IMPLIED
 
29
  name          - Element name for which specifiying attributes
 
30
  type,id       - Attribute names
 
31
 
 
32
  current|past  - Possible values (enumeration type)
 
33
  CDATA         - String
 
34
  ID            - Name(letters,_) which UNIQUE for xml document
 
35
  IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS
 
36
 
 
37
  #REQUIRED     - attribute is required
 
38
  #IMPLIED      - attribute isn't required
 
39
 
 
40
****************
 
41
* Optional nodes
 
42
****************
 
43
  ?     Optional
 
44
  +     Repeatable
 
45
  *     Optional and Repeatable
 
46
  |     OR
 
47
For example:
 
48
<!ELEMENT name(first,middle?,last)>
 
49
<!ELEMENT contact(phone|mobile,address)>
 
50
 
 
51
********
 
52
* Entity
 
53
********
 
54
** Something like #define, once defined in .dtd, then can be referenced from
 
55
** later in .dtd or .xml documents, for example author of dtd:
 
56
<!ENTITY dtd-author "Kain the Dragon">
 
57
** Referencing in .xml document
 
58
&dtd-authord
 
59
 
 
60
** Or more complex (list of elements)
 
61
<!ENTITY %person "name, contact">
 
62
<!ELEMENT Manager (%person;)>
 
63
<!ELEMENT Admin (%person;)>
 
64
 
 
65
** Or list of attributes
 
66
<!ATTLIST % name  attrname datatype #use>
 
67
** Yes ATTLIST not ENTITY (only differs from ATTLIST with '%' symbol)
 
68
** Later may be used
 
69
<!ATTLIST Manager %name;>
 
70
 
 
71
** Including external file with entities
 
72
<!ENTITY % name SYSTEM "filename.dtd"> 
 
73
** or from web
 
74
<!ENTITY % name PUBLIC "http://URL">
 
75
 
 
76
*************
 
77
* Comentaries
 
78
*************
 
79
<!-- multiline comment -->
 
80