在XSLT / XPath中将xpath xml元素的并集表示为公共父级的子级

时间:2019-10-29 09:53:08

标签: xml xslt xpath xslt-1.0

我正在尝试在xslt样式表中执行类似伪代码xpath //noah/(shem or cham or yefet)的操作,虽然我可以执行//noah/shem | //noah/cham | //noah/yefet,但我也遇到了2 * 2交叉乘积的情况,这种情况变得丑陋得很快。 / p>

实际样式表为here,而我正在尝试为{{3}添加fact的别名flang的别名l },其中包含有关人与物的类人动物(Chuck Norris / etc。)。

1 个答案:

答案 0 :(得分:1)

在XPath 2和更高版本中,您实际上可以使用2019-10-29 20:56:59.942 D/SERVERINFO: Server ID is 1 Name is Server 1 2019-10-29 20:56:59.943 D/SERVERINFO: Server ID is 2 Name is Server 2 2019-10-29 20:56:59.943 D/SERVERINFO: Server ID is 3 Name is Server 3 2019-10-29 20:56:59.945 D/ACCOUNTINFO: Account ID is 1 Account Name is FRED Account Server ID is 1 active is true 2019-10-29 20:56:59.945 D/ACCOUNTINFO: Account ID is 2 Account Name is MARY Account Server ID is 1 active is false 2019-10-29 20:56:59.945 D/ACCOUNTINFO: Account ID is 3 Account Name is JANE Account Server ID is 2 active is false 2019-10-29 20:56:59.945 D/ACCOUNTINFO: Account ID is 4 Account Name is ANNE Account Server ID is 2 active is false 2019-10-29 20:56:59.945 D/ACCOUNTINFO: Account ID is 5 Account Name is VERA Account Server ID is 3 active is false 2019-10-29 20:56:59.945 D/ACCOUNTINFO: Account ID is 6 Account Name is JOHN Account Server ID is 3 active is false 2019-10-29 20:56:59.947 D/CONTACTINFO: Contact ID is 1 Contact Name is C1 Contact Server ID is 1 2019-10-29 20:56:59.947 D/CONTACTINFO: Contact ID is 2 Contact Name is C2 Contact Server ID is 2 2019-10-29 20:56:59.947 D/CONTACTINFO: Contact ID is 3 Contact Name is C3 Contact Server ID is 3 2019-10-29 20:56:59.947 D/CONTACTINFO: Contact ID is 4 Contact Name is C4 Contact Server ID is 3 2019-10-29 20:56:59.953 D/CSAINFO: SERVER ID is 1 ACCOUNT ID is 2 CONTACT ID is 1 CONTACT NAME is C1 2019-10-29 20:56:59.954 D/CSALINFO: SERVER ID is 1 ACCOUNT ID is 1 CONTACT ID is 1 CONTACT NAME is C1 //noah/(shem, cham, yefet)。使用XPath 1,您只能使用//noah/(shem | cham | yefet)