Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String XSLT从字符串中删除中间部分_String_Xslt - Fatal编程技术网

String XSLT从字符串中删除中间部分

String XSLT从字符串中删除中间部分,string,xslt,String,Xslt,新手XSLT问题: 我有一个由点分隔的3部分组成的字符串:2120.555.11111 如何删除中间部分,以2120.11111结束? 字符串部分长度可能不是常量,XPath 1.0为后代提供了单独的步骤: substring-before('2120.555.11111', '.') # '2120' concat('2120', '.') # '2120.' substring-after('2120.555.11111', '

新手XSLT问题: 我有一个由点分隔的3部分组成的字符串:2120.555.11111 如何删除中间部分,以2120.11111结束?
字符串部分长度可能不是常量,XPath 1.0为后代提供了单独的步骤:

substring-before('2120.555.11111', '.')       # '2120'
concat('2120', '.')                           # '2120.'
substring-after('2120.555.11111', '2120.')    # '555.11111'
substring-after('555.11111', '.')             # '11111'
concat('2120.', '11111')                      # '2120.11111'
合并后,假设包含“2120.555.11111”:

XPath 2.0+在字符串处理方面更加灵活,这是一种方法:

string-join(tokenize(X, '\.')[position() = 1 or position() = 3], '.')

在XSLT 2.0或更高版本中,您可以简单地执行以下操作:

replace(input, '\..*\.', '.')
replace(input, '\..*\.', '.')