On 04/18/2011 09:30 AM, Marius Dumitru Florea wrote:
On 04/18/2011 09:49 AM, Vincent Massol wrote:
BTW you haven't defined what the separator is. Is the separator the one defined in
the Tag class property? If so it can be anything and there needs to be a way to enter it
IMO. Imagine I choose space as the separator and I want to enter "word of
mouth". I should be allowed to, either by using quotes or by escaping.
I see your point. I thought the separator was fixed because the UI says
"Comma separated tags". I just tested and it seems pipe character | is
also used as separator. If I enter "foo|bar,end" the UI displays 2 tags
but the value of the XWiki.TagClass object is "foo|bar|end" (so actually
I entered 3 tags).
IMO the fact that you can change the separator is an implementation
detail. We now use a Static List to store the list of tags but this can
change. The way we store the tags shouldn't influence the way we define
tags. The separator is *not* part of the tags specification because we
could have an UI that allows you to input tags only one by one and we
could store tags in separate fields.
So IMO the specification should only say:
* tags' case is used only for display
* tags don't have leading or trailing spaces
And in our implementation, *because* we input and store tags using a
single field, we can define a separator and a way to escape that
separator. I prefer comma as separator and backslash as escaping.
There's a difference between the separator used in the display, and the
separator used internally.
In the UI, the only separator is the comma, which is hard-coded in
documentTags.vm. The tag plugin takes care of escaping the pipe symbol.
Note that updating the tags using the tag input displayed in edit mode
will explode the tags containing a pipe (we should remove the tag input
in edit mode).
In the database, | is the only separator, and it can't easily be
changed. Also, | used inside values is automatically escaped with \| in
the database.
The current implementation doesn't support escapes in the UI, but this
could be changed if we decide on an escape character. See
com.xpn.xwiki.objects.classes.ListClass.getListFromString(String,
String, boolean)
--
Sergiu Dumitriu
http://purl.org/net/sergiu/