xsl-list
[Top] [All Lists]

Re: Re: [xsl] Complex expression

2006-03-12 22:05:27
Charles/Florent,

Maybe I should explain what I am trying to do
and show how, so you can comment on whether what I am doing is correct.

I am trying to upload Excel[2000/2003] file, process that info and put
it in database.
One of the very important fields is a Start_Date.
It supposed to be of type "Date" and be in the format mm/dd/yyyy.

If that was not a case (and invalid date format results in making type non-Date,
that seems to be some Microsoft trick in Excel),
up until recently we were just putting a fake date like 01/01/2000,
but that had negative consequences, so now if the type of Start_Date
is not a Date,
we are supposed to instead insert that row into Error table (without
the Start_Date).

So here is my code:
<xsl:template name='buildStatement'>
        <xsl:param name='row'/>
        <xsl:param name='table'/>
        <xsl:param name='notes'/>

        <sql:execute-query>
                <sql:query>
                        <xsl:text>insert into </xsl:text>
                        <xsl:value-of select='$table'/>
                        <xsl:text> (</xsl:text>
                        <xsl:for-each select='$row/sht:Cell'> <!--OK: MBR-233 
don't insert
Start_Date if not Date type - PUT condition here too? -->
                                <xsl:if 
test='not(sht:Name[.="Facility_Start_Date"]/@ValueType="DATE")'>
<!--OK: MBR-233  -->
                                        <xsl:value-of select='sht:Name'/>
                                        <xsl:text>, </xsl:text>
                                </xsl:if>       
                        </xsl:for-each>
                        <xsl:text>association_id, process_ind, 
last_update_user_id</xsl:text>
                        <!--OK: MBR-233 don't insert Start_Date if not Date 
type -->
                        <xsl:if 
test='not($row/sht:Cell/sht:Name[.="Facility_Start_Date"])'>
                                <xsl:text>, facility_start_date</xsl:text>
                        </xsl:if>
                        <xsl:if test='$notes'>
                                <xsl:text>, notes</xsl:text>
                        </xsl:if>
                        <xsl:text>) values (</xsl:text>
                        <xsl:variable name='theRow' select='.'/>
                        <xsl:for-each select='$row/sht:Cell'>
                                <xsl:choose>
                                        <xsl:when test='@ValueType="DATE"'>
                                                <xsl:choose>
                                                        <xsl:when 
test='contains(sht:Content, "9999") and
contains(sht:Name, "Facility_End_Date")'>
                                                                <xsl:text>null, 
</xsl:text>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                                
<xsl:text>to_date(&apos;</xsl:text>
                                                                <xsl:value-of 
select='sht:Content'/>
                                                                
<xsl:text>&apos;, &apos;mm/dd/YYYY&apos;), </xsl:text><!--Mon
dd, YYYY-->
                                                        </xsl:otherwise>
                                                </xsl:choose>
                                        </xsl:when>
<!--xsl:when test='contains(sht:Name, "Start_Date")'--> <!--OK:
MBR-233 Never insert 1/1/2000 or any fake date !
-->                                                                             
                                        <!--xsl:text>'1-jan-2000', </xsl:text-->
                                        <!--/xsl:when-->





On 3/6/06, Florent Georges <darkman_spam(_at_)yahoo(_dot_)fr> wrote:
cknell(_at_)onebox(_dot_)com wrote:

since every other node in the expression appears to be
in a namespace (i.e., sht:), how is that the @ValueType
isn't also in this namespace (e.g., sht:ValueType)?

  It's a common practice to not qualify attributes, letting them in the
null namespace.  Think about your favorite XML languages.

  Regards,

--drkm
























___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs 
exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>