【问题标题】:An XML language for describing file attributes of a directory tree?用于描述目录树文件​​属性的 XML 语言?
【发布时间】:2009-11-23 09:14:44
【问题描述】:

我有一个应用程序可以记录文件的目录列表 文本形式的系统。也就是说,它应该这样写:

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

列表将在长期档案中保存多年,因此对于未来的信息考古学家来说,语言应该是不言而喻的。该语言应该能够描述常见PC平台文件系统最常用的文件属性:NTFS、FAT、HFS+、ext2/3等。它应该能够处理非拉丁文件名、时间戳的不同语义在不同的文件系统等上。

当然,用于构建这些数据的语言的明显选择是 一些基于 XML 的语言。谁能给我指出一种已经 用于描述文件属性的层次结构和 目录属性,如在文件系统中?我希望从那些语言设计人员所做的工作中受益,这些工作包括正确的语义、创建模式或 DTD、确定某事物是否应该是 XML 元素或属性等琐碎的细节。

我已经查看了明显的地方:http://xml.coverpages.com,网络 搜索引擎,XML-Lcomp.text.xml 的档案,以及这里。我没有发现任何此类语言的痕迹。搜索有点复杂,因为搜索术语“文件属性”在 XML 中使用的术语属性上获得了很多命中。

请建议我应该调查的语言。拥有语言的名称和指向描述语言及其相关工具、语法定义等的 URL 的指针会有所帮助。

提前致谢!

【问题讨论】:

  • 我会在 XML-DEV (xml.org/xml-dev) 上发布这个问题,如果您没有得到有用的回复,我会感到惊讶。如果没有这方面的规范,那么应该有,我希望 OASIS 人员能够参与其中。 [你可以说是我建议的。]
  • 经过太多延迟,我认为这个答案是最好的。该列表没有为我指明合适的格式,我也没有成功让 OASIS 人员参与进来。但是 XML-DEV 列表是一个非常有用的论坛。

标签: xml filesystems language-design directory-structure file-attributes


【解决方案1】:

Tree size 使用XML format 来描述目录和文件树。

【讨论】:

    【解决方案2】:

    XML-Dev 列表中的 David A Lee 回复:

    xmlsh 中的 xls 命令正是这样做的,但我不认为它是为长期存档使用而设计的格式。 它可能对你有用,也可能没有

    http://www.xmlsh.org

    示例输出

    xls -l
    
    
    <dir>
     <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"/>
    </dir>
    

    【讨论】:

      【解决方案3】:

      XML-L 列表中的 Peter Flynn 向我指出 Cocoon。我在 Cocoon 中找到了目录生成器http://cocoon.apache.org/2.1/userdocs/directory-generator.html

      它会根据它们在此处显示的 DTD 生成 XML 目录列表,但这里有一个示例:

      <dir:directory xmlns:dir="http://apache.org/cocoon/directory/2.0"
          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"/>
      </dir:directory>
      

      还有一个 XPath 目录生成器: cocoon.apache.org/2.1/userdocs/xpathdirectory-generator.html

      他们的总结是,“XPath 目录生成器提供了目录生成器的所有功能。此外,还可以从目录生成器找到的 XML 文件中获取 XML sn-ps。”它会生成类似以下示例的目录列表:

      <dir:directory xmlns:dir="http://apache.org/cocoon/directory/2.0"
          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:xpath>
        </dir:file>
        <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>
          </dir:xpath>
        </dir:file>
      </dir:directory>
      

      我发现这种语言的有趣之处在于它们将所有文件属性放在 XML 实体属性中,而不是在标签之间。我对 XML 语言设计非常幼稚,所以我不知道每种方法的优缺点。但这正是我希望借鉴别人的语言设计的原因。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多