我有一个这样的输入 XML:-
<Results>
<School>
<Name>A</Name>
<Location>
<StreetAddress>abc</StreetAddress>
<Distance>5</Distance>
</Location>
<Location>
<StreetAddress>def</StreetAddress>
<Distance>3</Distance>
</Location>
<Location>
<StreetAddress>xyz</StreetAddress>
<Distance>6</Distance>
</Location>
</School>
<School>
<Name>B</Name>
<Location>
<StreetAddress>abc1</StreetAddress>
<Distance>7</Distance>
</Location>
<Location>
<StreetAddress>def2</StreetAddress>
<Distance>6</Distance>
</Location>
<Location>
<StreetAddress>xyz3</StreetAddress>
<Distance>2</Distance>
</Location>
</School>
<School>
<Name>C</Name>
<Location>
<StreetAddress>abc4</StreetAddress>
<Distance>2</Distance>
</Location>
<Location>
<StreetAddress>def5</StreetAddress>
<Distance>1</Distance>
</Location>
<Location>
<StreetAddress>xyz6</StreetAddress>
<Distance>0.5</Distance>
</Location>
</School>
使用 XSL v1,我需要对距离上的位置节点进行排序,然后按最小距离对学校进行排序基本上输出应该是这样的
<Results>
<School>
<Name>C</Name>
<Location>
<StreetAddress>xyz6</StreetAddress>
<Distance>0.5</Distance>
</Location>
<Location>
<StreetAddress>def5</StreetAddress>
<Distance>1</Distance>
</Location>
<Location>
<StreetAddress>abc4</StreetAddress>
<Distance>2</Distance>
</Location>
</School>
<School>
<Name>B</Name>
<Location>
<StreetAddress>xyz3</StreetAddress>
<Distance>2</Distance>
</Location>
<Location>
<StreetAddress>def2</StreetAddress>
<Distance>6</Distance>
</Location>
<Location>
<StreetAddress>abc1</StreetAddress>
<Distance>7</Distance>
</Location>
</School>
<School>
<Name>A</Name>
<Location>
<StreetAddress>def</StreetAddress>
<Distance>3</Distance>
</Location>
<Location>
<StreetAddress>abc</StreetAddress>
<Distance>5</Distance>
</Location>
<Location>
<StreetAddress>xyz</StreetAddress>
<Distance>6</Distance>
</Location>
</School>
我可以通过首先根据距离对节点进行排序,将它们存储在一个变量中,然后在 /Results/School/Location[1]/Distance 上再次对其进行排序来做到这一点。
我想知道是否有一种方法可以一次性完成所有这些。
感谢你的帮助。