您好我有一个XML我需要使用XSL将XML转换为另一种XML使用XSL转换XML到XML
我的XML看起来像
<Information>
<ShipmentType>
<shipmentType>A</shipmentType>
</ShipmentType>
<ShipmentRouting>
<airportCityCodeOrigin>AAA</airportCityCodeOrigin>
<airportCityCodeDestination>BBB</airportCityCodeDestination>
</ShipmentRouting>
<EarliestDepartureDateTime>
<dayOfMonth>00</dayOfMonth>
<month>OCT</month>
</EarliestDepartureDateTime>
</Information>
应该转化成这种格式:
<ECIDRA-INP>
<DRA-INP>
<OPTION>
<ORIGIN>
<STATION>AAA</STATION>
</ORIGIN>
<DEST>
<STATION>BBB</STATION>
</DEST>
</OPTION>
</DRA-INP>
</ECIDRA-INP>
我只需要值<airportCityCodeOrigin>
和<airportCityCodeDestination>
但我得到的所有标签值。
下面是我写的XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/Information">
<ECIDRA-INP>
<DRA-INP>
<OPTION>
<ORIGIN>
<STATION>
<xsl:value-of select="./ShipmentRouting/airportCodeofDeparture"></xsl:value-of>
</STATION>
</ORIGIN>
<DEST>
<STATION>
<xsl:value-of select="./ShipmentRouting/airportCodeofArrival"></xsl:value-of>
</STATION>
</DEST>
</OPTION>
</DRA-INP>
</ECIDRA-INP>
</xsl:template>
</xsl:stylesheet>
“我的XML看上去l IKE” ..;你的意思是没有尖括号的XML? ;-)请给我们展示真正的XML(和真正的XSLT)。 – 2011-02-01 14:28:51