0

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.

1
  • 1
    You always must include the output HTML you want to see. (Also - since you've deleted your previous question: Did you manage to solve it yourself?) Commented Aug 22, 2013 at 9:20

1 Answer 1

4

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'">
Sign up to request clarification or add additional context in comments.

1 Comment

Easier: <xsl:when test="$vTransfers[ToTime = '08:00']"> - contains() is redundant here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.