我正在尝试使用xsl 2.0转换xml这是传入的xml
<sprints>
<sprint>
<sprintid>260</sprintid>
<name>-</name>
<startdate>05-26-2016</startdate>
<enddate>06-09-2016</enddate>
<weeks>2</weeks>
<capacity>6</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>56</biid>
<name>test14</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-23 13:45:21.0</createdat>
<updatedat>2016-05-23 13:45:21.0</updatedat>
<priority>0</priority>
<size>8</size>
<enddate>06-09-2016</enddate>
</item>
</items>
<testenddate>06-09-2016</testenddate>
<csv>Summary,IssueType,Description,DueDate,Story Points
test14,story,,,8
</csv>
<sprint>
<sprintid>262</sprintid>
<name />
<startdate>06-23-2016</startdate>
<enddate>07-07-2016</enddate>
<weeks>2</weeks>
<capacity>12</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>59</biid>
<name>test689</name>
<description>-</description>
<targetdate>2017-05-23</targetdate>
<bid>5</bid>
<createdat>2016-05-23 13:53:21.0</createdat>
<updatedat>2016-05-23 19:12:20.0</updatedat>
<priority>1</priority>
<size>11</size>
<enddate>07-07-2016</enddate>
</item>
<item>
<biid>57</biid>
<name>sdfdsf</name>
<description>-</description>
<targetdate>2016-05-18</targetdate>
<bid>5</bid>
<createdat>2016-05-23 13:51:15.0</createdat>
<updatedat>2016-05-23 19:11:33.0</updatedat>
<priority>2</priority>
<size>11</size>
<enddate>07-07-2016</enddate>
</item>
</items>
<testenddate>07-07-2016</testenddate>
<csv>Summary,IssueType,Description,DueDate,Story Points
test689,story,-,2017-05-23,11
sdfdsf,story,-,2016-05-18,11
</csv>
</sprint>
<sprint>
<sprintid>263</sprintid>
<name />
<startdate>07-07-2016</startdate>
<enddate>07-21-2016</enddate>
<weeks>2</weeks>
<capacity>12</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>60</biid>
<name>test09</name>
<description>-</description>
<targetdate>2017-05-23</targetdate>
<bid>5</bid>
<createdat>2016-05-23 13:54:30.0</createdat>
<updatedat>2016-05-23 19:23:22.0</updatedat>
<priority>3</priority>
<size>2</size>
<enddate>07-21-2016</enddate>
</item>
<item>
<biid>88</biid>
<name>tets89</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 13:41:06.0</createdat>
<updatedat>2016-05-26 13:41:06.0</updatedat>
<priority>4</priority>
<size>100</size>
<enddate>07-21-2016</enddate>
</item>
</items>
<testenddate>07-21-2016</testenddate>
<csv>Summary,IssueType,Description,DueDate,Story Points
test09,story,-,2017-05-23,2
tets89,story,,,100
</csv>
</sprint>
<sprint>
<sprintid>264</sprintid>
<name />
<startdate>07-21-2016</startdate>
<enddate>08-04-2016</enddate>
<weeks>2</weeks>
<capacity>12</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>88</biid>
<name>tets89</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 13:41:06.0</createdat>
<updatedat>2016-05-26 13:41:06.0</updatedat>
<priority>4</priority>
<size>100</size>
<enddate>08-04-2016</enddate>
</item>
</items>
<testenddate>08-04-2016</testenddate>
<csv>Summary,IssueType,Description,DueDate,Story Points
tets89,story,,,100
</csv>
</sprint>
<sprint>
<sprintid>265</sprintid>
<name />
<startdate>08-04-2016</startdate>
<enddate>08-18-2016</enddate>
<weeks>2</weeks>
<capacity>12</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>88</biid>
<name>tets89</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 13:41:06.0</createdat>
<updatedat>2016-05-26 13:41:06.0</updatedat>
<priority>4</priority>
<size>100</size>
<enddate>08-18-2016</enddate>
</item>
</items>
<testenddate>08-18-2016</testenddate>
<csv>Summary,IssueType,Description,DueDate,Story Points
tets89,story,,,100
</csv>
</sprint>
<sprint>
<sprintid>266</sprintid>
<name />
<startdate>08-18-2016</startdate>
<enddate>09-01-2016</enddate>
<weeks>2</weeks>
<capacity>12</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>88</biid>
<name>tets89</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 13:41:06.0</createdat>
<updatedat>2016-05-26 13:41:06.0</updatedat>
<priority>4</priority>
<size>100</size>
<enddate>09-01-2016</enddate>
</item>
</items>
<testenddate>09-01-2016</testenddate>
<csv>Summary,IssueType,Description,DueDate,Story Points
tets89,story,,,100
</csv>
</sprint>
<sprint>
<sprintid>267</sprintid>
<name />
<startdate>09-01-2016</startdate>
<enddate>09-15-2016</enddate>
<weeks>2</weeks>
<capacity>12</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>88</biid>
<name>tets89</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 13:41:06.0</createdat>
<updatedat>2016-05-26 13:41:06.0</updatedat>
<priority>4</priority>
<size>100</size>
<enddate>09-15-2016</enddate>
</item>
</items>
<testenddate>09-15-2016</testenddate>
<csv>Summary,IssueType,Description,DueDate,Story Points
tets89,story,,,100
</csv>
</sprint>
<sprint>
<sprintid>268</sprintid>
<name />
<startdate>09-15-2016</startdate>
<enddate>09-29-2016</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>88</biid>
<name>tets89</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 13:41:06.0</createdat>
<updatedat>2016-05-26 13:41:06.0</updatedat>
<priority>4</priority>
<size>100</size>
<enddate>September</enddate>
</item>
</items>
<testenddate>September</testenddate>
</sprint>
<sprint>
<sprintid>269</sprintid>
<name />
<startdate>09-29-2016</startdate>
<enddate>10-13-2016</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>88</biid>
<name>tets89</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 13:41:06.0</createdat>
<updatedat>2016-05-26 13:41:06.0</updatedat>
<priority>4</priority>
<size>100</size>
<enddate>October</enddate>
</item>
</items>
<testenddate>October</testenddate>
</sprint>
<sprint>
<sprintid>270</sprintid>
<name />
<startdate>10-13-2016</startdate>
<enddate>10-27-2016</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>88</biid>
<name>tets89</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 13:41:06.0</createdat>
<updatedat>2016-05-26 13:41:06.0</updatedat>
<priority>4</priority>
<size>100</size>
<enddate>October</enddate>
</item>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>October</enddate>
</item>
</items>
<testenddate>October</testenddate>
</sprint>
<sprint>
<sprintid>271</sprintid>
<name />
<startdate>10-27-2016</startdate>
<enddate>11-10-2016</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>November</enddate>
</item>
</items>
<testenddate>November</testenddate>
</sprint>
<sprint>
<sprintid>272</sprintid>
<name />
<startdate>11-10-2016</startdate>
<enddate>11-24-2016</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>November</enddate>
</item>
</items>
<testenddate>November</testenddate>
</sprint>
<sprint>
<sprintid>273</sprintid>
<name />
<startdate>11-24-2016</startdate>
<enddate>12-08-2016</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>December</enddate>
</item>
</items>
<testenddate>December</testenddate>
</sprint>
<sprint>
<sprintid>274</sprintid>
<name />
<startdate>12-08-2016</startdate>
<enddate>12-22-2016</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>December</enddate>
</item>
</items>
<testenddate>December</testenddate>
</sprint>
<sprint>
<sprintid>275</sprintid>
<name />
<startdate>12-22-2016</startdate>
<enddate>01-05-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>January</enddate>
</item>
</items>
<testenddate>January</testenddate>
</sprint>
<sprint>
<sprintid>278</sprintid>
<name />
<startdate>02-02-2017</startdate>
<enddate>02-16-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q1</enddate>
</item>
</items>
<testenddate>Q1</testenddate>
</sprint>
<sprint>
<sprintid>279</sprintid>
<name />
<startdate>02-16-2017</startdate>
<enddate>03-02-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q1</enddate>
</item>
</items>
<testenddate>Q1</testenddate>
</sprint>
<sprint>
<sprintid>280</sprintid>
<name />
<startdate>03-02-2017</startdate>
<enddate>03-16-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q1</enddate>
</item>
</items>
<testenddate>Q1</testenddate>
</sprint>
<sprint>
<sprintid>281</sprintid>
<name />
<startdate>03-16-2017</startdate>
<enddate>03-30-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q1</enddate>
</item>
</items>
<testenddate>Q1</testenddate>
</sprint>
<sprint>
<sprintid>282</sprintid>
<name />
<startdate>03-30-2017</startdate>
<enddate>04-13-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q2</enddate>
</item>
</items>
<testenddate>Q2</testenddate>
</sprint>
<sprint>
<sprintid>283</sprintid>
<name />
<startdate>04-13-2017</startdate>
<enddate>04-27-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q2</enddate>
</item>
</items>
<testenddate>Q2</testenddate>
</sprint>
<sprint>
<sprintid>284</sprintid>
<name />
<startdate>04-27-2017</startdate>
<enddate>05-11-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q2</enddate>
</item>
</items>
<testenddate>Q2</testenddate>
</sprint>
<sprint>
<sprintid>285</sprintid>
<name />
<startdate>05-11-2017</startdate>
<enddate>05-25-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q2</enddate>
</item>
</items>
<testenddate>Q2</testenddate>
</sprint>
<sprint>
<sprintid>286</sprintid>
<name />
<startdate>05-25-2017</startdate>
<enddate>06-08-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q2</enddate>
</item>
</items>
<testenddate>Q2</testenddate>
</sprint>
<sprint>
<sprintid>287</sprintid>
<name />
<startdate>06-08-2017</startdate>
<enddate>06-22-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q2</enddate>
</item>
</items>
<testenddate>Q2</testenddate>
</sprint>
<sprint>
<sprintid>288</sprintid>
<name />
<startdate>06-22-2017</startdate>
<enddate>07-06-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q3</enddate>
</item>
</items>
<testenddate>Q3</testenddate>
</sprint>
<sprint>
<sprintid>289</sprintid>
<name />
<startdate>07-06-2017</startdate>
<enddate>07-20-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q3</enddate>
</item>
</items>
<testenddate>Q3</testenddate>
</sprint>
<sprint>
<sprintid>290</sprintid>
<name />
<startdate>07-20-2017</startdate>
<enddate>08-03-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q3</enddate>
</item>
</items>
<testenddate>Q3</testenddate>
</sprint>
<sprint>
<sprintid>291</sprintid>
<name />
<startdate>08-03-2017</startdate>
<enddate>08-17-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q3</enddate>
</item>
</items>
<testenddate>Q3</testenddate>
</sprint>
<sprint>
<sprintid>292</sprintid>
<name />
<startdate>08-17-2017</startdate>
<enddate>08-31-2017</enddate>
<weeks>2</weeks>
<capacity>20</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q3</enddate>
</item>
</items>
<testenddate>Q3</testenddate>
</sprint>
<sprint>
<sprintid>293</sprintid>
<name />
<startdate>08-31-2017</startdate>
<enddate>09-14-2017</enddate>
<weeks>2</weeks>
<capacity>300</capacity>
<teamid>5</teamid>
<items>
<item>
<biid>90</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-26 16:53:52.0</createdat>
<updatedat>2016-05-26 16:53:52.0</updatedat>
<priority>5</priority>
<size>500</size>
<enddate>Q3</enddate>
</item>
<item>
<biid>91</biid>
<name>testt</name>
<description />
<targetdate />
<bid>5</bid>
<createdat>2016-05-27 03:40:23.0</createdat>
<updatedat>2016-05-27 03:40:23.0</updatedat>
<priority>6</priority>
<size>4</size>
<enddate>Q3</enddate>
</item>
</items>
<testenddate>Q3</testenddate>
</sprint>
<result>Ok</result>
</sprints>
我正在尝试获得所有不同的冲刺,并且在这些不同的冲刺内,我希望看到属于冲刺的所有不同项目。为了这样做,这是我的xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:variable name="sprints" select="sprints/sprint" />
<xsl:variable name="items" select="sprints/sprint/items/item" />
<xsl:template match="/">
<root>
<sprints>
<xsl:for-each select="distinct-values(sprints/sprint/testenddate)">
<sprint>
<enddate><xsl:value-of select="." /></enddate>
<items>
<xsl:for-each select="distinct-values($items/biid)">
<item>
<xsl:value-of select="." />
</item>
</xsl:for-each>
</items>
</sprint>
</xsl:for-each>
</sprints>
</root>
</xsl:template>
</xsl:stylesheet>
输出不是我的预期:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xs="http://www.w3.org/2001/XMLSchema">
<sprints>
<sprint>
<enddate>06-09-2016</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>06-23-2016</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>07-07-2016</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>07-21-2016</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>09-15-2016</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>September</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>October</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>November</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>December</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>January</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>Q1</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>Q2</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
<sprint>
<enddate>Q3</enddate>
<items>
<item>56</item>
<item>59</item>
<item>57</item>
<item>60</item>
<item>88</item>
<item>90</item>
<item>91</item>
</items>
</sprint>
</sprints>
</root>
sprint是截然不同的,但是所有的项目都出现在所有冲刺中,我希望与正确的sprint相匹配。我怎么能这样做?
答案 0 :(得分:3)
使用xsl:for-each-group而不是distinct-values更容易实现,因为distinct-values只为您提供不同的日期值,而for-each-groups为您提供了每个不同的sprint组日期值。
所以你想要这样的东西:
<xsl:for-each-group select="/sprints/sprint" group-by="enddate">
<sprint>
<enddate><xsl:value-of select="current-grouping-key()"/></enddate>
<items>
<xsl:for-each-group select="current-group()/item" group-by="biid">
...
</xsl:for-each-group>
</items>
</sprint>
</xsl:for-each-group>
答案 1 :(得分:1)
这是一个解决方案。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:variable name="sprints" select="/sprints/sprint" />
<xsl:template match="/">
<root>
<sprints>
<xsl:for-each select="distinct-values(sprints/sprint/testenddate)">
<xsl:variable name="date" select="."/>
<sprint>
<enddate><xsl:value-of select="." /></enddate>
<items>
<xsl:for-each select="distinct-values($sprints[testenddate/text()=$date]/items/item/biid)">
<item>
<xsl:value-of select="." />
</item>
</xsl:for-each>
</items>
</sprint>
</xsl:for-each>
</sprints>
</root>
</xsl:template>
</xsl:stylesheet>
这是使用XSLT 2.0的分组功能编写的相同解决方案,不需要变量:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<root>
<sprints>
<xsl:for-each-group select="/sprints/sprint" group-by="testenddate">
<sprint>
<enddate><xsl:value-of select="current-grouping-key()"/></enddate>
<items>
<xsl:for-each select="distinct-values(current-group()/items/item/biid)">
<item>
<xsl:value-of select="." />
</item>
</xsl:for-each>
</items>
</sprint>
</xsl:for-each-group>
</sprints>
</root>
</xsl:template>
</xsl:stylesheet>