使用XSLT在另一个节点内移动具有名称空间的节点

使用XSLT在另一个节点内移动具有名称空间的节点,xslt,Xslt,我的输入xml如下所示: <?xml version="1.0" encoding="UTF-8"?> <response> <response> <case> <CRDATTIM>2017-02-13-07.04.12.346420</CRDATTIM> <issues> <row> <

我的输入xml如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <response>
      <case>
         <CRDATTIM>2017-02-13-07.04.12.346420</CRDATTIM>
         <issues>
            <row>
               <IKEY>2017-02-13-07.04.10.293420T01</IKEY>
            </row>
         </issues>
      </case>
      <results>
         <row>
            <IKEY>2017-02-13-07.04.10.293420T01</IKEY>
         </row>
      </results>
   </response>
   <results>
      <children xmlns="http://www.dsttechnologies.com/awd/rest/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema" total="1">
         <sourceInstance recordType="source" id="2017-02-22-01.02.41.198440O01">
            <link rel="attachments" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/attachments" />
            <link rel="fieldvalues" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/fieldvalues" />
            <link rel="form" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/form" />
            <link rel="history" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/history" />
            <link rel="parents" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/parents" />
            <link rel="presentation summary" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/presentationsummary" />
            <link rel="self" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01" />
            <link rel="archive" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/archive" />
            <permission>Update</permission>
            <secondaryTagline />
            <businessAreaName href="awdServer/awd/services/v1/businessareas/CS2XAA">CS2XAA</businessAreaName>
            <date>2017-02-22</date>
            <summary>CS2XAA - 2XSRCTYP - 044000000049 - Updateable - Create Date:2017-02-22 - Create Time:01:02:41-06:00</summary>
            <time>01:02:41-06:00</time>
            <typeName href="awdServer/awd/services/v1/businessareas/CS2XAA/types/2XSRCTYP">2XSRCTYP</typeName>
            <createStation>DT77214</createStation>
            <createUser href="awdServer/awd/services/v1/users/DT77214">Reddy, BATCH (DT77214)</createUser>
            <objectFormat format="I">IOCA</objectFormat>
            <objectId>044000000049</objectId>
            <opticalStatus status="2">Original state</opticalStatus>
            <receiveDate>2017-02-22</receiveDate>
            <receiveTime>01:02:41-06:00</receiveTime>
            <securityLevel>0</securityLevel>
         </sourceInstance>
      </children>
   </results>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<response>
   <response>
      <case>
         <CRDATTIM>2017-02-13-07.04.12.346420</CRDATTIM>
         <issues>
            <row>
               <IKEY>2017-02-13-07.04.10.293420T01</IKEY>
               <children xmlns="http://www.dsttechnologies.com/awd/rest/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema" total="1">
                  <sourceInstance recordType="source" id="2017-02-22-01.02.41.198440O01">
                     <link rel="attachments" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/attachments" />
                     <link rel="fieldvalues" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/fieldvalues" />
                     <link rel="form" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/form" />
                     <link rel="history" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/history" />
                     <link rel="parents" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/parents" />
                     <link rel="presentation summary" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/presentationsummary" />
                     <link rel="self" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01" />
                     <link rel="archive" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/archive" />
                     <permission>Update</permission>
                     <secondaryTagline />
                     <businessAreaName href="awdServer/awd/services/v1/businessareas/CS2XAA">CS2XAA</businessAreaName>
                     <date>2017-02-22</date>
                     <summary>CS2XAA - 2XSRCTYP - 044000000049 - Updateable - Create Date:2017-02-22 - Create Time:01:02:41-06:00</summary>
                     <time>01:02:41-06:00</time>
                     <typeName href="awdServer/awd/services/v1/businessareas/CS2XAA/types/2XSRCTYP">2XSRCTYP</typeName>
                     <createStation>DT77214</createStation>
                     <createUser href="awdServer/awd/services/v1/users/DT77214">Reddy, BATCH (DT77214)</createUser>
                     <objectFormat format="I">IOCA</objectFormat>
                     <objectId>044000000049</objectId>
                     <opticalStatus status="2">Original state</opticalStatus>
                     <receiveDate>2017-02-22</receiveDate>
                     <receiveTime>01:02:41-06:00</receiveTime>
                     <securityLevel>0</securityLevel>
                  </sourceInstance>
               </children>
            </row>
         </issues>
      </case>
      <results>
         <row>
            <IKEY>2017-02-13-07.04.10.293420T01</IKEY>
         </row>
      </results>
   </response>
   <results>
      <children xmlns="http://www.dsttechnologies.com/awd/rest/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema" total="1">
         <sourceInstance recordType="source" id="2017-02-22-01.02.41.198440O01">
            <link rel="attachments" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/attachments" />
            <link rel="fieldvalues" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/fieldvalues" />
            <link rel="form" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/form" />
            <link rel="history" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/history" />
            <link rel="parents" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/parents" />
            <link rel="presentation summary" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/presentationsummary" />
            <link rel="self" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01" />
            <link rel="archive" type="application/vnd.dsttechnologies.awd+xml" href="awdServer/awd/services/v1/instances/2017-02-22-01.02.41.198440O01/archive" />
            <permission>Update</permission>
            <secondaryTagline />
            <businessAreaName href="awdServer/awd/services/v1/businessareas/CS2XAA">CS2XAA</businessAreaName>
            <date>2017-02-22</date>
            <summary>CS2XAA - 2XSRCTYP - 044000000049 - Updateable - Create Date:2017-02-22 - Create Time:01:02:41-06:00</summary>
            <time>01:02:41-06:00</time>
            <typeName href="awdServer/awd/services/v1/businessareas/CS2XAA/types/2XSRCTYP">2XSRCTYP</typeName>
            <createStation>DT77214</createStation>
            <createUser href="awdServer/awd/services/v1/users/DT77214">Reddy, BATCH (DT77214)</createUser>
            <objectFormat format="I">IOCA</objectFormat>
            <objectId>044000000049</objectId>
            <opticalStatus status="2">Original state</opticalStatus>
            <receiveDate>2017-02-22</receiveDate>
            <receiveTime>01:02:41-06:00</receiveTime>
            <securityLevel>0</securityLevel>
         </sourceInstance>
      </children>
   </results>
</response>
我尝试使用以下XSL,但无法获得所需的输出

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:v="http://www.dsttechnologies.com/awd/rest/v1" version="2.0" exclude-result-prefixes="v">
   <xsl:output method="xml" version="1.0" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
   <xsl:strip-space elements="*" />
   <xsl:template match="@* | node()">
      <xsl:copy>
         <xsl:apply-templates select="@* | node()" />
      </xsl:copy>
   </xsl:template>
   <xsl:template match="//response/response/case/issues/row">
      <xsl:copy>
         <xsl:apply-templates select="node()|@*" />

            <xsl:apply-templates select="v:response/results/children" />

      </xsl:copy>
   </xsl:template>
</xsl:stylesheet>


关于我在哪里犯的错误,你有什么想法吗?

你离这里不远,但是你的名称空间前缀放错了地方
children
是路径中命名空间中的唯一元素<代码>响应不在命名空间中。此外,您需要将“选择以搜索”更改为“文档”节点,而不是“当前匹配”节点

所以,不是这个

<xsl:apply-templates select="v:response/results/children" />

做这个

<xsl:apply-templates select="/response/results/v:children" />

太好了+1.请解释。