-3
我是XSLT轉換的新手。
這是我以前的question的延伸。現在我正在複製像這樣的所有節點,然後根據前面的question的答案轉換它們。XSLT模板:只需複製子元素
<!-- Copy everything -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
但是輸入有兩個父元素。
<Parent1>
<Parent11>
<Element1>
<!--Rest of the xml I want to work with-->
</Element1>
<Parent11>
<Parent21>
<Other></Other>
</Parent21>
<Parent1>
我嘗試使用
<xsl:template match="Element1">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
但隨後回到我以純文本格式的XML值。值爲<Parent21>
孩子。
基於答案我想
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="Parent1/Parent11/Element1"/>
</xsl:copy>
</xsl:template>
該返回我什麼。
我會在哪裏使用它?在轉換結束時,我將擁有多個'Element1'。 –
更新了我的答案。 –