You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "Kapa, Madhavi" <ma...@marconimed.com> on 2000/08/29 00:15:36 UTC

Are DTD elements hierarchical?????????

Hi,

  I have a question about DTDs.

My XML file, with the DTD, looks like this.

<?xml version="1.0"?>
<!DOCTYPE coreconfig [
    <!ELEMENT coreconfig (action)+>
    <!ELEMENT action (name,actionname*,stylesheet+,delegate,license?)>
    <!ELEMENT name       (#PCDATA)>
    <!ELEMENT actionname (#PCDATA)>
    
    <!ELEMENT stylesheet (name,styleset?)>
    <!ELEMENT name    (#PCDATA)>
    <!ELEMENT styleset (#PCDATA)>
    
    <!ELEMENT delegate (#PCDATA)>
    
    <!ELEMENT license (type,id,checksum)>
    <!ELEMENT type     (#PCDATA)>
    <!ELEMENT id       (#PCDATA)>
    <!ELEMENT checksum (#PCDATA)>
]>
<coreconfig>
    <action>
        <name>login</name>
        <actionname>logon</actionname>
        <stylesheet>
            <name>login.xsl</name>
            <styleset>marconi</styleset>
        </stylesheet>
        <delegate>class1</delegate>
        <license>
            <type>existence</type>
            <id>10</id>
            <checksum>c1</checksum>
         </license>
    </action>
 </coreconfig>


     In the XML, I have a name element under both action and stylesheet
elements. I tested this XML for well-formedness under many XML validators
and it is well-formed. But, when, I add the DTD
     for this XML file, I get the error that the XML file is not well formed
as the element name occurs twice.
  
     My question is is this the right way of writing a DTD to specify what I
need.

    THanks,
    Madhavi


Re: Are DTD elements hierarchical?

Posted by Sean Kelly <ke...@ad1440.net>.
Are DTD elements hierarchical?????????Yes, your "name" element is defined
twice in your DTD, which is illegal.

You can have your "name" element occur at multiple levels---there's no
problem with that.  But the "name" element has to have the same content
model (PCDATA in your case) no matter where it occurs.

So pick one of your

<!ELEMENT name (#PCDATA)>

lines in your DTD and delete it.  It doesn't matter which one.

--Sean



Re: Are DTD elements hierarchical?????????

Posted by Elaine Brennan <el...@worldnet.att.net>.
At 06:15 PM 8/28/00 (-0400), Kapa, Madhavi
wrote:

>Hi,
>
>   I have a question about DTDs.
>
>My XML file, with the DTD, looks like this.

<snip> ...

>     <!ELEMENT name       (#PCDATA)>

<snip/> ...

>     <!ELEMENT name    (#PCDATA)>

<snip/> ...

>      In the XML, I have a name element under both action and stylesheet 
> elements. I tested this XML for well-formedness under many XML validators 
> and it is well-formed. But, when, I add the DTD
>
>      for this XML file, I get the error that the XML file is not well 
> formed as the element name occurs twice.
>
>      My question is is this the right way of writing a DTD to specify 
> what I need.

The problem is that you tried to *define* the element "name" twice in your 
DTD. It can only be declared once. So remove one of the element 
declarations pointed at above (it doesn't matter which) and you should be 
fine.

--ELaine