0
我想使用xslt從給定的xml中獲取輸出xml。輸出xml將在給定的xml中添加一些元素。但我沒有獲得所需的輸出。使用XSLT在XML中進行修改
我有一個輸入XML,如:
<Response xmlns="http://xyz.abc/max/" xmlns:ns1="http://xyz.abc/max/">
<out xmlns="">
<Number xmlns="http://xyz.abc/max/">Desc1</Number>
<Address xmlns="http://xyz.abc/max">Desc2</Address>
<Records xmlns="http://xyz.abc/max">Desc3</Records>
</out>
</Response>
我想要一個XML輸出,如:
<?xml version="1.0" encoding="UTF-8"?>
<abc:Reqeust xmlns:abc="http://www.nnn.com/bnm"
xmlns:ns1="http://xyz.abc/max/" xmlns="http://xyz.abc/max/" >
<abc:Tray>
<abc:Remote>
<abc:ID>ID1</abc:ID>
<abc:Distance>Always</abc:Distance>
</abc:Remote>
<abc:Time>
1100-01-01T01:01:01+05:30
</abc:Time>
<abc:AreaMap />
</abc:Tray>
<abc:Area>
<abc:Get>
<abc:Fault>Token1</abc:Fault>
</abc:Get>
<Response xmlns="http://xyz.abc/max/" xmlns:ns1="http://xyz.abc/max/">
<out xmlns="">
<Number xmlns="http://xyz.abc/max/">Desc1</Number>
<Address xmlns="http://xyz.abc/max">Desc2</Address>
<Records xmlns="http://xyz.abc/max">Desc3</Records>
</out>
</Response>
</abc:Area>
</abc:Reqeust>
我使用XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="http://www.nnn.com/bnm"
xmlns:ns1="http://xyz.abc/max/" xmlns="http://xyz.abc/max/" >
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Response">
<abc:Request>
<abc:Tray>
<abc:Remote>
<abc:ID>ID1</abc:ID>
<abc:Distance>Always</abc:Distance>
</abc:Remote>
<abc:Time>
1100-01-01T01:01:01+05:30
</abc:Time>
<abc:AreaMap />
</abc:Tray>
<abc:Area>
<abc:Get>
<abc:Fault>Token1</abc:Fault>
</abc:Get>
<Response>
<xsl:apply-templates select="@*|node()"/>
</Response>
</abc:Area>
</abc:Request>
</xsl:template>
</xsl:stylesheet>
,但我沒有得到所需的輸出。 我應該在xslt中做出什麼改變才能獲得所需的輸出xml?