Beginner XML DTD Help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andypandy
    New Member
    • Mar 2008
    • 2

    Beginner XML DTD Help.

    Hi there, I've been learning xml for a while but I now have to write an external dtd for a large xml file but I'm a bit stuck on something and was hoping someone could help. Below is an example of the code from the xml file

    <abstract>
    <para>Lorem ipsum dolor sit amet, consectetuer adipiscing elit</para>
    <acknowledgemen ts>
    <para>Lorem ipsum dolor sit amet, consectetuer adipiscing elit</para>
    </acknowledgement s>

    My question is how do I define the para element in the dtd, I'm just a bit confused as its used more than once and in different elements, would it be something like:

    <!ELEMENT project (abstract,ackno wledgements)>
    <!ELEMENT abstract (para)+>
    <!ELEMENT para (#PCDATA)>

    also within the para's there are thigs like images, code listing and lists, would they just be defined in the <!ELEMENT para (#PCDATA)>?

    Any help would be greatly appreciated.
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    I don't think you need the 2nd <!ELEMENT para (#PCDATA)>, as you've already defined it once.

    2nd question:yes

    Comment

    • andypandy
      New Member
      • Mar 2008
      • 2

      #3
      thanks for your reply i got the problem sorted but i was wondering if you could help me with something else? Im trying to create and display a table the code below shows how im doing it:

      <table>
      <item>
      <title>Lorem ipsum</title>
      <info>dolor sit</info>
      </item>
      </table>

      and in the dtd:

      <!ELEMENT table (item)+>
      <!ELEMENT item (title*, info*,detail*,s tuff*)>
      <!ELEMENT title (#PCDATA)>
      <!ELEMENT info (#PCDATA)>
      <!ELEMENT detail (#PCDATA)>
      <!ELEMENT stuff (#PCDATA)>

      when i try to validate it i get errors like:
      error (1102): tag uses GI for an undeclared element: item
      error (1150): enclosing tag undefined or lacks content model; can't check child: title

      the probel appears to be that the elements are undefined however I have clearly defined them in the dtd, any suggestions?

      thanks

      Comment

      Working...