Click to See Complete Forum and Search --> : Structuring Metadata Taxonomy


Beezer
07-08-2008, 12:03 PM
Hi,

Bit of a noob to XML, and I'm a bit confused.

Let's say you're trying to create a schema for quiz metadata and one of the elements is 'subject'. This could potentially be picked from a fairly complex classification of subjects arranged in a tree.

Not quite sure what the XML would look like. Is it:

<subject>
<science>
<biology>
<cellularBiology>
</cellularBiology>
</biology>
</science>
</subject>

That seems wrong because there is no value?

If this is right, how is it defined in the schema? Do you define empty elements and not use Enumerations?

Perhaps in my schema there is the simple element <subject> and this references an XML file with the subject taxonomy?

Or perhaps cellular biology is one of many values within the element <biology>???

I'm sure the answer is fairly obvious. Perhaps someone can set me straight and maybe link me to some suitable reading material. I have read quite a bit on XML and can create basic schemas, but it seems like there's something fundamental that I'm missing!

thanks.

bogocles
07-08-2008, 03:01 PM
Technically speaking, this is probably preferred:


<subject>
<science>
<biology>
<cellularBiology />
</biology>
</science>
</subject>


However, simply placing an empty opening and closing element is almost always recognized as an empty tag by any XML parser, ie:


<cellularBiology></cellularBiology> == <cellularBiology />

So there isn't any harm in it.

Do you define empty elements and not use Enumerations?
Within your schema, you'll have to define the elements contained in other elements. Enumerations are used to restrict the values of either an element or an attribute.

Perhaps in my schema there is the simple element <subject> and this references an XML file with the subject taxonomy?I guess this is possible, but seems overly complex.

Best bet is to check out the tutorial on XMLSchema here:

http://www.w3schools.com/Schema/default.asp

This is assuming you want to use XSD. It shouldn't be too hard to find similar tutorials on DTD or RelaxNG.

Beezer
07-08-2008, 03:35 PM
thanks a lot. That all makes sense. I think I'm confused about when I should be using empty elements as opposed to values to define the taxonomy.

i.e. should I define cellularBiology and say evolution as values or empty elements within biology?

I'm tending towards empty elements as the tree could potentially have any number of descendants and it seems more extensible that way. Could someone confirm that this is the right way to think?

bogocles
07-09-2008, 10:24 AM
Data modeling in XML can pretty much go any way. But for what is sounds like you're doing, nesting elements by subject (from general to more specific) sounds like a good plan. Remember, there is no right way to do anything in XML (at least once its well-formed)! :)