【发布时间】:2012-03-27 01:36:30
【问题描述】:
我想选择满足特定条件的节点列表,在处理完这些节点后,我想选择剩余的节点。如何在 XSLT 和 XPath 中做到这一点。
下面是场景,我有这个xml
<books>
<book name="Basic XML">
<type>Educational</type>
<grouping>A</grouping>
</book>
<book name="Basic XML">
<type>Tutorial</type>
<grouping>A</grouping>
</book>
<book name="Basic XSLT">
<type>Educational</type>
<grouping>A</grouping>
</book>
<book name="Basic XSLT">
<type>Tutorial</type>
<grouping>A</grouping>
</book>
<book name="Basic Java">
<type>Educational</type>
<grouping>A</grouping>
</book>
<book name="Basic Java">
<type>Tutorial</type>
<grouping>A</grouping>
</book>
<book name="Web Service">
<type>Educational</type>
<grouping>A</grouping>
</book>
<book name="C Programming">
<type>Educational</type>
<grouping>A</grouping>
</book>
</books>
1。选择“教程”的<type>的所有<book>节点,下面是输出
<books>
<book name="Basic XML">
<type>Tutorial</type>
<grouping>A</grouping>
</book>
<book name="Basic XSLT">
<type>Tutorial</type>
<grouping>A</grouping>
</book>
<book name="Basic Java">
<type>Tutorial</type>
<grouping>A</grouping>
</book>
</books>
2。然后选择其他<book> 节点没有“教程”的<type> 并且与#1 中选择的@name 不同,输出仅为:
<books>
<book name="Web Service">
<type>Educational</type>
<grouping>A</grouping>
</book>
<book name="C Programming">
<type>Educational</type>
<grouping>A</grouping>
</book>
</books>
【问题讨论】: