Reputation: 3963
XML:
<Calendars xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Urnik.xsd">
<Calendar>
<Name>Marko</Name>
<Days>
<Day>
<Date>2013-05-13</Date>
<DayType>1</DayType>
<DayWorking>1</DayWorking>
<WorkingTimes>
<WorkingTime>
<FromTime>08:00</FromTime>
<ToTime>11:00</ToTime>
<Name>Izpit Matematika</Name>
<Owner>Marko</Owner>
<Category>
<School Professor="111" Room="1" Subject="882" />
</Category>
</WorkingTime>
<WorkingTime>
<FromTime>13:00</FromTime>
<ToTime>17:00</ToTime>
<Name>Vaje APZ</Name>
<Owner>Marko</Owner>
<Category>
<School Professor="222" Room="11" Subject="881"/>
</Category>
</WorkingTime>
<WorkingTime>
<FromTime>20:00</FromTime>
<ToTime>22:00</ToTime>
<Name>Vaje aaaaaa</Name>
<Owner>Marko</Owner>
<Category>
<School Professor="222" Room="11" Subject="881"/>
</Category>
</WorkingTime>
</WorkingTimes>
</Day>
<Day>
<Date>2013-05-14</Date>
<DayType>2</DayType>
...
</Day>
XSLT:
<xsl:for-each select="Calendar/Days/Day">
<xsl:choose>
<xsl:when test="DayType = 1">
<xsl:variable name="vTransfers" select="child::*/WorkingTime"/>
Can I somehow check this variable vTransfers
if 08:00
exist in FromTime
. I do not want to loop it beacuse I need to place it in correct TD
row. And I am now in this TD and i woul like to check if 08:00
exist in FromTime
in this array.
I try something like
<xsl:when test="contains($vTransfers/ToTime, '08:00')">
<xsl:text>IN</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>OUT</xsl:text>
</xsl:otherwise>
but always takes just firs one and not check whole array.
Upvotes: 0
Views: 13639
Reputation: 33658
If you pass a node-set to contains
, it is converted to a string. This means that only string value of the first node is taken. Try something like that:
<xsl:when test="$vTransfers[contains(ToTime, '08:00')]">
This should work, too:
<xsl:when test="WorkingTimes/WorkingTime/ToTime = '08:00'">
Upvotes: 4