• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

USAGE OF PIPE CHARACTER IN DTD

 
ZEESHAN AZIZ
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per Deitel p:142(N.B:This chapter is available on web) for the DTD
<!ELEMENT Box (jelly?, lemon*, ((creme|sugar)+ |glazed))>
a valid markup example is :
<Box>
<sugar>semi-sweet</sugar>
<creme>whipped<creame>
<sugar>sweet</sugar>
</BOX>

My understanding is that this Markup example given by Dietel is not correct. The reason being when we use pipe character (a|b) we mean either a or b, not both a and b (Reference: P. 140 Dietel).
If that be the case, in above markup we can have either creme or sugar, not both of them. Expert views please.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't overlook the + symbol, which allows the expression to repeat any number of times (after 1 initial occurrence). So
(creme|sugar)+
can be equivalent (for this case) to
(creme|sugar),(creme|sugar),(creme|sugar)
or
sugar,creme,sugar
 
ZEESHAN AZIZ
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim. I did realised the point I was ignoring. Thanks for pointing out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic