[xsl] xsl:if/xsl:when test

Subject: [xsl] xsl:if/xsl:when test
From: "Maulik Modi" <mxmodi@xxxxxxxxxxxxxxx>
Date: Wed, 21 Feb 2001 15:51:35 -0600
Hi,

WHAT I WANT:
In the following XML, I have two <Node_path> and <Node_value> pairs in the
first child, I want to test if the values for both the pairs are true and
then process the three <URL>'s for it., meaning 3 times.

WHAT I have working:
In the following XML, I have two <Node_path> and <Node_value> pairs in the
first child, and if both text are valid, it processes each <URL> under it,
meaning six times!

Any help is appreciated. What am I missing?

My XML doc1 (called BER3.xml in the stylesheet) is:

<CHANNEL Name="temp.personresponse">
  <EVENT name="default">
    <NODE>

<Node_path>//DATA/PARAMETERS/PARAMETER/TimeSheet/EmpUserID</Node_path>
      <Node_value>txtester</Node_value>
    </NODE>
    <NODE>

<Node_path>//DATA/PARAMETERS/PARAMETER/TimeSheet/BeginWeek</Node_path>
      <Node_value>11/14/01</Node_value>
    </NODE>
    <URL>http://somurlcall</URL>
    <URL>http://some url call 2</URL>
    <URL>http://some url call 3</URL>
  </EVENT>
  <EVENT name="2">
  ....
  </EVENT>
</CHANNEL>

default XML passed to XSLT (value to be parsed from):

<MESSAGE>
<!--bunch of xml tags here ignored -->

<DATA>
  <PARAMETERS>
    <PARAMETER>
    <TimeSheet>
    <EmpUserID>txtester</EmpUserID>
    <BeginWeek>11/14/01</BeginWeek>
    <EndWeek>11/20/01</EndWeek>
    <Sun>1</Sun>
    <Mon>2</Mon>
    <Tue>3</Tue>
    <Wed>4</Wed>
    <Thu>5</Thu>
    <Fri>6</Fri>
    <Sat>7</Sat>
    <LastDate>01/01/01</LastDate>
    <UpdateUserId>admin</UpdateUserId>
    </TimeSheet>
    </PARAMETER>
  </PARAMETERS>
  </DATA>
</MESSAGE>


Snippet XSL code:

  <xsl:variable name="tempdoc" select="document('BER3.xml')/CHANNEL" />
  <xsl:variable name="chandoc" select="." />

  <xsl:template match="/">
    <!--some other code for presentation deleted here-->

   <xsl:for-each select="$tempdoc//NODE">

         <xsl:variable name="npath" select="Node_path" />
         <xsl:variable name="nvalue" select="Node_value" />

        <xsl:variable name="parsed">
           <xsl:for-each select="$chandoc">
       <xsl:value-of select="saxon:evaluate($npath)" />
          </xsl:for-each>
      </xsl:variable>

         <xsl:if test="$parsed=$nvalue">
         <xsl:for-each select="$tempdoc//URL">
          <url><xsl:value-of select="." /></url>
         </xsl:for-each>
         </xsl:if>

       </xsl:for-each>
</xsl:template>




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread