OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Element With Same Name

[ Lists Home | Date Index | Thread 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

   <rule context="x/item">
        <assert test="count(Note) = count(*)"
        >An item under an x element can only have Note children</assert>
    </rule>
    <rule context="y/item">
        <assert test="count(*) = 0"
        >An item under a y element cannot have any child elements</assert>
    </rule>

That looks after some other constraints.

Cheers
Rick Jelliffe

----- Original Message ----- 
From: "rajac" <rajac@ncmr.co.in>
To: <xml-dev@lists.xml.org>
Sent: Sunday, March 17, 2002 5:44 AM
Subject: [xml-dev] Element With Same Name


Hi,
   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. 

Regards,
Raja





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS