Multiple attribute sets for one element

I have a question about XML which is quite generic, but I will use SVG 
examples to keep it on-topic :-)

I wonder if it is OK for an element to have multiple attribute sets, 
perhaps overlapping, probably conflicting.

To be more concrete, let see some examples:
- a rectangle can be defined by two points, or by a point and two 
dimensions.
- a circle can be defined by a point and a radius, or three points.
- an arc can be defined by two points and two radii (plus some other 
params...) or a point, two angles and two points (and rotation).
- a gradient vector can be expressed as two points or an angle and a 
dimension).
etc.

Eg.:
<rect x="0" y="0" width="10" height="10"/>
or
<rect x1="0" x2="10" y1="0" y2="10"/>

So I wonder if it is OK to write that in XML?
I can see several possibilities:

- It is formally prohibited by the XML specification. OK, end of problem...

- It is not prohibited but discouraged by the spec., either by stating 
it, or because it is not possible to define it with DTD. OK, forget it.

- Nothing about this in the spec., but this is seen as bad practice, for 
reasons I may list below (or others).

- It is perfectly valid, but it hasn't been chosen in SVG for some reasons.

It is a bit like operation/method overloading in C++...

The pros and cons:

Pros:
- It adds lot of flexibility for hand-coders, without increasing the set 
of elements.
- It keeps semantics: whatever the method of construction, a rectangle 
is still a rectangle, not a rect2P and a rectPD...

Cons:
- It may be confusing.
- There must be support of badly formed attribute sets. If there is a 
mixup of two sets, should we raise an error, ignore the malformed 
element, or choose a version. Which version to choose? A spec. should 
specify the prefered one, assuming it is complete.

Neither pro nor con, I believe it is really easy to implement, so this 
is not a problem.

What do you think of this?

-- 
Philippe Lhoste
--  (near) Paris -- France
--  Professional programmer and amateur artist
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --

Received on Thursday, 11 November 2004 19:34:13 UTC