-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'。 –
更新了我的答案。 –