This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]