开发者

Should I create a new extension for an xml file?

I'm working with a data model stored in XML files. I want to create some metadata for the model and store it alongside, but would like to be able to distinguish between the two. The data model is imported into some software from time to time and we don't want it to try to import the meta data files.

To get round this, I've been thinking of creating a new extension for the metadata xml files (say .mdml). 开发者_StackOverflow中文版Is this good practice?


Yes. Create a file with a different extension.

The fact that your model uses XML is an implementation detail. The fact that most other file formats use a proprietary binary format doesn't mean that they all have to be called filename.bin, so why should all XML files need to be called filename.xml?

Yeah, sure, it might be nice to double-click the file and have it loaded into an XML-aware text editor. But surely it's nicer to be able to double-click on (for example) a .csproj file (which is XML) and have it load into Visual Studio?


Nope don't create new extension for your XML data, define XML schema for your XML data and just validate XML against your XSD wherever you read/write your XML data.


I don't really know if it's best practice, but I do know that some applications I use, create XML files (for settings usually) that have a custom extension. I'm not a fan of that, because the extension tells me what kind of file it is. I also have applications setup to open XML files when I double click on them.

So again: I don't know if it's good practice or not, but I'm not a fan of custom file extensions on known file types.


I agree that it's nice to be able to keep files organized by extension, but I also have noticed that having XML files end with .xml makes it using some tools easier. I recommend using an extension like .mdm.xml, which still lets you use a wildcard for the file name, but restrict it to just the files you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