[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Element With Same Name


dtd same name
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@n...>
To: <xml-dev@l...>
Sent: Sunday, March 17, 2002 5:44 AM
Subject:  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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.