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

Re: Re: Complex expression

Subject: Re: Re: Complex expression
From: "Oleg Konovalov" <olegkon@xxxxxxxxx>
Date: Mon, 13 Mar 2006 00:04:30 -0500
xsl if complex
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@xxxxxxxx> wrote:
> cknell@xxxxxxxxxx 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 : tiliphonez moins cher avec Yahoo! Messenger ! Dicouvez les tarifs
exceptionnels pour appeler la France et l'international.
> Tilichargez sur http://fr.messenger.yahoo.com

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.