如何使用XSLT封装我的XML块周围的节点? 例如,我有以下XML文件。XSLT:添加节点!
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="/">
<Root>
<VOBaseCollection>
<xsl:apply-templates select="Root/Location" />
</VOBaseCollection>
</Root>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
我的输入XML文件看起来像这样。
<Root>
<Location><Name>Pennsylvania</Name><Type>State</Type></Location>
</Root>
我希望输出看起来像这样。
<Root><Container>
<Location><Name>Pennsylvania</Name><Type>State</Type></Location>
</Container>
</Root>
我想确保一个名为<CONTAINER>
节点被应用于每一次,它复制了从根/位置信息。我需要对XSLT文件进行哪些更改?
目前尚不清楚你想要做什么。你如何提供一个小样本XML文件和你希望得到的输出? – Welbog 2010-07-12 15:47:52
我的XML文件看起来像这样。 [代码] 宾夕法尼亚 国家 [/代码] 我想这个文件转换成 [代码] 宾夕法尼亚 国家 [/代码] –
abhi
2010-07-12 17:23:12
那么什么是''在你的例子?如果您将其重命名为'',看起来您将拥有完全想要的内容。 –
Welbog
2010-07-12 17:55:44