[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xsl:if/xsl:when test

Subject: xsl:if/xsl:when test
From: "Maulik Modi" <mxmodi@xxxxxxxxxxxxxxx>
Date: Wed, 21 Feb 2001 15:51:35 -0600
xsl if xsl when
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.