1
私は以下のXMLを持っています。値は、すべて私はこれをやって行くだろうか、いくつかのより多くの余分なデータを持つInformationBodyタグの後に新しいノードを追加する必要があるだけのテストの目的のためにノードXSLT内に新しいノードを挿入
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TAG1>
<placeholder>ghgh</placeholder>
<placeholder>ghg</placeholder>
<placeholder>ghgh</placeholder>
<placeholder>ghg</placeholder>
<placeholder>ghgh</placeholder>
<placeholder>ghg</placeholder>
<Information>
<InformationBody>
<Test>EE</Test>
<TestTwo>QU1RIENUVEIxICAgICAgIBI3f1QK6wEs</TestTwo>
<TestThree>20150119.141224508</TestThree>
</InformationBody>
</Information>
</TAG1>
を嘲笑していますか?私はXSLTの初心者ですが、上記を思いついたのですが、それが正しいかどうかはわかりません。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Identity template, copies everything as is -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Override for target element -->
<xsl:template match="TAG1">
<!-- Copy the element -->
<xsl:copy>
<!-- And everything inside it -->
<xsl:apply-templates select="@* | *"/>
<!-- Add new node -->
<xsl:element name="newNode"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
最終的な結果は、コピーされた後に要素を追加し、InformationBody
要素にマッチ-であるとして、それをコピーすることができ
<Information>
<InformationBody>
<Test>EE</Test>
<TestTwo>QU1RIENUVEIxICAgICAgIBI3f1QK6wEs</TestTwo>
<TestThree>20150119.141224508</TestThree>
</InformationBody>
<newTag></newTag>
</Information>