0

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

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by peter20
0

Peter,

<!-- This is a comment -->

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

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.