First is I'm starting to build a standard XML format/structure for our users. The objectives are:
- XML that can be used for multiple organisations
- XML that can be used to map external system data to our system data
- XML structure should be in best practices
- XML should be adaptable to change
The above are the objectives, so our initial structure, users XML, would look like this:
<users>
<user>
<firstName></firstName>
<lastName></lastName>
<email></email>
<!-- .. some user child node here -->
</user>
</users>
So I'm thinking what if this structure grows which might have different objects associated to user something like:
<users>
<user>
<firstName></firstName>
<lastName></lastName>
<email></email>
<element1>
<child1></child1>
</element1>
<element2>
<child1></child1>
<child2>
<innerChild1></innerChild1>
</child2>
</element2>
</user>
</users>
Then I would have to implement urn
namespace to uniquely identify same named <element>
. This is where namespace is useful.
My questions are:
- Do I have to implement namespace by having it implemented on the initial XML sample?
- When to use attribute instead of creating elements as child node?
- Best practices that I could use for our XML to be adaptable to change?
- What are the things I should prevent when building or structuring XML?
Note: we are using XML instead of JSON because most of our users use XML.