2

我们正在开发一个应用程序,该应用程序从我们定义的自定义文件格式接收大量输入。输入文件是由第三方开发的应用程序生成的,因此我们自然需要能够有效地交流程序中可接受的输入和不可接受的输入。

该文件有 10 行的标题部分,每行代表不同的元信息,后跟换行符和“页脚”。页脚包含信息的内容。标题相当简单,但是当我们来到页脚时,每行都有几个字段,这些字段以预定义的字符偏移量开始。

我想知道是否有其他人遇到过类似的情况,并且可以就如何记录这些类型的文件格式提供一些提示。该文件规范的文档很可能会显示在 Wiki 上,但我也希望它适合在硬拷贝手册中发布。

4

3 回答 3

3

mouvicielBravax的回答很有帮助。一个处理显示,另一个处理您的文档应提供的有关文件格式的一些技术方面。

我一直处于这个问题的两端(创建/使用文件格式规范)。这是我在阅读文档时希望拥有的东西的清单。

  • 具有文件格式的可视化表示。
  • 有一个文件格式的例子。包括文档创建者可能认为合法但不合法的文件示例也会有所帮助。
  • 如果您的文档是电子文档,则将其超链接到相关部分会很有帮助。
  • 提供文件格式的理由。这有助于人们理解他们为什么要做某事,而不是盲目地遵循规范。

在技​​术方面,在文件格式中创建灵活性以供以后添加。有一个标题是一个好主意。我什至会创建一个版本号标题行以及一个“标题长度”属性,以便将来如果您需要添加其他元属性,您可以!

于 2009-08-14T09:14:04.817 回答
1

The second paragraph of your question would be a good introduction to your interface document.

Then I would add two sections, one for the header, the other for the footer.

The header section contains a description of what is expected on each line.

The foorter section is a table where each line describes one field and the columns are:

  • field name,
  • offset,
  • length,
  • purpose
于 2009-08-14T08:59:13.193 回答
1

I've helped write an XML Schema in the past which is roughly similiar to this.

My advice would be to be absolutely explicit in documenting exactly how the file is constructed, so no ambiguity exists.

So things which you need to consider are:

  • Spacing
  • End of line markers
  • End of file markers
  • Allowed characters in each area of the file.
  • Allowed value ranges in each area.
  • Any encoding which is required, and what method/algorithm to use.

Ideally you can write a validator program to give to the third party, to validate files. Thus minimizing the chance of something going wrong.

于 2009-08-14T08:59:36.640 回答