使用xsl 2.0将元素从1 xml复制到另一个

时间:2016-06-08 13:14:04

标签: xml xslt

我正在尝试将元素从1 xml复制到另一个 这是我的xml所在的

<sprints xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <sprint>
        <sprintid>332</sprintid>
        <name>dfgdfgdfg</name>
        <startdate>06-07-2016</startdate>
        <enddate>06-21-2016</enddate>
        <weeks>2</weeks>
        <capacity>5</capacity>
        <teamid>5</teamid>
        <items>
            <item>
                <biid>56</biid>
                <name>test14</name>
                <description>-</description>
                <targetdate />
                <bid>5</bid>
                <createdat>2016-05-23 13:45:21.0</createdat>
                <updatedat>2016-05-27 12:30:04.0</updatedat>
                <priority>0</priority>
                <size>3</size>
                <enddate>06-21-2016</enddate>
                <remainderitemcapacity>3</remainderitemcapacity>
            </item>
            <item>
                <biid>92</biid>
                <name>test89</name>
                <description />
                <targetdate />
                <bid>5</bid>
                <createdat>2016-05-27 11:40:39.0</createdat>
                <updatedat>2016-05-27 11:40:39.0</updatedat>
                <priority>1</priority>
                <size>11</size>
                <enddate>06-21-2016</enddate>
                <remainderitemcapacity>2</remainderitemcapacity>
            </item>
        </items>
        <testenddate>2016-06-21</testenddate>
        <csv>Summary,IssueType,Description,DueDate,Story Points
            test14,story,-,,3
            test89,story,,,11
        </csv>
    </sprint>
    <sprint>
        <sprintid>333</sprintid>
        <name />
        <startdate>06-21-2016</startdate>
        <enddate>07-05-2016</enddate>
        <weeks>2</weeks>
        <capacity>5</capacity>
        <teamid>5</teamid>
        <items>
            <item>
                <biid>92</biid>
                <name>test89</name>
                <description />
                <targetdate />
                <bid>5</bid>
                <createdat>2016-05-27 11:40:39.0</createdat>
                <updatedat>2016-05-27 11:40:39.0</updatedat>
                <priority>1</priority>
                <size>11</size>
                <enddate>07-05-2016</enddate>
                <remainderitemcapacity>5</remainderitemcapacity>
            </item>
        </items>
        <testenddate>2016-07-05</testenddate>
        <csv>Summary,IssueType,Description,DueDate,Story Points
            test89,story,,,11
        </csv>
    </sprint>
    <sprint>
        <sprintid>334</sprintid>
        <name />
        <startdate>07-05-2016</startdate>
        <enddate>07-19-2016</enddate>
        <weeks>2</weeks>
        <capacity>5</capacity>
        <teamid>5</teamid>
        <items>
            <item>
                <biid>92</biid>
                <name>test89</name>
                <description />
                <targetdate />
                <bid>5</bid>
                <createdat>2016-05-27 11:40:39.0</createdat>
                <updatedat>2016-05-27 11:40:39.0</updatedat>
                <priority>1</priority>
                <size>11</size>
                <enddate>07-19-2016</enddate>
                <remainderitemcapacity>4</remainderitemcapacity>
            </item>
            <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>2</priority>
                <size>11</size>
                <enddate>07-19-2016</enddate>
                <remainderitemcapacity>1</remainderitemcapacity>
            </item>
        </items>
        <testenddate>2016-07-19</testenddate>
        <csv>Summary,IssueType,Description,DueDate,Story Points
            test89,story,,,11
            test689,story,-,2017-05-23,11
        </csv>
    </sprint>
    <sprint>
        <sprintid>335</sprintid>
        <name />
        <startdate>07-19-2016</startdate>
        <enddate>08-02-2016</enddate>
        <weeks>2</weeks>
        <capacity>5</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>2</priority>
                <size>11</size>
                <enddate>08-02-2016</enddate>
                <remainderitemcapacity>5</remainderitemcapacity>
            </item>
        </items>
        <testenddate>2016-08-02</testenddate>
        <csv>Summary,IssueType,Description,DueDate,Story Points
            test689,story,-,2017-05-23,11
        </csv>
    </sprint>
    <sprint>
        <sprintid>336</sprintid>
        <name />
        <startdate>08-02-2016</startdate>
        <enddate>08-16-2016</enddate>
        <weeks>2</weeks>
        <capacity>5</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>2</priority>
                <size>11</size>
                <enddate>08-16-2016</enddate>
                <remainderitemcapacity>5</remainderitemcapacity>
            </item>
        </items>
        <testenddate>2016-08-16</testenddate>
        <csv>Summary,IssueType,Description,DueDate,Story Points
            test689,story,-,2017-05-23,11
        </csv>
    </sprint>
  <result>Ok</result>

