Tags:
create new tag
view all tags

SID-01599: Populating edit table select with table search

Status: Answered Answered TWiki version: 5.0.2 Perl version: 5.8.8
Category: EditTablePlugin Server OS: RedHat Linux, kernel 2.6.18 Last update: 13 years ago

I have a topic with a table. I'm attempting to create an edit table that will be included in multiple other topics, and in populating that generic edit table's select list with the contents from the first topic's table. I've been able to create the formatted search that will create the proper list, however in the context of an edit table definition the embedded '|' characters in the search result in an improperly formatted table and not the desired search results. I've also tried to define a topic preference variable populated with the search results, but because the edit table is included in other topics, the preference variable is not defined in the included context.

Is there a way to delay the evaluation of the vertical bar (like there is for '%' by using $percnt)?

Is there some other way to embed a table search in an edit table definition?

Topic: ReusedSchemaAttributes

Name OID Single? Description
uid 0.9.2342.19200300.100.1.1 no User ID
mail 0.9.2342.19200300.100.1.3 no User email address

Topic: AttributeEditTable

%EDITTABLE{ header="| *Name* | *Single?* |" format="| select, 1, $percntSEARCH{\".*?\| ([a-zA-Z0-9]+) \| .*\" topic=\"ReusedSchemaAttributes\" type=\"regex\" multiple=\"on\" separator=\", \" nonoise=\"on\" }$percnt | radio, 2, YES, no |" }%

-- JoshuaTharp - 2012-12-03

Discussion and Answer

I've been playing with this quite a bit today. The best solution I've been able to find is to use the character class [:punct:] instead of "|". It makes the proper match, but it's not as specific as I would like.

%EDITTABLE{ header="| *Name* | *Single?* |" format="| select, 1, $percntSEARCH{\"[[:punct:]] +([[:alpha:]]+) +[[:punct:]] +[[:digit:]\.]+ +[[:punct:]].*\" format=\"$pattern([[:punct:]] +([[:alnum:]]+) +[[:punct:]] +[[:digit:]\.]+ +[[:punct:]].*)\" topic=\"ReusedSchemaAttributes\" type=\"regex\" multiple=\"on\" separator=\", \" nonoise=\"on\"}$percnt | radio, 2, YES, no |" }%

-- JoshuaTharp - 2012-12-03

You can tell regex to use the hex code of the "|" character, "\x7c". Example:

$ perl -e 'print "aaa\x7cbbb\n";'
aaa|bbb

-- PeterThoeny - 2012-12-04

Thanks for the tip, Peter, but I can't seem to get that to work. I've tried a number of different combinations, and extracted the search part to remove a variable.

These searches worked, but employ the '|' character so will not work with the EditTablePlugin.

%SEARCH{"\| +[[:alpha:]]+ +\| +[[:digit:]\.]+ +\|.*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%
%SEARCH{"\|[[:space:]]+[[:alpha:]]+[[:space:]]+\|[[:space:]]+[[:digit:]\.]+[[:space:]]+\|.*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%

None of these searches worked (meaning they returned no results).

%SEARCH{"\|\s+[[:alpha:]]+\s+\|\s+[[:digit:]\.]+\s+\|.*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%
%SEARCH{"\x7c +[[:alpha:]]+ +\x7c +[[:digit:]\.]+ +\x7c.*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%
%SEARCH{"\\x7c +[[:alpha:]]+ +\\x7c +[[:digit:]\.]+ +\\x7c.*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%
%SEARCH{"\\\x7c +[[:alpha:]]+ +\\\x7c +[[:digit:]\.]+ +\\\x7c.*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%
%SEARCH{"[\x7c] +[[:alpha:]]+ +[\x7c] +[[:digit:]\.]+ +[\x7c].*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%
%SEARCH{"[\\x7c] +[[:alpha:]]+ +[\\x7c] +[[:digit:]\.]+ +[\\x7c].*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%
%SEARCH{"[\\\x7c] +[[:alpha:]]+ +[\\\x7c] +[[:digit:]\.]+ +[\\\x7c].*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%
%SEARCH{"| +[[:alpha:]]+ +| +[[:digit:]\.]+ +|.*" format="$text" topic="ReusedSchemaAttributes" type="regex" multiple="on"}%

As you can see I've tried a number of different levels of escaping to try and get the '|' character in the regular expression. Also, you might notice that my attempt to use '\s' instead of ' ' didn't work either. Is there some additional setting that enables the use of backslash character classes and hex character specification?

-- JoshuaTharp - 2012-12-04

This works. Table:

aaa 12313 24243
bbb 354181 9453
ccc 82734 62354


SEARCH using "\|":
uid 0.9.2342.19200300.100.1.1 no User ID
mail 0.9.2342.19200300.100.1.3 no User email address
aaa 12313 24243
bbb 354181 9453
ccc 82734 62354


SEARCH using "\x7c" instead of "\|":
uid 0.9.2342.19200300.100.1.1 no User ID
mail 0.9.2342.19200300.100.1.3 no User email address
aaa 12313 24243
bbb 354181 9453
ccc 82734 62354

-- PeterThoeny - 2012-12-04

Interestingly, it does not work on my installation. I copied and pasted your exact markup into my TWiki and the one with the \| works, but the one with the \x7c does not. Is this a feature introduced with TWiki 5.1.x?

-- JoshuaTharp - 2012-12-04

Not sure, I do not recall of any change in search that could affect this. Perl version is also the same on your system and twiki.org.

-- PeterThoeny - 2012-12-04

Well, I guess I'll have to put a TWiki upgrade on my calendar and see if that fixes the search problem.

Thanks for the help.

-- JoshuaTharp - 2012-12-10

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Populating edit table select with table search
SupportCategory EditTablePlugin
TWiki version 5.0.2
Server OS RedHat Linux, kernel 2.6.18
Web server Apache 2.2.3
Perl version 5.8.8
Browser & version Firefox 16.0.2
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2012-12-10 - JoshuaTharp
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.