Dear Betty and Dan,
Just a comment. Instead of using,
<!DOCTYPE test SYSTEM "test.dtd" [
<!ELEMENT test (#PCDATA|elm1|elm2)* >
<!ELEMENT elm1 (#PCDATA)>
<!ELEMENT elm2 (#PCDATA)>
]>
you should use,
<!DOCTYPE test [
<!ELEMENT test (#PCDATA|elm1|elm2)* >
<!ELEMENT elm1 (#PCDATA)>
<!ELEMENT elm2 (#PCDATA)>
]>
The reason is that you have already included the DTD inside the document, an
internal subset. What will happen if you still have the SYSTEM declaration in
DOCTYPE is that it will search for a "test.dtd" and return a "file not found"
error.
On the other hand you can use,
<!DOCTYPE test SYSTEM "test.dtd">
and define the elements in a file saved as TEST.DTD as,
<!ELEMENT test (#PCDATA|elm1|elm2)* >
<!ELEMENT elm1 (#PCDATA)>
<!ELEMENT elm2 (#PCDATA)>
To add to what Betty has said below, there is another book "The XML Handbook" by
Dr. Charles F. Goldfarb and Paul Prescod (ISBN 0-13-014714-1). This
"Interesting to Read" book is really a handbook which you can always refer to,
when you are in doubt. It has what you want.
Thanks,
Ajith Perera,
Innodata (www.innodata.com)
____________________Reply Separator____________________
Subject: Re: DTD question
Author: "Betty L. Harvey" <[EMAIL PROTECTED]>
Date: 9/19/01 5:42 PM
Trust me, they are wrong. Just doing a cursory look at the questions
and their answers, that isn't the only question they have wrong!
If you want to write XML DTD's I would recommend the book "Structuring XML
Documents" by David Megginson. This is an older book but is a good
resource for XML DTD's. Dave has many years of experience in developing
XML and is the original author of SAX. I would be a little bit leery of
learning how to develop DTD's from on-line sources. I have seen many
wrong examples and I have seen 'standard' DTD's for major organizations
that are wrong and won't parse.
I have also picked up many XML books that have had wrong code.
Betty
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Betty Harvey, XML Consultant, | Phone: 410-787-9200 FAX: 9830
Electronic Commerce Connection, Inc. |
[EMAIL PROTECTED] | Washington,DC SGML/XML Users Grp
URL: http://www.eccnet.com | http://www.eccnet.com/xmlug/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
On Wed, 19 Sep 2001, Zhong-Dan LAN wrote:
> Thx for your response.
>
> I agree with you. I think a) is the only correct answer among the three. But
> the solution that I found from javaranch is a) and c). Go to
> http://www.javaranch.com/xml/XML_DTD.htm, it is the question 3).
>
> Dan
>
>
> >From: "Betty L. Harvey" <[EMAIL PROTECTED]>
> >To: Zhong-Dan LAN <[EMAIL PROTECTED]>
> >CC: <[EMAIL PROTECTED]>
> >Subject: Re: DTD question
> >Date: Wed, 19 Sep 2001 17:22:57 -0400 (EDT)
> >
> >
> >I don't know what you want to do, but only a
> >correct answer.
> >
> >C is not correct because your element declaration is outside
> >the document declaration subset. Your DOCTYPE element has to
> >match your root element. In C your root element is called
> >'test.dtd'.
> >
> >I think what want is:
> >
> ><!DOCTYPE test SYSTEM "test.dtd" [
> >
> ><!ELEMENT test (#PCDATA|elm1|elm2)* >
> >
> ><!ELEMENT elm1 (#PCDATA)>
> ><!ELEMENT elm2 (#PCDATA)>
> >
> >]>
> >
> >Hope this helps.
> >
> >Betty
> >
> >/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
> >Betty Harvey, XML Consultant, | Phone: 410-787-9200 FAX: 9830
> >Electronic Commerce Connection, Inc. |
> >[EMAIL PROTECTED] | Washington,DC SGML/XML Users Grp
> >URL: http://www.eccnet.com | http://www.eccnet.com/xmlug/
> >/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
> >
> >On Wed, 19 Sep 2001, Zhong-Dan LAN wrote:
> >
> > > I found the following question:
> > >
> > > 3. Which of the following code is valid?
> > >
> > > a)<!DOCTYPE test [ <!ELEMENT test (#PCDATA)>]>
> > > b)<!DOCTYPE test [ <!ELEMENT test.dtd (elm1|elm2|#PCDATA) >]>
> > > c)<!DOC
> >TYPE test [ <!ELEMENT test.dtd (#PCDATA|elm1|elm2)* >]>
> > > <!ELEMENT elm1 (#PCDATA)>
> > > <!ELEMENT elm2 (#PCDATA)>
> > > d)<!DOCTYPE test [ <!ELEMENT test test (#PCDATA)>]>
> > > e)<!DOCTYPE test [ <!ELEMENT test "test" (#PCDATA)>]>
> > >
> > > Answer is a) and c). But I think a) is the only
> > > correct choice, because the declaration should start from the
> > > root element test.
> > >
> > > Anyone can help me out?
> > >
> > > Thx.
> > >
> > > Dan
> > >
> > >
> > >
> > >
> > > _________________________________________________________________
> > > Get your FREE download of MSN Explorer at
> >http://explorer.msn.com/intl.asp
> > >
> > >
> > >
> > > ------ XML/edi Group Discussion List ------
> > > Homepage = http://www.XMLedi-Group.org
> > >
> > > Unsubscribe = send email to: [EMAIL PROTECTED]
> > > Leave the subject and body of the message blank
> > >
> > > Questions/requests: [EMAIL PROTECTED]
> > >
> > > To receive only one message per day (digest format)
> > > send the following message to [EMAIL PROTECTED],
> > > (leave the subject line blank)
> > >
> > > digest xmledi-group your-email-address
> > >
> > > To join the XML/edi Group complete the form located at:
> > > http://www.xmledi-group.org/xmledigroup/mail1.htm
> > >
> > >
> >
> >--
> >
> >
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
--
------ XML/edi Group Discussion List ------
Homepage = http://www.XMLedi-Group.org
Unsubscribe = send email to: [EMAIL PROTECTED]
Leave the subject and body of the message blank
Questions/requests: [EMAIL PROTECTED]
To receive only one message per day (digest format)
send the following message to [EMAIL PROTECTED],
(leave the subject line blank)
digest xmledi-group your-email-address
To join the XML/edi Group complete the form located at:
http://www.xmledi-group.org/xmledigroup/mail1.htm
------ XML/edi Group Discussion List ------
Homepage = http://www.XMLedi-Group.org
Unsubscribe = send email to: [EMAIL PROTECTED]
Leave the subject and body of the message blank
Questions/requests: [EMAIL PROTECTED]
To receive only one message per day (digest format)
send the following message to [EMAIL PROTECTED],
(leave the subject line blank)
digest xmledi-group your-email-address
To join the XML/edi Group complete the form located at:
http://www.xmledi-group.org/xmledigroup/mail1.htm