这是我希望它复制到的xml。请记住,2 xmls是,除了剩余的容量元素相同

    <?xml version="1.0" encoding="UTF-8"?>
    <sprints>
        <sprint>
            <testenddate>2016-06-21</testenddate>
            <sprintid>332</sprintid>
            <name>dfgdfgdfg</name>
            <startdate>2016-06-07</startdate>
            <enddate>2016-06-21</enddate>
            <teamid>5</teamid>
            <weeks>2</weeks>
            <capacity>5</capacity>
            <items>
                <item>
                    <BIID>56</BIID>
                    <NAME>test14</NAME>
                    <DESCRIPTION>-</DESCRIPTION>
                    <SIZE>3</SIZE>
                    <TARGETDATE />
                    <BID>5</BID>
                    <CREATED_AT>2016-05-23 13:45:21.0</CREATED_AT>
                    <UPDATED_AT>2016-05-27 12:30:04.0</UPDATED_AT>
                    <PRIORITY>0</PRIORITY>
                </item>
                <item>
                    <BIID>92</BIID>
                    <NAME>test89</NAME>
                    <DESCRIPTION />
                    <SIZE>11</SIZE>
                    <TARGETDATE />
                    <BID>5</BID>
                    <CREATED_AT>2016-05-27 11:40:39.0</CREATED_AT>
                    <UPDATED_AT>2016-05-27 11:40:39.0</UPDATED_AT>
                    <PRIORITY>1</PRIORITY>
                </item>
            </items>
            <csv>Summary,IssueType,Description,DueDate,Story Points
                test14,story,-,,3
                test89,story,,,11
            </csv>
        </sprint>
        <sprint>
            <testenddate>2016-07-05</testenddate>
            <sprintid>333</sprintid>
            <name />
            <startdate>2016-06-21</startdate>
            <enddate>2016-07-05</enddate>
            <teamid>5</teamid>
            <weeks>2</weeks>
            <capacity>5</capacity>
            <items>
                <item>
                    <BIID>92</BIID>
                    <NAME>test89</NAME>
                    <DESCRIPTION />
                    <SIZE>11</SIZE>
                    <TARGETDATE />
                    <BID>5</BID>
                    <CREATED_AT>2016-05-27 11:40:39.0</CREATED_AT>
                    <UPDATED_AT>2016-05-27 11:40:39.0</UPDATED_AT>
                    <PRIORITY>1</PRIORITY>
                </item>
            </items>
            <csv>Summary,IssueType,Description,DueDate,Story Points
                test89,story,,,11
            </csv>
        </sprint>
        <sprint>
            <testenddate>2016-07-19</testenddate>
            <sprintid>334</sprintid>
            <name />
            <startdate>2016-07-05</startdate>
            <enddate>2016-07-19</enddate>
            <teamid>5</teamid>
            <weeks>2</weeks>
            <capacity>5</capacity>
            <items>
                <item>
                    <BIID>92</BIID>
                    <NAME>test89</NAME>
                    <DESCRIPTION />
                    <SIZE>11</SIZE>
                    <TARGETDATE />
                    <BID>5</BID>
                    <CREATED_AT>2016-05-27 11:40:39.0</CREATED_AT>
                    <UPDATED_AT>2016-05-27 11:40:39.0</UPDATED_AT>
                    <PRIORITY>1</PRIORITY>
                </item>
                <item>
                    <BIID>59</BIID>
                    <NAME>test689</NAME>
                    <DESCRIPTION>-</DESCRIPTION>
                    <SIZE>11</SIZE>
                    <TARGETDATE>2017-05-23</TARGETDATE>
                    <BID>5</BID>
                    <CREATED_AT>2016-05-23 13:53:21.0</CREATED_AT>
                    <UPDATED_AT>2016-05-23 19:12:20.0</UPDATED_AT>
                    <PRIORITY>2</PRIORITY>
                </item>
            </items>
            <csv>Summary,IssueType,Description,DueDate,Story Points
                test89,story,,,11
                test689,story,-,2017-05-23,11
            </csv>
        </sprint>
        <sprint>
            <testenddate>2016-08-02</testenddate>
            <sprintid>335</sprintid>
            <name />
            <startdate>2016-07-19</startdate>
            <enddate>2016-08-02</enddate>
            <teamid>5</teamid>
            <weeks>2</weeks>
            <capacity>5</capacity>
            <items>
                <item>
                    <BIID>59</BIID>
                    <NAME>test689</NAME>
                    <DESCRIPTION>-</DESCRIPTION>
                    <SIZE>11</SIZE>
                    <TARGETDATE>2017-05-23</TARGETDATE>
                    <BID>5</BID>
                    <CREATED_AT>2016-05-23 13:53:21.0</CREATED_AT>
                    <UPDATED_AT>2016-05-23 19:12:20.0</UPDATED_AT>
                    <PRIORITY>2</PRIORITY>
                </item>
            </items>
            <csv>Summary,IssueType,Description,DueDate,Story Points
                test689,story,-,2017-05-23,11
            </csv>
        </sprint>
        <sprint>
            <testenddate>2016-08-16</testenddate>
            <sprintid>336</sprintid>
            <name />
            <startdate>2016-08-02</startdate>
            <enddate>2016-08-16</enddate>
            <teamid>5</teamid>
            <weeks>2</weeks>
            <capacity>5</capacity>
            <items>
                <item>
                    <BIID>59</BIID>
                    <NAME>test689</NAME>
                    <DESCRIPTION>-</DESCRIPTION>
                    <SIZE>11</SIZE>
                    <TARGETDATE>2017-05-23</TARGETDATE>
                    <BID>5</BID>
                    <CREATED_AT>2016-05-23 13:53:21.0</CREATED_AT>
                    <UPDATED_AT>2016-05-23 19:12:20.0</UPDATED_AT>
                    <PRIORITY>2</PRIORITY>
                </item>
            </items>
            <csv>Summary,IssueType,Description,DueDate,Story Points
                test689,story,-,2017-05-23,11
            </csv>
        </sprint>
