0

The title above is one of the requirements for an Android Application. I know XML is the code used to store data, like spread sheets ect...But how is an application supposed to "design" XML schemas? Also how is that applicable to an android application? Sorry my knowledge of android applications, or android in general is very low.

Renaud
  • 8,783
  • 4
  • 32
  • 40
Jake
  • 2,877
  • 8
  • 43
  • 62

2 Answers2

0

An application doesn't design schema, the application designer does. (And it's not code, it's data.)

The process is the same as anything else: what do you need saved? What are the entities that need saving, at all levels? Do want an actual schema (.xsd file) in which you can define types, or do you just want a simple XML-based data file? The two are very different things.

Simple XML might look like this:

<contacts>
  <contact>
    <first>Dave</first>
    <last>Newton</last>
    <phone>630-555-1212</phone>
  </contact>

  <contact>
    <first>Foo</first>
    <last>Bar</last>
    <phone>312-123-4567</phone>
  </contact>
</contacts>

A schema definition for this describes what's in the elements, what order they're in, what's optional (or not), their type, etc.

This doesn't have anything to do with Android, rather XML.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
0

Dave provides a simple and clear answer.

My two cents:

Wikipedia is our friend for that kind of question:

Extensible Markup Language (XML) is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification[4] produced by the W3C, and several other related specifications, all gratis open standards.

Does XML fit your needs? It depends… In fact, it depends on the data model you (or your business customer) need to implement. Dave is right, the application doesn't design schema, the development team design data models based on the underlying business knowledge. Once your data model is there, you'll need to implement it as a basis for your end-user application. If there are good reasons to use XML, don't redesign the wheel. If your need doesn't not fit with the existing XML derivative formats, then you'll have to consider your data model and the related constraints. Based on the model and the related modelization constraints, you'll have to choose how you will define that: W3C XML Schema, Relax NG, schematron constraints, etc.

Why we do all that stuff: just to be sure that the input/output data fits our need, is interoperable if need be and understandable by the application… The schema is like an i/o contract for the application (Are the data valid?)

It's out of scope but android, as an embedded platform, is not very good for out-of-the-box schema validation (I mean there W3C XML Schema validation) since the API is there but without implementation behind. Validation is not impossible (as nothing is impossible) but it's reasonable to enforce server-side data structure validation (for client/server use cases). If you have an inner model, the android prefered way to implement data model is sqlite (or you could use plain java) but that's another answer to another question…

Renaud
  • 8,783
  • 4
  • 32
  • 40