tags:

views:

64

answers:

4

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). Is this good practice?

A: 

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.

this. __curious_geek
So read in every xml file and ignore ones which fail validation against the XSD?
macleojw
That sounds like a really expensive way to get around having naming conventions for different types of files.
David Dorward
so you want to standrdize your own custom-defined XML data by just giving it new file extnesion? You will anyways need to validate the XML data wherver you consume the XML..won't you ?
this. __curious_geek
Yes, the XML should always be validated when consumed. I wasn't wanting to use a file extension as an alternative to schema validation. The data model has several thousand files, so I was hoping to avoid the overhead of reading in unnecessary files.
macleojw
A: 

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.

Rob
So I assume you use .txt for all your source code rather than .cpp/.php/... :-)
Roddy
A: 

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.

Grimarr
+6  A: 

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?

Roger Lipscombe
It's only nice if you indeed have an application associated with the file type. So if your application is supposed to open the file in question, then yes, I'd consider the custom extension as well. If it's a settings file, or something that's only used by the application, then it shouldn't need a custom extension and having it open with your favorite xml editor would still be my personal preference.
Rob
@Roger: Right. The fact that it is XML doesn't matter. What does matter is that it is a specific type of file that needs to be differentiated from other types of files, and one conventional means of doing so is to use different extensions.
Jon Purdy