<result>Ok</result>
</sprints>

为了实现我的目标,我创建了这个XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="2.0">
    <xsl:output method="xml" indent="yes" />
    <xsl:param name="items" />
    <xsl:template match="/">
        <sprints>
            <xsl:for-each select="/sprints/sprint">
                <sprint>
                    <testenddate>
                        <xsl:value-of select="testenddate" />
                    </testenddate>
                    <sprintid>
                        <xsl:value-of select="sprintid" />
                    </sprintid>
                    <name>
                        <xsl:value-of select="name" />
                    </name>
                    <startdate>
                        <xsl:value-of select="startdate" />
                    </startdate>
                    <enddate>
                        <xsl:value-of select="enddate" />
                    </enddate>
                    <teamid>
                        <xsl:value-of select="teamid" />
                    </teamid>
                    <weeks>
                        <xsl:value-of select="weeks" />
                    </weeks>
                    <capacity>
                        <xsl:value-of select="capacity" />
                    </capacity>
                    <items>
                        <xsl:for-each select="items/item">
                            <item>
                                <BIID>
                                    <xsl:value-of select="BIID" />
                                </BIID>
                                <NAME>
                                    <xsl:value-of select="NAME" />
                                </NAME>
                                <DESCRIPTION>
                                    <xsl:value-of select="DESCRIPTION" />
                                </DESCRIPTION>
                                <SIZE>
                                    <xsl:value-of select="SIZE" />
                                </SIZE>
                                <TARGETDATE>
                                    <xsl:value-of select="TARGETDATE" />
                                </TARGETDATE>
                                <BID>
                                    <xsl:value-of select="BID" />
                                </BID>
                                <CREATED_AT>
                                    <xsl:value-of select="CREATED_AT" />
                                </CREATED_AT>
                                <UPDATED_AT>
                                    <xsl:value-of select="UPDATED_AT" />
                                </UPDATED_AT>
                                <PRIORITY>
                                    <xsl:value-of select="PRIORITY" />
                                </PRIORITY>
                                <xsl:for-each select="$items/sprints/sprint/items/item/remainderitemcapacity">                              
                                <remainderitemcapacity>
                                    <xsl:value-of select="current()" />
                                </remainderitemcapacity>
                                </xsl:for-each>
                            </item>
                        </xsl:for-each>
                    </items>
                    <csv>
                        <xsl:value-of select="csv" />
                    </csv>
                </sprint>
            </xsl:for-each>
            <result>Ok</result>
        </sprints>
    </xsl:template>
</xsl:stylesheet>

但我的输出并不是我的预期:

