XML/DTD question, please help me out.

Discussion in 'XML' started by Martijn, Sep 24, 2003.

  1. Martijn

    Martijn Guest

    Hi,

    I'm new in the XML world. I need to program a C++ application that
    writes information of all directories and files on the harddisk to a
    XML file. Now that's not really the problem.

    I expect part of the XML file could look like this:

    <FILELIST>
    <DIRECTORY name="windows" date="09/23/2003">
    <FILE>
    <FILENAME>win.ini</FILENAME>
    <FILESIZE>1128</FILESIZE>
    <FILEDATE>09/23/2003</FILEDATE>
    </FILE>
    <DIRECTORY name="system" date="09/23/2003">
    <FILE>
    <FILENAME>keyboard.drv</FILENAME>
    <FILESIZE>2000</FILESIZE>
    <FILEDATE>09/23/2003</FILEDATE>
    </FILE>
    </DIRECTORY>
    </DIRECTORY>
    </FILELIST>

    Correct me when I'm wrong.

    And for the DTD file:

    <!DOCTYPE FILELIST [

    <!ELEMENT FILELIST (DIRECTORY*)>
    <!ELEMENT DIRECTORY (DIRECTORYNAME, DIRECTORYDATE, FILE*)>
    <!ELEMENT DIRECTORYNAME (#PCDATA)>
    <!ELEMENT DIRECTORYDATE (#PCDATA)>
    <!ELEMENT FILE (FILENAME, FILESIZE, FILEDATE)>
    <!ELEMENT FILENAME (#PCDATA)>
    <!ELEMENT FILESIZE (#PCDATA)>
    <!ELEMENT FILEDATE (#PCDATA)>

    <!ATTLIST DIRECTORY NAME CDATA #REQUIRED>
    <!ATTLIST DIRECTORY DATE CDATA #REQUIRED>

    ]>

    Now my question:

    Directories can excist in directories wich can excist in directories,
    etc.
    How to solve this in the DTD file.

    -Martijn
    Martijn, Sep 24, 2003
    #1
    1. Advertising

  2. Martijn

    Martin Boehm Guest

    "Martijn" <> wrote in message
    news:
    > Hi,
    >
    > I'm new in the XML world. I need to program a C++ application that
    > writes information of all directories and files on the harddisk to a
    > XML file. Now that's not really the problem.
    >
    > [...]
    >
    > And for the DTD file:
    >
    > <!DOCTYPE FILELIST [
    >
    > <!ELEMENT FILELIST (DIRECTORY*)>
    > <!ELEMENT DIRECTORY (DIRECTORYNAME, DIRECTORYDATE, FILE*)>


    According to your samle XML, this is wrong. You should, but do not have
    any DIRECTORYNAME or DIRECTORYDATE elements, you use attributes, as you
    correctly denoted later. But you would have noticed, I guess. ;-)

    > Now my question:
    >
    > Directories can excist in directories wich can excist in directories,
    > etc.
    > How to solve this in the DTD file.


    <!ELEMENT DIRECTORY (DIRECTORY*, FILE*)>

    What did you think? ;-) Self-referencing is allowed in DTDs.

    Martin
    Martin Boehm, Sep 24, 2003
    #2
    1. Advertising

  3. Martijn

    Martijn Guest

    "Martin Boehm" <> wrote in message news:<3f717357$0$23104$-online.net>...
    > "Martijn" <> wrote in message
    > news:
    > > Hi,
    > >
    > > I'm new in the XML world. I need to program a C++ application that
    > > writes information of all directories and files on the harddisk to a
    > > XML file. Now that's not really the problem.
    > >
    > > [...]
    > >
    > > And for the DTD file:
    > >
    > > <!DOCTYPE FILELIST [
    > >
    > > <!ELEMENT FILELIST (DIRECTORY*)>
    > > <!ELEMENT DIRECTORY (DIRECTORYNAME, DIRECTORYDATE, FILE*)>

    >
    > According to your samle XML, this is wrong. You should, but do not have
    > any DIRECTORYNAME or DIRECTORYDATE elements, you use attributes, as you
    > correctly denoted later. But you would have noticed, I guess. ;-)
    >

    Stupid of me.

    > > Now my question:
    > >
    > > Directories can excist in directories wich can excist in directories,
    > > etc.
    > > How to solve this in the DTD file.

    >
    > <!ELEMENT DIRECTORY (DIRECTORY*, FILE*)>
    >
    > What did you think? ;-) Self-referencing is allowed in DTDs.
    >


    That's what I didn't know.

    > Martin


    Thanks
    Martijn
    Martijn, Sep 24, 2003
    #3
  4. Martijn

    Micah Cowan Guest

    "Martin Boehm" <> writes:

    > > Now my question:
    > >
    > > Directories can excist in directories wich can excist in directories,
    > > etc.
    > > How to solve this in the DTD file.

    >
    > <!ELEMENT DIRECTORY (DIRECTORY*, FILE*)>
    >
    > What did you think? ;-) Self-referencing is allowed in DTDs.


    <!ELEMENT DIRECTORY (DIRECTORY | FILE)*>

    Would allow intermixing between DIRECTORYs and FILEs.

    -Micah
    Micah Cowan, Sep 26, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joseph Tilian
    Replies:
    0
    Views:
    331
    Joseph Tilian
    Dec 21, 2004
  2. Ronald Fischer
    Replies:
    4
    Views:
    1,735
    Ronald Fischer
    Mar 17, 2005
  3. KK
    Replies:
    2
    Views:
    498
    Big Brian
    Oct 14, 2003
  4. test
    Replies:
    2
    Views:
    1,975
    Oliver Wong
    Jul 28, 2006
  5. Generic Usenet Account
    Replies:
    1
    Views:
    1,045
    Joe Kesselman
    May 6, 2009
Loading...

Share This Page