Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用xslt更改某些元素的值 输入xml结构如下所示: fdad dfsa fdad dfsa fdad dfsa_Xslt_Xslt 1.0 - Fatal编程技术网

使用xslt更改某些元素的值 输入xml结构如下所示: fdad dfsa fdad dfsa fdad dfsa

使用xslt更改某些元素的值 输入xml结构如下所示: fdad dfsa fdad dfsa fdad dfsa,xslt,xslt-1.0,Xslt,Xslt 1.0,在我的xsl中,我执行以下操作: The input xml structure is like this: <Envelopes> <env:Envelope> <urn:MyFunction> <parameter1 attr1='df'>fdad</parameter1> <parameter2 attr2='ww'>dfsa</parameter2>

在我的xsl中,我执行以下操作:

The input xml structure is like this:



  <Envelopes>
    <env:Envelope>
     <urn:MyFunction>
      <parameter1 attr1='df'>fdad</parameter1>
      <parameter2 attr2='ww'>dfsa</parameter2>
      <productData>
        <Id></Id>
        <Description></Description>
        <Price><Price>
      </productData>
    </urn:MyFunction>
    </env:Envelope>

    <env:Envelope>
     <urn:MyFunction1>
       <parameter1 attr1='df'>fdad</parameter1>
       <parameter2 attr2='ww'>dfsa</parameter2>
       <productData>
        <Id></Id>
        <Description></Description>
        <Price><Price>
       </productData>
    </urn:MyFunction>
   </env:Envelope>

   <env:Envelope>
     <urn:MyFunction1>
       <parameter1 attr1='df'>fdad</parameter1>
       <parameter2 attr2='ww'>dfsa</parameter2>
       <productData>
        <Id></Id>
        <Description></Description>
        <Price><Price>
       </productData>
    </urn:MyFunction>
   </env:Envelope>
 <Envelopes>

新描述

我打算保持
productData
元素和属性的其余部分不变,但修改其中一些。但是,生成的xml为
description
元素提供了新的值,但对于其余元素,只提供了
文本节点
。如何获取productData的所有其余节点?

您需要一个可以复制输入内容的标识模板。尝试将其添加到XSLT中:

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

<xsl:template match="productData/Description">
<Description>new Description</Description>
</xsl:template>

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