XSLT如果我的條件滿足,如何獲取以前的屬性值?XSLT如果我的條件滿足,如何獲取以前的屬性值?
我試圖得到所需的出,但沒有成功可有人請幫助我如何實現這一目標?
這裏是我的Zip.xml
<Zip>
<ZipNotify Zip="1144" ZipNo="1" ZipTime="2010-09-02T11:15:30+10:00"/>
<ZipDetail Zone="U" DepartZip="West" ArriveZip="West"/>
<ZipCategoryDetail ZORE="false" />
<ZipOrigin ZipOrigin="ABC002" Die="20:59:00"/>
<ZipDestination ZipDestination="UVW001" Live="21:38:00"/>
<ZipPath>
<ZipSubject ZipSubjectType="Payed" ZipNum="1">
<ZipRoute ZipLoc="ABC002" ZipStop="true" ZipDieTime="20:59:00" ZipDieTime1="20:59:00"/>
</ZipSubject>
<ZipSubject ZipSubjectType="Payed" ZipNum="2">
<ZipRoute ZipLoc="BCD002" ZipStop="true" ZipLiveTime="21:00:40" ZipDieTime1="21:01:00"/>
<ZipSpec Charge="false"/>
</ZipSubject>
<ZipSubject ZipSubjectType="Payed" ZipNum="3">
<ZipRoute ZipLoc="CDE001" ZipStop="true" ZipLiveTime="21:03:40" ZipDieTime1="21:04:00"/>
<ZipSpec Charge="true"/>
</ZipSubject>
<ZipSubject ZipSubjectType="Payed" ZipNum="4">
<ZipRoute ZipLoc="DEF001" ZipStop="true" ZipLiveTime="21:05:40" ZipDieTime1="21:06:00"/>
<ZipSpec Charge="true"/>
</ZipSubject>
<ZipSubject ZipSubjectType="Payed" ZipNum="5">
<ZipRoute ZipLoc="EFG001" ZipStop="true" ZipLiveTime="21:07:40" ZipDieTime1="21:08:00"/>
<ZipSpec Charge="true"/>
</ZipSubject>
<ZipSubject ZipSubjectType="Payed" ZipNum="5">
<ZipRoute ZipLoc="UVW001" ZipStop="true" ZipLiveTime="21:38:00" ZipLiveTime1="21:38:00"/>
<ZipSpec Charge="true"/>
</ZipSubject>
</ZipPath>
</Zip>
這裏是我的XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head/>
<body>
<xsl:for-each select="/Zip/ZipPath/ZipSubject">
<xsl:if test="/Zip/ZipPath/ZipSubject/ZipSpec/@Charge = 'true'">
<div>ZipLoc: <xsl:value-of select="/Zip/ZipPath/ZipSubject/ZipRoute/@ZipLoc"/> </div>
<div>Charge: <xsl:value-of select="/Zip/ZipPath/ZipSubject/ZipSpec/@Charge"/></div>
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
出把我想要的 我想以前ZipSubject的保鮮袋在電荷= 「真」 例如。對於ZipNum =「3」值Charge =「true」,所以我的輸出必須顯示以前的ZipLoc =「BCD002」(即使Charge =「false」ZipNum =「2」)就是這樣,它不應該進一步驗證ZipOrigin和對於ZipDestination又應該從最後ZipNum =「5」,如果充電=「真」,那麼幹脆就應該使用相同的保鮮袋=「UVW001」檢查
所需的輸出應該是
BCD002UVW001
但我的輸出在下面。我曾嘗試可能的方法(我知道它缺乏與XSLT經驗,這不是藉口),請幫助我獲得所需的輸出
ZipLoc: ABC002
Charge: false
ZipLoc: ABC002
Charge: false
ZipLoc: ABC002
Charge: false
ZipLoc: ABC002
Charge: false
ZipLoc: ABC002
Charge: false
ZipLoc: ABC002
Charge: false
不清楚最後是期望的輸出。 –