<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT a ((b|e)*)>
<!ELEMENT b ((c|f)*)>
<!ELEMENT e ((c|f|d)*)>
<!ELEMENT d (#PCDATA)>
<!ELEMENT f (#PCDATA)>
<!ELEMENT c (d?)>
\sigma = {a,b,c,d,e,f} \Q = {q_a,q_b,q_c,q_d,q_e,q_f} F= {q_a}
<a>
<b>
<c>
</c>
</b>
</a>
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT directory ((student|teacher)*)>
<!ELEMENT student (contact)>
<!ELEMENT teacher (contact)>
<!ELEMENT contact (Name,address)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT address (#PCDATA)>
```
# XML Schema
# regular tree Grammar
R = (N,T,S,P)
N = (A,B,C,D,E,F,G,H,I,J,K,L,M)
T = (shiporder,orderperson,shipto,name,address,country,item
, title,note,quantity,price)
S = (A)
P =
- A -> shiporder[B,C,H,M]
- B -> orderperson[epsilon]
- C -> shipto[D,E,F,G]
- D -> name[epsilon]
- E -> city[epsilon]
- F -> address[epsilon]
- G -> city[epsilon]
- H -> item[I,J,K,L]
- I -> title[epsilon]
- J -> note[epsilon]
- K -> qty[epsilon]
- L -> price[epsilon]
# DTD and RTG
## 1
The grammar allows only patient* follow doctors * therefore there is a valid DTD D file that cannot be generated by the RTG G.
## 2
The opposite is true because of the flexibility of dtd syntax (correct even if there are more attributes)
## 3
G writen in DTD
<!ELEMENT files ((file|patient|Doctor))> <!ELEMENT Doctor (person)> <!ELEMENT patient <!ELEMENT person (FName,LName,Tel)> <!ELEMENT file ((file|person|Doctor))>
THIS IS NOT POSSIBLE -> CANNOT DEFINE TWO PERSON FOR PATIENT AND DOCTOR
## 4