Groups | Blog | Home
all groups > dotnet xml > october 2005 >

dotnet xml : Can I have the same element declared within itself ?



sbeerav NO[at]SPAM gmail.com
10/26/2005 11:09:15 AM
Hi,

I wanted to know if it is legal in XML to declare an element within
itself. For example...

<A>
This is an element of type A.
<A>
This is another element of type A
</A>
</A>

Thanks,
Sri
Stan Kitsis [MSFT]
10/26/2005 11:13:47 AM
Yes, it is legal

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
[quoted text, click to view]

Peter Flynn
10/27/2005 12:19:47 AM
[quoted text, click to view]

Yes, it is very common.

But be careful with your design above, as it uses Mixed Content,
which is normally only required in text document applications.
Perhaps your labels are not supposed to imply the presence of text,
but it would be more usual for data-oriented applications to use, eg

<A>
<stuff>This is an element of type A.</stuff>
<A>
<stuff>This is another element of type A </stuff>
</A>
</A>

eg

<!ELEMENT A (stuff,A?)>
<!ELEMENT stuff (#PCDATA)>

///Peter
--
AddThis Social Bookmark Button