Lists Home |
Date Index |
In DTDs you cannot have two elements with the same name.
You need to go
<!ELEMENT item ( #PCDATA | Note)* >
which is loose enough to model both.
XML DTDs are not very powerful. They provide an 80/20 way to model the contents
of an element type, but frequently there will be constraints that cannot be modelled.
The other factor is that if you have two elements of the same name, your processing
software must cope with the differences, by providing some kind of context-checking.
That may be a little unexpected by programmers.
In W3C XML Schemas you can specify that an element has a content model,
when used with a particualar parent (a "local" element). I believe that in RELAX
you can do the same.
You can use Schematron to over come the DTD weakness. Use the content
model above, then have a Schematron schema
<assert test="count(Note) = count(*)"
>An item under an x element can only have Note children</assert>
<assert test="count(*) = 0"
>An item under a y element cannot have any child elements</assert>
That looks after some other constraints.
----- Original Message -----
From: "rajac" <firstname.lastname@example.org>
Sent: Sunday, March 17, 2002 5:44 AM
Subject: [xml-dev] Element With Same Name
I have an Element in DTD called item ie <!ELEMENT item (#PCDATA)>. But same Element item(in the same DTD) should be used like <!ELEMENT item (Note*)>. This Note is an another Element which has a structure. So the Element item is used in two different structures in same DTD. I tried to use <!ELEMENT item (ANY)>. But it is not working. I hope that i have explained the problem clearly. If the problem is not clear, please ask me.