wood burning stoves*
The moose likes Product and Other Certifications and the fly likes DTD for this XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "DTD for this XML" Watch "DTD for this XML" New topic
Author

DTD for this XML

Ramesh Balasubramanian
Greenhorn

Joined: Dec 29, 2002
Posts: 5
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>
Sridhar Kilambi
Greenhorn

Joined: Apr 19, 2002
Posts: 23
<!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.
Syed AliRaza Zaidi
Ranch Hand

Joined: May 12, 2002
Posts: 169
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
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Sridhar Kilambi
Greenhorn

Joined: Apr 19, 2002
Posts: 23
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

Joined: May 12, 2002
Posts: 169
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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
You are welcome.
Happy to help
Ramesh Balasubramanian
Greenhorn

Joined: Dec 29, 2002
Posts: 5
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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
( 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

Joined: Dec 29, 2002
Posts: 5
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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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

Joined: Dec 29, 2002
Posts: 5
Thanks a lot Valentin Crettaz.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Doesn't (a | b | c) mean you must have exactly one of a, b, or c? Empty isn't allowed.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
I guess you are right, Ron. Sorry about that
I must need a break
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
if you want "a, b, c, or nothing" you would say
(a | b | c)?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DTD for this XML
 
Similar Threads
html:select and pulling out value
logic problem using Dom Parser
Hibernate Bi Directional Problem
Invalid/Special XML characters such as &, ', "
query a database table using a foreign key ( where) using Hibernate.