Jump to content
Guest zhangbaodi

A question in dtd tutorial example

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

Share this post


Link to post
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.

Share this post


Link to post
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".

Share this post


Link to post
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".

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...