<?xml version="1.0" encoding="UTF-8"?>
<sprints>
    <sprint>
        <testenddate>2016-06-21</testenddate>
        <sprintid>332</sprintid>
        <name>dfgdfgdfg</name>
        <startdate>2016-06-07</startdate>
        <enddate>2016-06-21</enddate>
        <teamid>5</teamid>
        <weeks>2</weeks>
        <capacity>5</capacity>
        <items>
            <item>
                <BIID>56</BIID>
                <NAME>test14</NAME>
                <DESCRIPTION>-</DESCRIPTION>
                <SIZE>3</SIZE>
                <TARGETDATE />
                <BID>5</BID>
                <CREATED_AT>2016-05-23 13:45:21.0</CREATED_AT>
                <UPDATED_AT>2016-05-27 12:30:04.0</UPDATED_AT>
                <PRIORITY>0</PRIORITY>
                <remainderitemcapacity>3</remainderitemcapacity>
                <remainderitemcapacity>2</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
            </item>
            <item>
                <BIID>92</BIID>
                <NAME>test89</NAME>
                <DESCRIPTION />
                <SIZE>11</SIZE>
                <TARGETDATE />
                <BID>5</BID>
                <CREATED_AT>2016-05-27 11:40:39.0</CREATED_AT>
                <UPDATED_AT>2016-05-27 11:40:39.0</UPDATED_AT>
                <PRIORITY>1</PRIORITY>
                <remainderitemcapacity>3</remainderitemcapacity>
                <remainderitemcapacity>2</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
            </item>
        </items>
        <csv>Summary,IssueType,Description,DueDate,Story Points
            test14,story,-,,3
            test89,story,,,11
        </csv>
    </sprint>
    <sprint>
        <testenddate>2016-07-05</testenddate>
        <sprintid>333</sprintid>
        <name />
        <startdate>2016-06-21</startdate>
        <enddate>2016-07-05</enddate>
        <teamid>5</teamid>
        <weeks>2</weeks>
        <capacity>5</capacity>
        <items>
            <item>
                <BIID>92</BIID>
                <NAME>test89</NAME>
                <DESCRIPTION />
                <SIZE>11</SIZE>
                <TARGETDATE />
                <BID>5</BID>
                <CREATED_AT>2016-05-27 11:40:39.0</CREATED_AT>
                <UPDATED_AT>2016-05-27 11:40:39.0</UPDATED_AT>
                <PRIORITY>1</PRIORITY>
                <remainderitemcapacity>3</remainderitemcapacity>
                <remainderitemcapacity>2</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
            </item>
        </items>
        <csv>Summary,IssueType,Description,DueDate,Story Points
            test89,story,,,11
        </csv>
    </sprint>
    <sprint>
        <testenddate>2016-07-19</testenddate>
        <sprintid>334</sprintid>
        <name />
        <startdate>2016-07-05</startdate>
        <enddate>2016-07-19</enddate>
        <teamid>5</teamid>
        <weeks>2</weeks>
        <capacity>5</capacity>
        <items>
            <item>
                <BIID>92</BIID>
                <NAME>test89</NAME>
                <DESCRIPTION />
                <SIZE>11</SIZE>
                <TARGETDATE />
                <BID>5</BID>
                <CREATED_AT>2016-05-27 11:40:39.0</CREATED_AT>
                <UPDATED_AT>2016-05-27 11:40:39.0</UPDATED_AT>
                <PRIORITY>1</PRIORITY>
                <remainderitemcapacity>3</remainderitemcapacity>
                <remainderitemcapacity>2</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
            </item>
            <item>
                <BIID>59</BIID>
                <NAME>test689</NAME>
                <DESCRIPTION>-</DESCRIPTION>
                <SIZE>11</SIZE>
                <TARGETDATE>2017-05-23</TARGETDATE>
                <BID>5</BID>
                <CREATED_AT>2016-05-23 13:53:21.0</CREATED_AT>
                <UPDATED_AT>2016-05-23 19:12:20.0</UPDATED_AT>
                <PRIORITY>2</PRIORITY>
                <remainderitemcapacity>3</remainderitemcapacity>
                <remainderitemcapacity>2</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>1</remainderitemcapacity>
                <remainderitemcapacity>4</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
                <remainderitemcapacity>5</remainderitemcapacity>
            </item>
        </items>
        <csv>Summary,IssueType,Description,DueDate,Story Points
            test89,story,,,11
            test689,story,-,2017-05-23,11
        </csv>
    </sprint>
    <result>Ok</result>
</sprints>

For-each item我只希望匹配的remainingitemcapacity不是每个项目中的所有项目。

我希望restitemcapacity与sprintid和biid匹配

1 个答案:

答案 0 :(得分:1)

我猜你想基于一些id值进行匹配,所以也许

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">

    <xsl:param name="doc2" select="doc('file1.xml')"/>

    <xsl:key name="sid" match="sprint" use="sprintid"/>
    <xsl:key name="item-id" match="item" use="biid"/>

    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="item">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
            <xsl:copy-of copy-namespaces="no"
                select="key('item-id', BIID, key('sid', ancestor::sprint/sprintid, $doc2))/remainderitemcapacity"
            />
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>

做你想做的事。