我正在使用 XSl 文件,我在其中从 xml 节点读取值并创建另一个 xml 文件。以下是输入xml的一部分,我想从中一一读取值节点。
输入 XML:
<Param>
<RoomsInvs>
<RoomInv>
<ProvisionalId Id="13-0000000007">13-0000000007</ProvisionalId>
</RoomInv>
<RoomInv>
<ProvisionalId Id="13-0000000008">13-0000000008</ProvisionalId>
</RoomInv>
</RoomsInvs>
<Rooms>
<Room NumberOfRooms="1" RoomId="TLC13-000005" Description="AC DEULEX" Twin="no" SupplierCode="RM" SupplierId="0" PropertyId="" ExtraBed="0" RateBasis="-4" Type="" Index="0">
<Rate Id="0" Currency="INR" Gross="4990.00" DisplayCurrency="INR" DisplayGross="4990.00" Net="4990.00" Tax="0" STax="" ExtraGuestCharge="0" AdultCount="2" AdultRate="1490.00" ChildCount="0" ChildRate=".00" Description="" Status="Available" AllocationDetails="-" SDisc="" SComm="" SRoomTotal="">
ieiorkmbjfgngjofmgfoikmfhkjg
</Rate>
</Room>
<Room NumberOfRooms="2" RoomId="TLC13-000005" Description="AC DEULEX" Twin="no" SupplierCode="RM" SupplierId="0" PropertyId="" ExtraBed="0" RateBasis="-4" Type="" Index="0">
<Rate Id="0" Currency="INR" Gross="4990.00" DisplayCurrency="INR" DisplayGross="4990.00" Net="4990.00" Tax="0" STax="" ExtraGuestCharge="0" AdultCount="2" AdultRate="1490.00" ChildCount="0" ChildRate=".00" Description="" Status="Available" AllocationDetails="-" SDisc="" SComm="" SRoomTotal="">
dbfbjsdbfjsdfbkjsdfbklnlnlsdf
</Rate>
</Room>
</Rooms>
<Param>
Xsl 应用:
<Rooms>
<xsl:apply-templates select="//Rooms/Room" >
<xsl:with-param name ="IdNo" select ="//RoomsInvs/RoomInv"></xsl:with-param>
</xsl:apply-templates>
</Rooms>
<xsl:template match="Room" >
<xsl:param name="IdNo"/>
<Room>
<tempID>
<xsl:value-of select="$IdNo[position()]/ProvisionalId"/>
</tempID>
<xsl:copy-of select="Rate"/>
</Room>
输出获取:
<Rooms>
<Room>
<tempID>13-0000000007</tempID>
<Rate Id="0" Currency="INR" Gross="4990.00" DisplayCurrency="INR" DisplayGross="4990.00" Net="4990.00" Tax="0" STax="" ExtraGuestCharge="0" AdultCount="2" AdultRate="1490.00" ChildCount="0" ChildRate=".00" Description="" Status="Available" AllocationDetails="-" SDisc="" SComm="" SRoomTotal="">
ieiorkmbjfgngjofmgfoikmfhkjg
</Rate>
</Room>
<Room>
<tempID>13-0000000007</tempID>
<Rate Id="0" Currency="INR" Gross="4990.00" DisplayCurrency="INR" DisplayGross="4990.00" Net="4990.00" Tax="0" STax="" ExtraGuestCharge="0" AdultCount="2" AdultRate="1490.00" ChildCount="0" ChildRate=".00" Description="" Status="Available" AllocationDetails="-" SDisc="" SComm="" SRoomTotal="">
dbfbjsdbfjsdfbkjsdfbklnlnlsdf
</Rate>
</Room>
</Rooms>
我想要的输出:
<Rooms>
<Room>
<tempID>13-0000000007</tempID>
<Rate Id="0" Currency="INR" Gross="4990.00" DisplayCurrency="INR" DisplayGross="4990.00" Net="4990.00" Tax="0" STax="" ExtraGuestCharge="0" AdultCount="2" AdultRate="1490.00" ChildCount="0" ChildRate=".00" Description="" Status="Available" AllocationDetails="-" SDisc="" SComm="" SRoomTotal="">
ieiorkmbjfgngjofmgfoikmfhkjg
</Rate>
</Room>
<Room>
<tempID>13-0000000008</tempID>
<Rate Id="0" Currency="INR" Gross="4990.00" DisplayCurrency="INR" DisplayGross="4990.00" Net="4990.00" Tax="0" STax="" ExtraGuestCharge="0" AdultCount="2" AdultRate="1490.00" ChildCount="0" ChildRate=".00" Description="" Status="Available" AllocationDetails="-" SDisc="" SComm="" SRoomTotal="">
dbfbjsdbfjsdfbkjsdfbklnlnlsdf
</Rate>
</Room>
</Rooms>