Ittay Dror wrote:

 > can i create an attribute whose type is some enumeration?

Not yet, but you join the list of people asking for this feature.

I should be coding better date/time handling :-)
but this is pretty straightforward; I've got an implementation working 
locally and should be able to check it into SVN tomorrow if no one objects.

 > the point is to have an attribute that accepts string values, but
 > still be able to create order, and use comparisons in queries.
 >
 > my use case is a 'product_version' attribute. I'd like for different
 > components to state since what product version they exist ('since
 > version 1.2'). i want then to be able to list all components for a
 > given version (something like [[product_version:=<1.3]]).

The inline query code would have to detect queries on the enumerated 
datatype, look up the value_num for 1.3, and query on that.  I don't 
have that part working.

 > version names can be anything (e.g. 'xp'). so i want to be able to
 > map them in the attribute page (or type of). then i'd assign to 1.1
 > the value of 1, to 1.2 the value of 2, to 'xp' the value of 3, etc.

In my "keep it simple" approach, the [[Attribute:Product version]] page 
would have the special property
    [[possible values:=3.0,3.1,98,98SE,ME,XP,Vista]]
and each comma-separated value gets a numeric offset that you wouldn't 
be able to control (or see).

 > when new versions come (incl. minor versions), i'll update the page,
 > inserting the version and its sequence number (maybe bumping others)

In my "keep it simple" approach, if you inserted a new value within 
possible values, you'd have to re-edit all pages with the attribute to 
update the offsets.  If you really want an advanced enum type that lets 
you control the numeric value of each string, how would you specify this 
in wiki text?

In another message, Ittay Dror wrote:
 > can anyone please give pointers (or example code) how to
 > implement as custom type (php)?
My PHP code for SMWEnumeratedTypeHandler is a combination of 
SMWStringTypeHandler and SMWBooleanTypeHandler, with handling of the 
special property "possible values" similar to "display units".  Nothing 
innovative ;-)

Notes
-----
I don't think there's any way to represent an enumerated type in RDF 
export beyond the string XSD type.

Although strings are the obvious case for enumeration, [[possible 
values]] could also be applied to other attribute datatypes, and even to 
relations.  But no one's asked for that yet.

The [[possible values]] special property will really run into the 255 
character limit for string values.  But if you split the enumeration 
across two [[possible value]] attributes, I don't think order is 
guaranteed between them.

--
=S

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Semediawiki-user mailing list
Semediawiki-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-user

Reply via email to