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

Need better ways to do this..

Subject: Need better ways to do this..
From: "Sudhir Malhotra" <sudhirmalhotra123@xxxxxxxxxxx>
Date: Thu, 31 May 2001 19:03:29 -0500
better ways to do
I am sure there are better ways to accomplish what I am
doing and trying to do. I would be thankful if you could
suggest one. I have explained my approach in the comments in
the XSL segment.

Questions:
1. How to prevent the output being generated for td[4], td[5], td[6] and td[7] if td[1] fails my validation as shown in the XSL segment?
2. How to avoid repitition of the XSL code for processing
td[4], td[5], td[6] and td[7]?


Thank you for your suggestions.

-sm

--Input XML segment--
<tr>
	  <td>19960529-00:00:00.000 CDT</td>
	  <td>115.269997</td>
	  <td>49.669998</td>
	  <td>2.320717</td>
	  <td>2.314239</td>
	  <td>2.295786</td>
	  <td>2.332692</td>
	  <td>0.018453</td>
</tr>
<tr>
	  <td>19960530-00:00:00.000 CDT</td>
	  <td>112.650002</td>
	  <td>49.019900</td>
	  <td>2.298042</td>
	  <td>2.308282</td>
	  <td>2.290944</td>
	  <td>2.325620</td>
	  <td>0.017338</td>
</tr>
------

-- XSL segment --
<!-- Look for the timestamp, and validate it. -->
<xsl:template match="tr/td[1]">
<xsl:variable name="currentDate" select="."/>
<xsl:variable name="isValid" select="datelogicext:checkValidity( $StartDateObject, string( $currentDate ))"/>
<xsl:choose>
<!-- If valid, print the timestamp within XData tag -->
<!-- Then go for other values in tr/td[4], tr/td[5], tr/td[6] and tr/td[7] -->
<!-- The code is working fine when the date is valid -->
<xsl:when test=" $isValid = 'YES' ">
<XData>
<xsl:value-of select="."/>
</XData>
</xsl:when>
<xsl:otherwise>
<!-- A futile attempt to skip to next tr and not process this tr
since td[1] is invalid. -->
<xsl:apply-templates mode="INVALID" select="tr/td"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template mode="INVALID" match="tr/td" >
</xsl:template>

<!-- COPY PROCESSING for positions 4-7 -->
<xsl:template match="tr/td[4 ]">
            <xsl:choose>
                       <xsl:when test=" .  = 'NA'  ">
                        <YData>-9999</YData>
                             </xsl:when>
                             <xsl:otherwise>
                             <YData><xsl:value-of select="."/></YData>
                             </xsl:otherwise>
         </xsl:choose>
</xsl:template>

<xsl:template match="tr/td[5 ]">
            <xsl:choose>
	                         <xsl:when test=" .  = 'NA'  ">
	                          <YData>-9999</YData>
                               </xsl:when>
                                <xsl:otherwise>
                                <YData><xsl:value-of select="."/></YData>
                                </xsl:otherwise>
         </xsl:choose>
</xsl:template>

<xsl:template match="tr/td[6 ]">
            <xsl:choose>
	                         <xsl:when test=" .  = 'NA'  ">
	                          <YData>-9999</YData>
                               </xsl:when>
                                <xsl:otherwise>
                                <YData><xsl:value-of select="."/></YData>
                                </xsl:otherwise>
         </xsl:choose>
</xsl:template>

<xsl:template match="tr/td[7 ]">
            <xsl:choose>
	                         <xsl:when test=" .  = 'NA'  ">
	                          <YData>-9999</YData>
                               </xsl:when>
                                <xsl:otherwise>
                                <YData><xsl:value-of select="."/></YData>
                                </xsl:otherwise>
         </xsl:choose>
</xsl:template>
--------------------
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


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.