如何使用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