[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: Thu, 16 Mar 2006 09:43:16 -0500
excel expressions
Andrew,

I was really hoping for an easy fix (10 lines or so total).

I actually do process all good-date and bad-date rows in the template
which calls the template which I posted before.
So the difference in the call to the buildstatement template is just a
table name.
Since that column is nullable, we decided to insert NULL
instead of skipping column in insert.

The real question I have is what is a correct syntax for the expression
" if type of Excel cell called Start_Date
<xsl:when test='sht:Cell[sht:Name="Start_Date"]/@ValueType != "DATE"'>
or maybe
<xsl:when test='not(sht:Cell/sht:Name[.="Start_Date"]/@ValueType = "DATE")'>

For some strange reason that doesn't seem to work for me,
although similar expressions (without '/@ValueType = "DATE" ' are used
around)
seem to work there.

Please advise. Sorry for the newbie question.

Thank you in advance,
Oleg.

On 3/13/06, andrew welch <andrew.j.welch@xxxxxxxxx> wrote:
> On 3/13/06, Oleg Konovalov <olegkon@xxxxxxxxx> wrote:
> > 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? -->
>
> Hi,
>
> This is quite a common problem, you need to invert your processing
> here and move all of the conditions to the outside.
>
> eg, first process all rows with bad start dates, then process all the
> good rows::
>
> <xsl:for-each select="// all rows with bad start dates">
>     ...do something...
> </xsl:for-each>
>
> <xsl:for-each select="// all rows with good start dates">
>   ...do something...
> </xsl:for-each>
>
> Where you have code duplication separate it out into named templates.
>
> It seems backwards at first because you're thinking procedurally, but
> when you understand at what point things get added to the result tree
> you realise where the conditionals need to be.
>
> In this the case, a different $table is needed so the conditional must
> be at the point that is decided...
>
> cheers
> andrew

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.