Subject: Re: Re: [xsl] Complex expression From: "Oleg Konovalov" <olegkon@xxxxxxxxx> Date: Thu, 16 Mar 2006 21:20:22 -0500 |
So I am trying to do an enhancement to Cocoon 2.0/XSLT1.0 application: add a date validation of Excel cells (named Start_Date) in SQLTransformer, so if a Type of that cell is not a DATE, insert that row into Error table (otherwise to the Main table). I tried: <xsl:when test='not(sht:Cell[sht:Name="Start_Date"]/@ValueType = "DATE")' > and: <xsl:when test='not(sht:Cell/sht:Name[.="Start_Date"]/@ValueType = "DATE")'> but neither worked (seem to stop - no exceptions, nothing inserted in DB). Unfortunately I can not get an input XML [Cocoon pipelines sometimes are very difficult to debug, inserting serializer doesn't produce anything] Here is a code snippet. It uploads Excel file, converts it to XML and processes it. <xsl:template match="/"> ...<xsl:apply-templates/> </xsl:template> <xsl:template match='sht:Row'> <!-- do some integrity checks. If they fail, put them into the load_member_reject table --> <xsl:choose> <xsl:when test='not(sht:Cell[sht:Name="Start_Date"]/@ValueType="DATE")'> <xsl:call-template name='buildStatement'> <xsl:with-param name='row' select='.'/> <xsl:with-param name='table'><xsl:text>error_table</xsl:text></xsl:with-param> <xsl:with-param name='notes'> <xsl:text>Start_ Date has a wrong type or date is not formatted properly (record ignored)</xsl:text> </xsl:with-param> </xsl:call-template> </xsl:when> ... other validations otherwise - insert in main_table </xsl:choose> </xsl:template> Any help is very appreciated. Thank you in advance, Oleg. On 3/16/06, Oleg Konovalov <olegkon@xxxxxxxxx> wrote: > Slight Correction: > > So should I use > <xsl:when test='not(sht:Cell[sht:Name="Start_Date"]/@ValueType = "DATE")' > > as opposed to: > <xsl:when test='not(sht:Cell/sht:Name[.="Start_Date"]/@ValueType = "DATE")'> > > Is that correct ? > > > On 3/16/06, Oleg Konovalov <olegkon@xxxxxxxxx> wrote: > > Andrew, > > > > So you are saying that to determine the Type of the Cell [named "Start_Date"], > > I need to use: sht:Cell[sht:Name="Start_Date"]/@ValueType. > > > > I also looked at not() vs. != in "Beginning XSLT" book and > > if I understand correctly, it is better to use not() in my case (for > > comparison true for any node), so it boils down to using: > > <xsl:when test='not(sht:Cell[sht:Name="Start_Date"]/@ValueType = 'DATE')' >... > > > > Do you agree ? > > > > Thank you, > > Oleg. > > > > On 3/16/06, andrew welch <andrew.j.welch@xxxxxxxxx> wrote: > > > On 3/16/06, Oleg Konovalov <olegkon@xxxxxxxxx> wrote: > > > > Are these 2 expressions equal (if not, please explain): > > > > sht:Cell[sht:Name="Start_Date"]/@ValueType and > > > > sht:Cell/sht:Name[.="Start_Date"]/@ValueType > > > > > > no, the former looks for @ValueType on sht:Cell and the latter on sht:Name... > > > > > > Sorry I hit "reply" instead of "reply to all" on the last mail, we > > > really should keep this on list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Re: [xsl] Complex expression, Oleg Konovalov | Thread | Re: [xsl] Complex expression, cknell |
RE: [xsl] preceding-sibling questio, Florent Georges | Date | RE: [xsl] Parameter passing through, cknell |
Month |