[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: element content vs. element attribute
At 04:09 21/12/97 -0500, Liam Quin wrote: >On Sat, 20 Dec 1997, Ray Waldin asked: [... a very common and important question of style ...] >> when should data be contained by elements? Or conversely, when should >> data be an attribute of an element instead of contained by that element? > >There are a number of issues that may help here, depending on how the >information is going to be used... > >Some pragmatics first: > [...] I have run into exactly this problem with Technical Markup Language. I wanted to design it with as few ELEMENTs as possible and have evolved this to <XVAR TITLE="BolierTemperature" UNITS="Celsius" FUZZY="Range" ...>120-125</XVAR> where there are a number of attributes that qualify the value. For reasons Liam has outlined, and some others (see below) I have come to the conclusion that ELEMENTs are easier to work with than attributes. So, to Liam's criteria I'll add: * X*L tools formally require more support to be given to ELEMENTs than attributes. For example, if I have a unit of length (metre), but don't know whether it occurs as kilometre or centimetre [1], I can search in content with standard XML syntax: DESCENDANT(ALL,UNITS)STRING(1,"metre",0) whereas I have no way of searching in attribute values unless I write my own software. * When you have to write significant amounts of code to process an attribute it may be work reworking it as an ELEMENT. JUMBO includes a lot of code for automatic conversion between UNITS and so it makes sense to make this an ELEMENT, because much of that processing can then be done automatically. Put another way, at present JUMBO has to know which ELEMENTs might have UNITS attributes and call special code. If UNITS is contained, the processing is requested just like any other ELEMENT. > Unfortuantely, a practical example would add units and tolerance to > the temperature, and then you need to use elements or a non-XML sub- > structure: Yes - and I ran into trouble here. So the example I gave is horrid, and I am reworking this using <MINVALUE> and things like this. I would much rather have a proliferation of ELEMENTs than attributes. [Part of my worry about multiplying ELEMENTs was that the content models can get very complex. Since much of my XML will not be validatable, that's less of a problem now.] > <boiler MinTemperature="7 {units K} {tolerance {plus 3} {minus 2}"....> > This is generally unsatisfactory because it's not using XML; so Liam is an illicit helium distiller, I see. :-) P. [1] Some countries use the variant "meter" so you will have to do two searches. Peter Murray-Rust, Director Virtual School of Molecular Sciences, domestic net connection VSMS http://www.nottingham.ac.uk/vsms, Virtual Hyperglossary http://www.venus.co.uk/vhg xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i... Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ To (un)subscribe, mailto:majordomo@i... the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@i... the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@i...)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|