From: Van de B. <van...@gm...> - 2011-07-23 23:29:22
|
BTW, Just a thought: I thing we can solve most of the issues with delimiters using named template parameters. For example: {{ #ask: ...query... | ?Prop1 | ?Prop2 | ?Prop3 | template=my_template}} Currently my_template is called with positional parameters: {{{1}}} is value of Prop1, {{{2}}} is value of Prop2, {{{3}}} is value of Prop3 etc. (Yes, I know that {{{1}}} is name of page, but let us ignore it for the moment.) My proposal is using not positional, but named arguments, so {{{Prop1}}} is value of Prop1, {{{Prop2}}} is value of Prop2, etc. Advantages are: 1. It is easier to write template. 2. Template code is much more readable. 3. It is possible to vary order of printout statements without need to rewrite template. 4. The same template may be used for different queries. Ok, what about delimiters? If we have multiple values for one printout statement (e. g. in case of one-to-many relationship), multiple arguments will be passed to template. All the parameters will have the same prefix "Prop" and different suffixes: [1], [2], [3], etc. Template can use #forargs parser function (from Loops extension) for handle all the values. Alternatively, we can extend ArrayExtension to create an array from template arguments. Any comments? Van. On Sat, 2011-07-23 at 13:08 +0400, Van de Bugger wrote: > Hi Patrick, > > Thanks for the info. > > Markus, > > Do you have any progress on 22777? Do you have any objections against > Patrick's patch? Do you need any help (e. g. for testing the patch)? > > Semantic Forms and ArrayExtension use term "delimiter" for such kind of > separator. I think it would be good to have the same naming conventions > across Semantic MediaWiki, Semantic Forms,and ArrayExtension. > > Thanks, > Van. > > On Sat, 2011-07-23 at 10:50 +0800, Patrick Nagel wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > Hi Van, > > > > On 2011-07-23 06:44, Van de Bugger wrote: > > > I have one-to-many relationship in my database. For example, several > > > people together can visit a region. To handle such information, I use > > > input field with multiple values and handle them with array functions. > > > Everything works good. But I found that some names confuse templates. The > > > system fails to handle names with a comma, for example: "Dow, Jones", or > > > "Indiana Jones, Jr.". I started to use semicolon as a delimiter (Semantic > > > Forms and Arrays allow specifying custom delimiter), and was happy for > > > some time. The problem is in inline queries. For example: > > > > > > {{ #ask: ...some conditions... | ?# | ?Date | ?Location | ?Visitor | > > > format=template | template=my_template }} > > > > > > Note that Many visitors are associated with the same Visit, so #ask > > > passes a COMMA-separated list of visitors as the 4th argument to > > > my_template. I tried to use "sep" parameter, but it separates entire > > > records, not items within a multi-value. > > > > > > I probably can workaround the issue with nested queries (e. g. drop > > > "?Visitor" printout statement and request Visitors within my_template by > > > {{ #show: {{{1}}} | ?Visitor }}), but is there another way to handle this > > > issue? > > > > I have run into the same issue, and opened a bug report about it, some time > > ago: https://bugzilla.wikimedia.org/show_bug.cgi?id=22777 > > > > The patch in the bug report works against 1.5.6 (I think), but not against > > current trunk / 1.6 - but I'm sure it won't be hard to adjust it. > > > > I hope the 'itemsep' parameter can be integrated into SMW at some point, it > > makes working with multiple values in one property more flexible. > > > > Patrick. > > > > - -- > > Key ID: 0x86E346D4 http://patrick-nagel.net/key.asc > > Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4 > > -----BEGIN PGP SIGNATURE----- > > Version: GnuPG v2.0.17 (GNU/Linux) > > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > > > iEYEARECAAYFAk4qNvUACgkQyYHmhobjRtSg8ACfRwUE1FNzv0ppljAVi25r70S/ > > fH8AoJH8eKz2i/JeISH0808R9KwgEWqd > > =0Ux3 > > -----END PGP SIGNATURE----- > > > > ------------------------------------------------------------------------------ > > Storage Efficiency Calculator > > This modeling tool is based on patent-pending intellectual property that > > has been used successfully in hundreds of IBM storage optimization engage- > > ments, worldwide. Store less, Store more with what you own, Move data to > > the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/ > > _______________________________________________ > > Semediawiki-user mailing list > > Sem...@li... > > https://lists.sourceforge.net/lists/listinfo/semediawiki-user > |