Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.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
Xml xslt多部分密钥分组_Xml_Xslt_Key_Grouping - Fatal编程技术网

Xml xslt多部分密钥分组

Xml xslt多部分密钥分组,xml,xslt,key,grouping,Xml,Xslt,Key,Grouping,假设我有一些xml,如下所示: <root> <object id='1'/> <object id='1' otherid='2'/> <object otherid='2'/> <object otherid='2' yetanotherid='3'/> <object yetanotherid='3'/> <object id='2'>I'm not the same</object> <

假设我有一些xml,如下所示:

<root>
<object id='1'/>
<object id='1' otherid='2'/>
<object otherid='2'/>
<object otherid='2' yetanotherid='3'/>
<object yetanotherid='3'/>
<object id='2'>I'm not the same</object>
</root>

我不一样
可爱,我知道。现在这些都是相同的对象,但它们有各种ID。我如何将它们分组?这些id中的任何一个都将唯一标识,因此id[1]=otherid[2]=yetanotherid[3]

一个完整的例子:

<root>
<object id='1'><property1></property1></object>
<object id='1' otherid='2'><property1></property1></object>
<object otherid='2'><property2></property2></object>
<object otherid='2' yetanotherid='3'><property3></property3></object>
<object yetanotherid='3'><property2></property2><property4></property4></object>
<object id='2'><property2></property2></object>
</root>

结果:

<root>
<object id='1' otherid='2' yetanotherid='3'>
<property1></property1>
<property2></property2>
<property3></property3>
<property4></property4>
</object>
<object id='2'>
<property2></property2>
</object>
</root>


您能给出一个示例输出吗?对于这个输入,将有两组,第一组是前5个对象,第二组是最后一个对象。这将适用于我的另一个问题,我正在合并同一对象的元素。我需要对对象进行分组,以便合并它们。因此,如果我理解正确,您希望仅基于id属性对它们进行分组吗?我仍然不清楚您希望如何对元素进行分组。您可以基于id属性创建两个组,但并非所有元素都具有该属性,因此不具有该属性的元素将被忽略。id[1]=otherid[2]=yetanotherid[3]是什么意思?由于其中一个元素的id=1和otherid=2,我们知道[id=1]=[otherid=2],由于另一个元素的otherid=2和yetanotherid=3,我们知道[otherid=2]=[yetanotherid=3],并且通过扩展[id=1]=[yetanotherid=3]。因此,所有这些都应该分组在一起。我不知道该怎么做。我们之所以知道这一点,是因为ID是唯一标识的,所以如果一个元素拥有2,您就知道它们是等价的标识符。