Is this valid or not?

B

bo gusman

I'm just learning XML and am struggling with an example of an ELEMENT
definition at http://www.xmlfiles.com/dtd/dtd_elements.asp.
Specifically, the following is shown

<!ELEMENT note (to+,from,header,message*,#PCDATA)>

I do not believe that this is valid (by reading the spec at w3c.org),
and if I create a DTD/XML instance that uses it, it neither validates
using xmllint nor the online validator at
http://www.stg.brown.edu/service/xmlvalid/ (which apparently uses Xmlparse).

Would someone confirm for me that this is an invalid example or explain
why not?

Thanks!

Bo
 
D

David Carlisle

Would someone confirm for me that this is an invalid example or explain
why not?

It's invalid: #PCDATA has to come first and can only be used in a |
choice list not a , list the list must be used with a * occurrence
indiator.
(#PCDATA|aaa|bbb|ccc)*

There are other errors:
<!ELEMENT to (#CDATA)>
There is no #CDATA element content in XML. This should be #PCDATA.


David
 
T

Toni Uusitalo

bo gusman said:
I'm just learning XML and am struggling with an example of an ELEMENT
definition at http://www.xmlfiles.com/dtd/dtd_elements.asp.

This sites' examples are full of errors, actually too many - they can't be
typos etc.
I wonder what has happened but certainly examples aren't well-formed
XML element declarations.

Mr. Carlisle pointed out some errors but there's just too many like:

<!ELEMENT element-name (ANY)>

this one for example could be XML DTD trick question since it's
well-formed but I doubt it's what the writer intended to demonstrate.
Specifically, the following is shown

<!ELEMENT note (to+,from,header,message*,#PCDATA)>

I do not believe that this is valid (by reading the spec at w3c.org), and
if I create a DTD/XML instance that uses it, it neither validates using
xmllint nor the online validator at
http://www.stg.brown.edu/service/xmlvalid/ (which apparently uses
Xmlparse).

Would someone confirm for me that this is an invalid example or explain
why not?

with respect,
Toni Uusitalo
 
T

Toni Uusitalo

Toni Uusitalo said:
<!ELEMENT element-name (ANY)>

this one for example could be XML DTD trick question since it's
well-formed but I doubt it's what the writer intended to demonstrate.

under that example the page says:
"The keyword ANY declares an element with any content."
so it ISN'T what the writer tries to demonstrate.

ps. see http://www.zvon.org for good XML tutorials.

with respect,
Toni Uusitalo
 
S

Stanimir Stamenkov

/Toni Uusitalo/:
<!ELEMENT element-name (ANY)>

this one for example could be XML DTD trick question since it's
well-formed but I doubt it's what the writer intended to demonstrate.

It is not well-formed, nor

<!ELEMENT element-name (EMPTY)>

is. Both 'ANY' and 'EMPTY' (w/o the quotes) must appear without the
parentheses.

http://www.w3.org/TR/REC-xml/#IDAN43S
 
T

Toni Uusitalo

Stanimir Stamenkov said:
/Toni Uusitalo/:


It is not well-formed, nor

<!ELEMENT element-name (EMPTY)>

is. Both 'ANY' and 'EMPTY' (w/o the quotes) must appear without the
parentheses.

http://www.w3.org/TR/REC-xml/#IDAN43S

Both are well-formed, for example this is well-formed (and valid too):
<!DOCTYPE doc [
<!ELEMENT doc (EMPTY)>
<!ELEMENT EMPTY EMPTY>
]>
<doc><EMPTY/></doc>

That's the trick thing I mentioned. Not suitable for tutorial though ;-)

with respect,
Toni Uusitalo
 
S

Stanimir Stamenkov

/Toni Uusitalo/:
Both are well-formed, for example this is well-formed (and valid too):
<!DOCTYPE doc [
<!ELEMENT doc (EMPTY)>
<!ELEMENT EMPTY EMPTY>
]>
<doc><EMPTY/></doc>

That's the trick thing I mentioned. Not suitable for tutorial though ;-)

Ops - missed that one. You're absolutely right! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,838
Latest member
KandiceChi

Latest Threads

Top