Results 1 to 4 of 4

Thread: XML element declaration

  1. #1

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609

    Question XML element declaration

    i have this xml file but it doesnt want to recognise The "school" element that i have created, i defined it in the DTD but when i try and open it with MS-XML Notapad it gives me the following error:

    PHP Code:
    The element 'school' is used but not declared in the DTD/Schema.

          <
    school yr="11" nm="St Collumbans"/>
    ------------------------------------------^ 
    what am i doing wrong ? i have provided a copy of the files with this post. any help is greatly appreciated.

    XML file:

    <?xml version="1.0"?>
    <!DOCTYPE account SYSTEM "x.dtd">
    <account>
    <personal>
    <name>Michael</name>
    <lname>Dawson</lname>
    <age>16</age>
    <school yr="11" nm="St Collumbans"/>
    </personal>
    </account>

    DTD file:

    <!ELEMENT account (personal)>
    <!ELEMENT personal (name,lname,age,school)>
    <!ELEMENT name (#PCDATA)>
    <!ELEMENT lname (#PCDATA)>
    <!ELEMENT age (#PCDATA)>
    <!ATTLIST school yr CDATA #REQUIRED
    nm CDATA #REQUIRED>
    Attached Files Attached Files
    • File Type: zip x.zip (464 Bytes, 53 views)

  2. #2
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276
    Thr are some things that i noticed.
    (1) U have used the school tag as an "Empty Tag". The attribute listing is only to pass values and nothing can be displayed unless they are placed within the open and close tags.

    (2) Place the attribute listing as separate declarations:
    Like this:

    <!ATTLIST school yr CDATA #REQUIRED>
    <!ATTLIST school nm CDATA #REQUIRED>

    I haven't worked in XML b4. So if someone else can contribute here, i can learn too. Hope this helps.

    - Jemima.

  3. #3
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Shouldn't school be declared as an element before the attlist?

    <!ELEMENT school EMPTY>
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  4. #4

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    sorry, i fixed it just after i posted this thread.
    I totally forgot to declare the "School" element. this works:

    <!ELEMENT personal (f:name,l:name,age,school)>
    <!ELEMENT f:name (#PCDATA)>
    <!ELEMENT l:name (#PCDATA)>
    <!ELEMENT age (#PCDATA)>
    <!ELEMENT school EMPTY>
    <!ATTLIST school yr CDATA #REQUIRED
    schl:name CDATA #REQUIRED>


    thanx u people

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width