我想使用xslt对xml中的日期进行排序,并且我的日期元素在xsd中使用数据类型进行验证,因为下面的日期是我的xml和xsl
XML
<Trade xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Symbol xsi:type="TradedSymbol" Type="Swap">
<Economic xsi:type="EconomicLeg">
<Leg xsi:type="IRLegGeneratedFixed">
<Schedule xsi:type="ScheduleGeneratorFixed">
<Date>2014-06-17</Date>
</Schedule>
</Leg>
</Economic>
</Symbol>
<Symbol xsi:type="TradedSymbol" Type="Swap">
<Economic xsi:type="EconomicDetailIRLeg">
<Leg xsi:type="IRLegFloat">
<Schedule xsi:type="ScheduleGeneratorFloat">
<Date>2018-06-17</Date>
</Schedule>
</Leg>
</Economic>
</Symbol>
<Symbol xsi:type="TradedSymbol" Type="Floor">
<Economic xsi:type="EconomicDetailIRLeg">
<Leg xsi:type="IRLegFloat">
<Schedule xsi:type="ScheduleGeneratorFloat">
<Date>2000-06-17</Date>
</Schedule>
</Leg>
</Economic>
</Symbol>
</Trade>
XSD
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="fiExoticStructuredDeal">
<fixedIncomeExoticDeal>
<frontOfficeDealDescription>Empty decription</frontOfficeDealDescription>
<component>
<frontOfficeComponentType>
<optionDetails>
<optionStyle>European</optionStyle>
<optionDates>
<adjustedDate>
<xsl:for-each select="/Trade/Symbol/Economic/Leg/Schedule">
<xsl:sort select="concat(substring-before(Date,'-'), substring-before(substring-after(Date,'- '),'-'),substring-after(substring-after(Date,'-'),'-'))" order="ascending"/>
<xsl:choose>
<xsl:when test="position() = last()">
<xsl:value-of select="Date"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</adjustedDate>
</optionDates>
</optionDetails>
</frontOfficeComponentType>
</component>
</fixedIncomeExoticDeal>
</xsl:template>
</xsl:stylesheet>
我无法使用xslt对日期进行排序。它总是在Schedule元素中给我最后一个日期。如果有人让我知道我错过了什么,那就太好了。
使用
<xsl:sort select="Date" order="ascending"/>