第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 XLS 轉(zhuǎn)換復(fù)制 XML 節(jié)點并粘貼到同一級別

如何使用 XLS 轉(zhuǎn)換復(fù)制 XML 節(jié)點并粘貼到同一級別

拉風(fēng)的咖菲貓 2021-06-21 16:09:38
我想復(fù)制一個 xml 的節(jié)點并將其粘貼到同一級別??紤]我有一個 xml,如下所示。<MyXml>    <system>        <Groups>            <Group id="01" check="true">            <name>Value</name>            <age>test</age>        </Group>        <Group id="02" check="true">            <name>Value</name>            <age>test</age>        </Group>        <Group id="03" check="true">            <name>Value</name>            <age>test</age>        </Group>        </Groups>  </system></MyXml>我想復(fù)制組 03 并使用 XSL 轉(zhuǎn)換粘貼到與“04”相同的級別(組內(nèi))。預(yù)期產(chǎn)出<MyXml>    <system>        <Groups>            <Group id="01" check="true">                <name>Value</name>                <age>test</age>            </Group>            <Group id="02" check="true">                <name>Value</name>                <age>test</age>            </Group>            <Group id="03" check="true">                <name>Value</name>                <age>test</age>            </Group>            <Group id="04" check="true">                <name>Value</name>                <age>test</age>            </Group>        </Groups>  </system></MyXml>有人可以幫忙完成相同的 XSL 樣式表。不確定下面的 xsl 是否正確。提前致謝。<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/><xsl:param name="groupId" /><xsl:param name="newGroupId" /><xsl:template match="node()|@*" name="identity">  <xsl:copy>    <xsl:apply-templates select="node()|@*"/>  </xsl:copy> </xsl:template><xsl:template match="MyXML/system/Groups/Group[@id=$groupId]" > <xsl:copy>    <xsl:apply-templates select="@*|node()"/>            <!--Wanted to do something for pasting the copied node and changing the id value with new Group Id.-->  </xsl:copy></xsl:template></xsl:stylesheet>
查看完整描述

1 回答

?
慕碼人2483693

TA貢獻1860條經(jīng)驗 獲得超9個贊

在 XSLT 1.0 中,在模板匹配中包含變量表達式實際上被認為是錯誤的(盡管您可能會發(fā)現(xiàn)某些處理器允許這樣做)。


但是你可能應(yīng)該做的,就是在模板匹配中調(diào)用身份模板Group,然后有一個xsl:if決定是否復(fù)制它。


試試這個模板


<xsl:template match="Group" >

  <xsl:call-template name="identity" />;

  <xsl:if test="@id = $groupId">

    <group id="{$newGroupId}">

      <xsl:apply-templates select="@*[name() != 'id']|node()"/>

    </group>

  </xsl:if>

</xsl:template>

請注意,您不需要Group模板匹配中的完整路徑,除非Group您不想匹配其他級別的元素。(此外,MyXML當(dāng)您的 XML 將其設(shè)為MyXml.XSLT時,您當(dāng)前的匹配指的是 。XSLT 區(qū)分大小寫,因此不會匹配)。


查看完整回答
反對 回復(fù) 2021-06-23
  • 1 回答
  • 0 關(guān)注
  • 128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號