Semanticmediawiki: Setting multiple values #set/#subobject using `|`

Created on 2 Jan 2016  路  3Comments  路  Source: SemanticMediaWiki/SemanticMediaWiki

[0] wrote "with some old templates of mine I found out that ... can be used to store multiple values for one property. Since I did not find any mention of it as I wanted to confirm this"

{{#set:
 |property1=value1|value2|value3
 |property2=value1|value2|value3
 ...
}}

Above is codified in [1] but we are missing:

  • [ ] an integration test [2, 3] and it would be great if someone could send a PR to cover this in order to avoid any regression in future
  • [ ] wiki documentation ("... I would like to ask, whether this is a solid feature (and remains so) or is it unwanted and will be removed ")

[0] https://www.semantic-mediawiki.org/wiki/Thread:Help_talk:Setting_values/Setting_multiple_values_in_one_turn
[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/src/ParserParameterProcessor.php#L205-L212
[2] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/tests/phpunit/Integration/ByJsonScript/README.md
[3] https://github.com/SemanticMediaWiki/SemanticMediaWiki/tree/master/tests#write-integration-tests-using-json-script

question

All 3 comments

It is actually already documented here but just lacking a note making this exception more visible. Since this works in many versions of SMW I however consider this a stable feature.

Hmm, I have the feeling that we should rather ditch this since it adds another syntactical exception and does not cater for values containing a pipe which will be split - not saying that this is a common use case. Let's rather use the sep parameter in any case and in this case |+sep|. Some people could be irritated by two consecutive pipes one defining the separator and the next one the following property-value-annotation but as it stands now one could now confuse the difference also without directly seeing that the pipes are there to split values.

Also there are cases with results which are expected but confusing at first sight:

{{#set:
 |Has text=Pipe7,Pipe8|Pipe9,Pipe10|Pipe11,Pipe12|+sep
}}

Here we get annotations with the values "Pipe7,Pipe8", "Pipe9,Pipe10", "Pipe11" and "Pipe12". See also the test page. It will not be possible to split at the comma for the first two pairs no matter what you do since a closing pipe "masks" the comma, e.g. this.

@oetterer since you originally asked about it.

@JeroenDeDauw Do you have an opinion on my suggestion?

Edit:
@s7eph4n Acutally I should have pinged you right away, too. :(

The more I think about it the more I feel that we should deprecate this with 3.0.0 and ditch this with 4.0.0 or so.

Given the indifference I decided that this should go. We have the sep parameter since SMW 1.9.0 which allows to do many more things than using the pipe. No need to maintain extra syntax. Thus it is now deprecated and should be removed in SMW 4.0.0. Documented respectively: 1, 2 and 3.

Was this page helpful?
0 / 5 - 0 ratings