macleojw
macleojw

Reputation: 4159

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

Upvotes: 4

Views: 1262

Answers (4)

Roger Lipscombe
Roger Lipscombe

Reputation: 91865

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?

Upvotes: 12

Grimarr
Grimarr

Reputation: 41

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.

Upvotes: 0

Rob
Rob

Reputation: 1846

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.

Upvotes: 0

this. __curious_geek
this. __curious_geek

Reputation: 43207

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.

Upvotes: 0

Related Questions