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

Re: current()

Subject: Re: current()
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 4 Jan 2001 14:09:33 -0800 (PST)
xslt month names
Hi Matthew,

> but Xalan 1.2.2 (newest) tells me
> "The current() function is not allowed in a match pattern!".
> I assume this is simply a bug in Xalan as versions prior to 1.2.1
> sort correctly, any ideas? Any work-around suggestions?

This must be a bug -- the value of the @select attribute of xsl:sort is
an expression -- not pattern.

I had to reconstruct the full stylesheet in order to test it. The test
with MSXML3 (standard and July beta) returns the following result:

<date>December</date>
<date>July</date>
<date>June</date>
<date>April</date>
<date>March</date>


The test with Saxon 5.4 returns a diferent result and it seems to me
that this could be caused by a bug in Saxon 5.4:

G:\xml\msxml\XML SDK\Samples\Tests>java  com.icl.saxon.StyleSheet   
testSort.xm
l testSort.xsl
Cannot find ParserManager.properties - using built-in parser
Cannot find ParserManager.properties - using built-in parser
Cannot find ParserManager.properties - using built-in parser
<date>December</date>
<date>March</date>
<date>July</date>
<date>June</date>
<date>April</date>


I hope that Mike Kay could help us in interpreting the different
behaviour of these two XSLT processors.

Here's the stylesheet I used with your xml source:

<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:m="mmm"
>
<xsl:output omit-xml-declaration="yes"/>
<xsl:key name="myKey" match="person/date" use="concat(../account, '::',
.)"/>

	<m:month name="Jan" value="0"/>
	<m:month name="Feb" value="1"/>
	<m:month name="Mar" value="2"/>
	<m:month name="Apr" value="3"/>
	<m:month name="May" value="4"/>
	<m:month name="Jun" value="5"/>
	<m:month name="Jul" value="6"/>
	<m:month name="Aug" value="7"/>
	<m:month name="Sep" value="8"/>
	<m:month name="Oct" value="9"/>
	<m:month name="Nov" value="10"/>
	<m:month name="Dec" value="11"/>
	
	
	<xsl:template match="/">
		<xsl:variable name="months" select="document('')//m:month"/>
	
	<xsl:for-each 
		select="/person/date[generate-id(.)=generate-id(key('myKey', concat(
../account, '::', .))[1])]">
	
		<xsl:sort select="$months[ starts-with( current(),  @name ) ]/@value"
data-type="number" order="descending"/>
	<xsl:copy-of select="."/>
	<xsl:text>&#xA;</xsl:text>
	</xsl:for-each>		
	</xsl:template>
</xsl:stylesheet>


Cheers,
Dimitre Novatchev.


Matthew Cordes wrote:
Hello all, 

Is the current() function allowed in this syntax?


XML:

	<person>
		<account>12345</account>
		<date>December</date>
		<date>March</date>
		<date>March</date>
		<date>July</date>
		<date>March</date>
		<date>June</date>
		<date>April</date>
	</person>


XSL:


<m:month name="Jan" value="0"/>
<m:month name="Feb" value="1"/>
<m:month name="Mar" value="2"/>
<m:month name="Apr" value="3"/>
<m:month name="May" value="4"/>
<m:month name="Jun" value="5"/>
<m:month name="Jul" value="6"/>
<m:month name="Aug" value="7"/>
<m:month name="Sep" value="8"/>
<m:month name="Oct" value="9"/>
<m:month name="Nov" value="10"/>
<m:month name="Dec" value="11"/>


<xsl:variable name="months" select="document('')//m:month"/>

<xsl:for-each 
	select="person/date[generate-id(.)=generate-id(key('myKey', concat(
account, '::', .))[1])]">

	<xsl:sort select="$months[ starts-with( current(),  @name ) ]/@value"
		data-type="number" order="descending"/>

</xsl:for-each>		


As you can see, I'm trying to sort Month names in correct 
(sequential) order, but Xalan 1.2.2 (newest) tells me
"The current() function is not allowed in a match pattern!".
I assume this is simply a bug in Xalan as versions prior to 1.2.1
sort correctly, any ideas? Any work-around suggestions?

-matt




__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/

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


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.