xslt排序(xslt sorting)
我有一个以xml格式返回的项目列表。 每个项目都有各种元素。 其中一个元素是“位置”,取值在0-6之间
如果Position为0则不应显示该项,但如果它在1到6之间,我需要显示它。
我该如何做xslt以便它按“位置”的顺序列出项目
I have a list of items being returned in xml. each item has various elements. one of the elements is "Position" which takes a value between 0-6
if Position is 0 then the item should not be shown, but if its between 1 and 6 I need it to be shown.
how can i do the xslt so that it will list the items by order of "Position"
原文:https://stackoverflow.com/questions/1012989
最满意答案
使用一个简单的循环进行测试,如果它对于删除是“有效”,则删除第一个和最后一个:
bool isValid = value[0] == '(' && value[value.Length - 1] == ')'; int i = 1; int c = 0; for(; isValid && c >= 0 && i < value.Length - 1; i++) { if(value[i] == '(') c++; else if(value[i] == ')') c--; } if(isValid && i == (value.Length - 1) && c == 0) value = value.Substring(1, value.Length - 2);
Use a simple loop for testing, if it's "valid" for removal, remove first & last:
bool isValid = value[0] == '(' && value[value.Length - 1] == ')'; int i = 1; int c = 0; for(; isValid && c >= 0 && i < value.Length - 1; i++) { if(value[i] == '(') c++; else if(value[i] == ')') c--; } if(isValid && i == (value.Length - 1) && c == 0) value = value.Substring(1, value.Length - 2);
相关问答
更多-
s/\([^)]*\)// 所以在Python中,你可以这样做: re.sub(r'\([^)]*\)', '', filename) s/\([^)]*\)// So in Python, you'd do: re.sub(r'\([^)]*\)', '', filename)
-
如何使用NSRegularExpression删除括号内的文本?(How to remove text within parentheses using NSRegularExpression?)[2022-04-13]
删除正则表达式分隔符并确保您也排除(在字符类中: NSString *phraseLabelWithBrackets = @"(test text) 1 2 3 text test"; NSError *error = NULL; NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:@"\\([^()]+\\)" options:NSRegularExpressionCaseInsensitive e ... -
$string = "ABC (Test1)"; echo preg_replace("/\([^)]+\)/","",$string); // 'ABC ' preg_replace是一个基于Perl的正则表达式替换例程。 该脚本执行的操作是匹配所有出现的开始括号,后跟任意数量的字符而不是右括号,并且后跟一个右括号,然后删除它们: 正则表达式分解: / - opening delimiter (necessary for regular expressions, can be any characte ...
-
如何删除字符串中的外部圆括号之间的所有文本?(How to remove all text between the outer parentheses in a string?)[2021-04-28]
re匹配是急切的,所以他们尝试匹配尽可能多的文本,对于你提到的简单测试用例,让正则表达式运行: >>> re.sub(r'\(.*\)', '', 'stuff(remove(me))') 'stuff' re matches are eager so they try to match as much text as possible, for the simple test case you mention just let the regex run: >>> re.sub(r'\(.*\)', ' ... -
[({\[](?!key).*?[)\]}] 您可以使用此功能轻松完成此操作。请参阅演示。 https://regex101.com/r/wX9fR1/23 textpop向上 import re p = re.compile(r'[({\[](?!key).*?[)\]}]', re.MULTILINE) test_str = "\n\n text1 (key) text2\n\n text1 (key) text2 (some other text)\n\n [key] text.. text.. [ ...
-
尝试使用Notepad ++的查找/替换功能。 找: \r(?!\n) 用。。。来代替: (空间) 您需要检查正则表达式复选框: 首先尝试替换几行(例如,选择前80行),然后在选择中替换以查看。 如果可以,您可以继续处理整个文件。 在上面\r \n将匹配CR和\n将匹配LF。 (?!\n)是一个特殊的组,意思是'如果后跟\n '则不匹配\r '。 注意:我认为notepad ++有时不能正确替换,因此如果立即更换整个文件会导致问题,请尝试更换较小的批次。 我通常使用脚本来做这样的事情,但如果你不习惯,我认 ...
-
改变正则表达式如下: \(.*?\) .*? 匹配任何字符(除了换行符) 量词: *? 在零和无限次之间,尽可能少的次数,根据需要扩展[懒惰] 演示 Change the regex as below: \(.*?\) .*? matches any character (except newline) Quantifier: *? Between zero and unlimited times, as few times as possible, expanding as needed [laz ...
-
如何仅在整个文本被它们包围时删除括号?(How to remove parentheses only when the whole text is surrounded by them?)[2023-12-26]
使用一个简单的循环进行测试,如果它对于删除是“有效”,则删除第一个和最后一个: bool isValid = value[0] == '(' && value[value.Length - 1] == ')'; int i = 1; int c = 0; for(; isValid && c >= 0 && i < value.Length - 1; i++) { if(value[i] == '(') c++; else if(value[i] == ')') c--; } if ... -
我们可以通过提取括号内的子字符串paste其paste在一起来完成此操作 library(stringr) paste(str_extract_all(str1, "\\([^)]*\\)")[[1]], collapse=' ') #[1] "( some pineapples over 4 ) ( coconuts with happy face :D ) ( they are for my parents sorry ;C )" 或者我们可以使用基于gsub的解决方案 trimws(gsub("\\ ...
-
您可以使用标准的“搜索和替换”。 按CTRL + H,查找不带引号的“(*)”并替换为空。 如果要使用公式解决此问题,请使用LEFT,SEARCH和MID的组合。 =LEFT(H23,SEARCH("(",H23)-1)&MID(H23,SEARCH(")",H23)+2,99) You could just use standard "Search and Replace". Hit CTRL+H, look for "(*)" without quotation marks and replace w ...