0
XSLT를 사용하여 XML 요소를 추가하려고합니다. 요소를 추가 한 후 새로 추가 된 요소 안에 일부 요소를 이동하려고합니다. XML 요소를 기존 XML에 추가하고 XML 요소를 내부로 이동하는 방법
이
내가 <Collection>
<ONE/>
<TWO/>
<THREE/>
<PARTCollection>
<Allparts>
<part>
<number>001</number>
<material>Platinum</material>
<price>High</price>
</part>
<part>
<number>002</number>
<material>Gold</material>
<price>Medium</price>
</part>
<part>
<number>003</number>
<material>Silver</material>
<price>Low</price>
</part>
</Allparts>
</PARTCollection>
<BOMCollection>
<Allboms>
<bom>
<Part-number>001</Part-number>
</bom>
<bom>
<Part-number>002</Part-number>
</bom>
<bom>
<Part-number>003</Part-number>
</bom>
</Allboms>
<BOMCollection>
</Collection>
내가
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Collection">
<xsl:copy>
<BOMCollection></BOMCollection>
<PARTCollection></PARTCollection>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="BOMCollection">
<xsl:copy>
<xsl:apply-templates select="../Allboms"
mode="move" />
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="PARTCollection">
<xsl:copy>
<xsl:apply-templates select="../Allparts"
mode="move" />
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Allboms" mode="move">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Allparts" mode="move">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
새로운 요소가 제대로 만드는
을 쓴 이에 대한하지만 데이터와 같은 출력이 아닌 원하는 내 XML
<Collection>
<ONE/>
<TWO/>
<THREE/>
<Allparts>
<part>
<number>001</number>
<material>Platinum</material>
<price>High</price>
</part>
<part>
<number>002</number>
<material>Gold</material>
<price>Medium</price>
</part>
<part>
<number>003</number>
<material>Silver</material>
<price>Low</price>
</part>
</Allparts>
<Allboms>
<bom>
<Part-number>001</Part-number>
</bom>
<bom>
<Part-number>002</Part-number>
</bom>
<bom>
<Part-number>003</Part-number>
</bom>
</Allboms>
</Collection>
입니다 그 안에 들어가서이 일을 어떻게 할 수 있는지 말해 주시겠습니까
마틴을 사용하는 것이 충분합니다. 다른 질문에 대한 도움이 필요합니다. 도와 주시겠습니까? 감사합니다 http://stackoverflow.com/questions/38993864/match-and-merge-in-xslt-with-optional-nodes – Victor