Jump to content

A question in dtd tutorial example


Guest zhangbaodi

Recommended Posts

Guest zhangbaodi

I'm reading dtd tutorial,I see an exampleDeclaring mixed content<!ELEMENT note (#PCDATA|to|from|header|message)*>I think it is same as<!ELEMENT note (#PCDATA)*> Is that right ?If not,why

Link to comment
Share on other sites

As far as I'm aware, the things after #PCDATA declare the elements that could only occur once as childs of that element. If you don't include them, then all declared elements could be placed more then once as childs of note. For example, with

<!ELEMENT note (#PCDATA)*><!ELEMENT to	  (#PCDATA)><!ELEMENT from	(#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body	(#PCDATA)>

the following XMLs are valid:

<note><to>Tove</to><from>Jani</from><body>Don't forget me this weekend!</body></note>

<note><to>Tove</to><to>Hege</to><from>Jani</from><from>Kaijim</from><from>Stale</from><heading>Reminder</heading><body>Don't forget me this weekend!</body><body>Or I'll forget you.</body></note>

Whereas with

<!ELEMENT note (#PCDATA|to|from|header|message)*><!ELEMENT to	  (#PCDATA)><!ELEMENT from	(#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body	(#PCDATA)>

Only the first example is valid. I'm not sure though.

Link to comment
Share on other sites

hey!this<!ELEMENT note (#PCDATA|to|from|header|message)*>declares that the element "note" can have either character data or element to or element from or header or message.this example means that since note can contain any no. of character data or element "to" or element "from" or "header" or "message".

Link to comment
Share on other sites

hey!this<!ELEMENT note (#PCDATA|to|from|header|message)*>declares that the element "note" can have either character data...
Don't you mean "Parsable Character data", which btw practically means "any well formed XML data".
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...