Cisco Cisco Customer Voice Portal 8.0(1) Guida Dello Sviluppatore

Pagina di 98
C
HAPTER 
2:
 
C
ISCO 
U
NIFIED 
CVP
 
API
 
I
NTRODUCTION
V
OICE
XML
 
P
ROGRAMMING 
G
UIDE 
 
 
 
FOR 
C
ISCO 
U
NIFIED 
C
USTOMER 
V
OICE 
P
ORTAL 
R
ELEASE 
4.0(1) 
 
 
 
 
9
 
Figure 2-1 shows a sample DTD diagram that contains most of what can be found in an XML 
DTD. A DTD diagram is a graphical representation of a DTD that explains how an XML 
document is formatted. Due to the nature of XML, syntax is very important and DTD diagrams 
describe the syntax of an XML document. The diagram shows the hierarchical structure of XML 
by using a sideways tree display, listing tags and their child tags from left to right. The diagram 
shows the attributes of tags as well as how those tags can be added to their parent tags. 
In the above diagram, the root tag is named parent. Tags are denoted by a blue diamond in its 
box. parent has two attributes, attribute1 and attribute2 displayed in a red box emerging from 
the tag. An attribute is denoted by a blue circle in its box. The type of those attributes is shown in 
the gray section of the box. An enumerated type is an attribute whose value can be one of a select 
group of options (for example, “apple”, “orange” or “grape”). attribute2 is an optional attribute, 
denoted by a question mark to its left. attribute1 is a required attribute, denoted by having no 
symbol to its left. 
parent has four child tags that can appear within the encapsulating parent tag. This is denoted by 
a red bracket encapsulating all the tags. A bracket indicates that the child tags must appear within 
the parent tag in the order set in the diagram. A * next to the tag indicates it can appear from 0 to 
many times. A + indicates it can appear from 1 to many times (it must appear at least once in the 
document). A ? indicates it can appear from 0 to 1 time (if it appears, it can only once). 
The child2 tag contains its own tags, another_child1 and another_child2. This time, however, an 
angled red line is used to encapsulate the tags. This indicates that either one or the other can 
appear, but not both. child4 has a similar situation, but a + sign appears, indicating that the child 
tags can appear any number of times in any order, as long as there is at least one. 
The following is an example XML document that conforms to the above DTD: 
<parent attribute1=”something”>  
 
<child1 attribute=”a value”/> 
 <child1/> 
 <child2> 
 
 
<another_child1 attribute=”this is required”> 
 
 
 
Some value for the another_child1 tag. 
  </another_child1> 
  <another_child2> 
   The 
content 
for 
another_child2. 
  </another_child2> 
 </child2> 
 <child4> 
  <child1_of_child4/> 
  <child2_of_child4/> 
  <child2_of_child4/> 
  <child1_of_child4/> 
 </child4> 
</parent>