954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem with dtd

Hi, I am new in xml programming and I need your help.
I want to cataloging my cds and I have create a xml file and a dtd but they are not valid.
:(

xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cdcollection SYSTEM "cd-collection.dtd">

<cdcollection>
  <album barcode="">
    <title></title>
    <artist></artist>
    <track id="1"  time=""> </track>
    <track id="2"  time=""> </track>
    <track id="3"  time=""> </track>
    <track id="4"  time=""> </track>
    <track id="5"  time=""> </track>
  </album>
</cdcollection>


dtd

<!DOCTYPE cdcollection [
<!ELEMENT cdcollection (album+)>
<!ELEMENT album (title,artist,track+)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT artist (#PCDATA)>
<!ELEMENT track (#PCDATA)>
<!ATTLIST album barcode CDATA #REQUIRED>
<!ATTLIST track id CDATA #REQUIRED>
<!ATTLIST track time CDATA #REQUIRED>
]>


and how can I insert comments in xml ?
Thanks a lot

peter20
Light Poster
32 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Peter,

[code]

[code]

The DTD problem is with your track+ element where you have not stated it's additional track elements, e.g.

<!ELEMENT track (element1, element2, element3) >


If you do not need any 'child' elements for the 'parent' track element, then remove the +.

See DTD examples which use the + on the w3schools website: http://www.w3schools.com/dtd/dtd_examples.asp

It also holds a lot of useful XML information such as Syntax Rules which include how to comment, etc.

http://www.w3schools.com/xml/xml_syntax.asp

StephNicolaou
Posting Whiz in Training
204 posts since Nov 2007
Reputation Points: 77
Solved Threads: 18
 

thanks a lot

peter20
Light Poster
32 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You