RE: [xsl] dd mmm yyyy Date converted to number - attempt to sort using variable - unable to do so

Subject: RE: [xsl] dd mmm yyyy Date converted to number - attempt to sort using variable - unable to do so
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Mon, 29 Oct 2001 09:03:01 -0000
I would have expected to see the error message say that <xsl:sort> must be
the first child of <xsl:for-each>. Instead, Xalan seems to be trying to
evaluate the <xsl:sort> as if it were the first child, so the error message
says that the variable has not been declared. I'm afraid you'll have to
avoid using the variables, and compute the sort key directly in a single
complex expression.

Mike Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
> mark.clare@xxxxxxxxxxxx
> Sent: 28 October 2001 11:34
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] dd mmm yyyy Date converted to number - attempt to sort
> using variable - unable to do so
>
>
> I have a list of items which contain a date in the format dd
> mmm yyyy.  I
> want to sort these entries by date.  To do so I have used the
> following
> code:
>
> <xsl:variable name="FORMATTER"
> select="java:java.text.SimpleDateFormat.new(&quot;dd MMM
> yyyy&quot;)"/>
>   <xsl:variable name="NUMBER_FORMATTER"
> select="java:java.text.DecimalFormat.new(&quot;00000000000000&
> quot;)"/>
>
> .......................
> .......................
>
>  <xsl:for-each select="CashSettlementFlow">
>                                   <xsl:variable
> name="SETTLEMENT_DATE" select="string(dateAdjusted)"/>
>                                   <xsl:variable
> name="SETTLEMENT_JAVA_DATE"
> select="java:parse($FORMATTER,$SETTLEMENT_DATE)"/>
>                                   <xsl:variable
> name="SETTLEMENT_JAVA_TIME"
> select="java:getTime($SETTLEMENT_JAVA_DATE)"/>
>                                   <xsl:variable
> name="SETTLEMENT_PADDED_NUMBER"
> select="java:format($NUMBER_FORMATTER,$SETTLEMENT_JAVA_TIME)"/>
>                                   <!-- <xsl:sort
> select="*[name()=$SETTLEMENT_PADDED_NUMBER]"/> -->
>                                   <xsl:sort
> select="$SETTLEMENT_PADDED_NUMBER"/>
>
> As can be seen I first convert the date into a number and it
> is this number which I want to sort on (this is within a
> transform which creates HTML
> output for display).
>
> This produces the error:
>
> XSL Error: pattern = '$SETTLEMENT_PADDED_NUMBER'
> VariableReference given for variable out of context or
> without definition!  Name = SETTLEMENT_PADDED_NUMBER, source
> tree node: CashSettlementFlow
> XSL Error: SAX Exception
> Exception in thread "main"
> org.apache.xalan.xslt.XSLProcessorException: pattern =
> '$SETTLEMENT_PADDED_NUMBER'
> VariableReference given for variable out of context or
> without definition!  Name = SETTLEMENT_PADDED_NUMBER
>
> Can anyone advise how I can utilise the variable in the sort function?
>
>
>
>
> This e-mail message is CONFIDENTIAL and may contain legally privileged
> information.  If you are not the intended recipient you
> should not  read,
> copy, distribute, disclose or otherwise use the information
> in this e-mail.
> Please also telephone or fax us immediately and delete the
> message from
> your system.  E-mail may be susceptible to data corruption,
> interception
> and unauthorised amendment, and we do not accept liability
> for any such
> corruption, interception or amendment or the consequences thereof.
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread