By Jim DeLaHunt

2009-11-23 09:14:44 8 Comments

I have an application in mind which will record directory listings of a file system in text form. That is, it should say something like:

File name is: abc.txt
Last modification date is: 2009-12-31T01:23
Read-only attribute is: True
Hidden attribute is: False

The listings will persist for years in a long-term archive, so the language should be self-evident to an information archaeologist of the future. The language should be able to describe the most commonly-used file attributes of common PC platform file systems: NTFS, FAT, HFS+, ext2/3, etc. It should be able to handle non-Latin file names, different semantics for time stamps on different file systems, etc.

Of course, the obvious choice of a language for structuring this data is some XML-based language. Can anyone point me to a language which already exists for describing hierarchical structures of file attributes and directory attributes, as in a file system? I'm hoping to benefit from the work those language designers did to get the semantics right, create the schema or DTD, work out the niggling details of whether something should be an XML element or attribute, etc.

I've looked in the obvious places:, web search engines, the archives of XML-L and comp.text.xml, and here. I didn't find any traces of such languages. The search was complicated a bit because the search term "file attributes" gets lots of hits on the term attributes as used in XML.

Please suggest languages I should investigate. It helps to have the name of the language, and a pointer to a URL where the language and its related tools, syntax definitions, etc. are described.

Thanks in advance!


@Jim DeLaHunt 2009-11-25 09:51:59

Peter Flynn on the XML-L list kindly pointed me to Cocoon. I found the Directory Generator in Cocoon:

It generates XML directory listings according to a DTD they show there, but here's an example:

<dir:directory xmlns:dir=""
    name="stylesheets" lastModified="1056668768203" date="27.06.03 01:06" size="0"
    requested="true" sort="name" reverse="false">
  <dir:directory name="sites" lastModified="1056668768203" date="27.06.03 01:06" size="0"/>
  <dir:file name="dynamic-page2html.xsl" lastModified="1056668768203" date="27.06.03 01:06" size="4321"/>
  <dir:file name="simple-xml2html.xslt" lastModified="1056668768203" date="27.06.03 01:06" size="1234"/>

There is also an XPath Directory Generator:

Their summary is, "The XPath Directory Generator provides all the functionality of the Directory Generator. Additionaly it is possible to get XML snippets out of the XML files the Directory Generator finds." It generates directory listings like the following example:

<dir:directory xmlns:dir=""
    name="articles" lastModified="1057183738609" date="03.07.03 00:08" size="0"
    requested="true" sort="name" reverse="false">
  <dir:directory name="images" lastModified="1057183738609" date="03.07.03 00:08" size="0"/>
  <dir:file name="article1.xml" lastModified="1057183738609" date="03.07.03 00:08" size="123">
    <dir:xpath query="/article/title">
      <title>My first article!</title>
  <dir:file name="article2.html" lastModified="1057183738609" date="03.07.03 00:08" size="345"/>
  <dir:file name="article2.xml" lastModified="1057183738609" date="03.07.03 00:08" size="234">
    <dir:xpath query="/article/title">
      <title>My second article!</title>

What I find interesting about this language is that they put all the file attributes in XML entity attributes, rather than between the tags. I'm very naive on XML language design, so I don't know the pros and cons of each approach. But that's exactly why I hope to piggyback on someone else's language design.

@Jim DeLaHunt 2009-11-24 08:03:09

David A Lee from the XML-Dev list replied:

The xls command in xmlsh does exactly this, but I wouldnt consider it a format designed for long term archival use. It might be useful to you or it might not

Example output

xls -l

 <file name="README.txt" path="C:/Work/DEI/xmlsh/trunk/README.txt" length="191" type="file" readable="true" writable="true" executable="true" mtime="2008-11-10T11:18:59"/>
 <file name="_dist" path="C:/Work/DEI/xmlsh/trunk/_dist" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-11-23T10:38:00"/>
 <file name="_out" path="C:/Work/DEI/xmlsh/trunk/_out" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-11-23T10:38:04"/>
 <file name="bin" path="C:/Work/DEI/xmlsh/trunk/bin" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-11-23T10:26:06"/>
 <file name="build-lib" path="C:/Work/DEI/xmlsh/trunk/build-lib" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-11-01T11:57:19"/>
 <file name="build.xml" path="C:/Work/DEI/xmlsh/trunk/build.xml" length="3732" type="file" readable="true" writable="true" executable="true" mtime="2009-11-14T12:31:37"/>
 <file name="doc" path="C:/Work/DEI/xmlsh/trunk/doc" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-11-01T11:56:17"/>
 <file name="lib" path="C:/Work/DEI/xmlsh/trunk/lib" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-11-20T07:56:56"/>
 <file name="license.txt" path="C:/Work/DEI/xmlsh/trunk/license.txt" length="1540" type="file" readable="true" writable="true" executable="true" mtime="2009-04-09T09:15:50"/>
 <file name="notices" path="C:/Work/DEI/xmlsh/trunk/notices" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-11-20T07:49:36"/>
 <file name="out.txt" path="C:/Work/DEI/xmlsh/trunk/out.txt" length="0" type="file" readable="true" writable="true" executable="true" mtime="2009-11-23T20:44:33"/>
 <file name="samples" path="C:/Work/DEI/xmlsh/trunk/samples" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-05-27T11:36:54"/>
 <file name="schemas" path="C:/Work/DEI/xmlsh/trunk/schemas" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2008-05-26T20:36:41"/>
 <file name="sh_histo" path="C:/Work/DEI/xmlsh/trunk/sh_histo" length="23" type="file" readable="true" writable="true" executable="true" mtime="2009-11-23T11:02:38"/>
 <file name="src" path="C:/Work/DEI/xmlsh/trunk/src" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-03-20T10:21:07"/>
 <file name="test" path="C:/Work/DEI/xmlsh/trunk/test" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-10-29T11:14:29"/>
 <file name="unix" path="C:/Work/DEI/xmlsh/trunk/unix" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-11-16T15:17:48"/>
 <file name="win32" path="C:/Work/DEI/xmlsh/trunk/win32" length="0" type="dir" readable="true" writable="true" executable="true" mtime="2009-09-20T07:54:55"/>
 <file name="xmlsh.log" path="C:/Work/DEI/xmlsh/trunk/xmlsh.log" length="116538" type="file" readable="true" writable="true" executable="true" mtime="2009-11-23T20:44:31"/>

@Andrey Adamovich 2009-11-23 09:26:26

Tree size is using an XML format to describe directory and file trees.

Related Questions

Sponsored Content

21 Answered Questions

[SOLVED] How many files can I put in a directory?

  • 2009-01-21 18:58:25
  • Kip
  • 312137 View
  • 563 Score
  • 21 Answer
  • Tags:   filesystems limit

2 Answered Questions

[SOLVED] How to know character encoding of file names depending on the filesystem

1 Answered Questions

[SOLVED] FAT and NTFS file systems comparison clarifications

1 Answered Questions

[SOLVED] NTFS vs FAT32 Search Time

1 Answered Questions

[SOLVED] How to get all xml files in a directory that satisfy attribute

  • 2015-04-08 10:08:52
  • mightymouse
  • 3497 View
  • 0 Score
  • 1 Answer
  • Tags:   c# xml linq

2 Answered Questions

Generate XML tree structure from nested ArrayList in Java

1 Answered Questions

3 Answered Questions

[SOLVED] Creating xml from directory structure

Sponsored Content