This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Transfer Learning for Natural Language Processing (MEAP) and have Paul Azunre on-line!
See this thread for details.
Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

DTD for this XML

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am looking for the DTD for this XML. Can you please help me out.
Thx.
<pre>

<letter>
Dear Mr.<name>John Smith</name>.
Your order <orderid>1032</orderid>
will be shipped on <shipdate>2001-07-13</shipdate>.
</letter>
</pre>
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<!DOCTYPE pre (letter, name, orderid, shipdate)
<!ATTLIST letter (#PCDATA)
name (#PCDATA)
orderid (#PCDATA)
shipdate (#PCDATA) >
I am NOT sure of this. plz verify with experts present here. but this should give u an general idea.
regards
sridhar
---------------------------------------
aspirant for xml 141 cert.
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the correct DTD one which was posted previously is not correct
<!ELEMENT pre(letter)>
<!ELEMENT letter(#PCDATA|name|orderid|shipdate)>
<!ELEMENT name(#PCDATA)>
<!ELEMENT orderid(#PCDATA)>
<!ELEMENT shipdate(#PCDATA)>
This is typically mixing of element contents
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Syed,
there is a slight problem with your DTD. As you can see mixed content can be found several times in the XML document provided by Ramesh.
Here is the correct DTD:

Note that:
- There's a star (*) after (#PCDATA | name | orderid | shipdate) since #PCDATA can be found at different locations between the name, orderid and shipdate elements.
- There's no "pre" element. I think Ramesh wanted preformat the XML document.
- There's a space between the element name and its content type
Here is the whole document with DTD.
 
Sridhar Kilambi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Valentin for the clarification .
regards
sridhar
------------------------------------------
aspirant for xml 141 cert.
[ December 30, 2002: Message edited by: Sridhar Kilambi ]
 
Syed AliRaza Zaidi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Valentin,
Yes Valentin good job yours is the correct one I was thinking about using * but I left out Thanks for correcting me by the way.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.
Happy to help
 
Ramesh Balasubramanian
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all your response, Especially to
Valentin Crettaz. .
Actually my doubt was for the #PCDATA appearing in between each tag.
My understanding is
* means, the one mentioned in "(" to ")" can
appear 0 to n times.
And "(#PCDATA | name | orderid | shipdate)"
implies that any one of them
can appear. i.e. #PCDATA or name or
orderid or shipdate in an
XML instance.

Can you please explain.
Thx.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
( a | b | c)* means that any one of a, b or c can appear any number of times, that is, all the following productions are valid:
aaa
abc
aabac
abbbb
c
b
ab
ac
...
Does this clear your doubts?
Please see the following section of the DTD specification which explains how mixed content can be specified:
DTD Spec - Mixed content
 
Ramesh Balasubramanian
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all thanks for such a quick reply.
Question:
I) Just (a|b|c)
Does this mean it can have
a
b
c
Can it also have
ab
ac
bc
Can it have in reverse order like
ba
ca
cb
II) For (a|b|c)*
Are these valid?
c
ccb
ccbccbbaac
...
Does that mean that "a" or "b" or "c" can appear any number of times in any order?
Thx for your patience
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The valid productions in the first case, i.e. (a | b | c) are:
a
b
c
<nothing>
The valid productions in the second case, i.e. (a | b | c)* are:
any combinations (actually an infinity of possibilities) of a, b and c plus the empty production
 
Ramesh Balasubramanian
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Valentin Crettaz.
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't (a | b | c) mean you must have exactly one of a, b, or c? Empty isn't allowed.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you are right, Ron. Sorry about that
I must need a break
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you want "a, b, c, or nothing" you would say
(a | b | c)?
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic