You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Dave Brosius <db...@mebigfatguy.com> on 2007/04/09 06:59:45 UTC

Struggling to iterate over tokenized string

I'm trying to loop over tokens in a comma seperated input parameter. 
Something like this

<xsl:transform version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="input"/>
<xsl:template match="/">
    <test>
    <xsl:for-each select="tokenize($input, ',')">
        <xsl:element name="{name(.)}"/>
    </xsl:for-each>
    </test>
</xsl:template>
</xsl:transform>

I'm getting this

ERROR: 'Error checking type of the expression 'funcall(tokenize, 
[funcall(string, [parameter-ref(input/reference)]), literal-expr(,)])'.'

FATAL ERROR: 'Could not compile stylesheet'





Could someone point out what i'm doing wrong, please? 


Re: Struggling to iterate over tokenized string

Posted by Mukul Gandhi <ga...@gmail.com>.
It's wrong to write, xsl:transform version="2.0" when using Xalan's
latest version. As Xalan currently doesn't support XSLT 2.0.
xsl:transform version="1.0" would work as well.

On 4/9/07, Dave Brosius <db...@mebigfatguy.com> wrote:
> Thanks, all, for the input. For the curious, this seems to work as desired
>
> <xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                             xmlns:xalan="http://xml.apache.org/xalan"
>                                                exclude-result-prefixes="xalan">
>
>        <xsl:output method="xml" omit-xml-declaration="yes"/>
>        <xsl:param name="input"/>
>
>        <xsl:template match="/">
>                <xsl:element name="test">
>                        <xsl:for-each select="xalan:tokenize($input, ',')">
>                                <xsl:element name="{string(.)}"/>
>                        </xsl:for-each>
>                </xsl:element>
>        </xsl:template>
> </xsl:transform>


-- 
Regards,
Mukul Gandhi

Re: Struggling to iterate over tokenized string

Posted by Dave Brosius <db...@mebigfatguy.com>.
Thanks, all, for the input. For the curious, this seems to work as desired

<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                             xmlns:xalan="http://xml.apache.org/xalan"
     						exclude-result-prefixes="xalan">

	<xsl:output method="xml" omit-xml-declaration="yes"/>
	<xsl:param name="input"/>

	<xsl:template match="/">
		<xsl:element name="test">
			<xsl:for-each select="xalan:tokenize($input, ',')">
				<xsl:element name="{string(.)}"/>
			</xsl:for-each>
		</xsl:element>
	</xsl:template>
</xsl:transform>






-----Original Message-----
From: david_marston@us.ibm.com
Sent: Mon, April 9, 2007 11:24 am
To: xalan-j-users@xml.apache.org
Subject: Re: Struggling to iterate over tokenized string

Dave Brosius asked about:
    <xsl:for-each select="tokenize($input, ',')">
        <xsl:element name="{name(.)}"/>
    </xsl:for-each>

In addition to needing a namespace qualifier for the tokenize function,
I think you probably meant to extract the value of each node, rather
than the name. If tokenize is returning a node-list, they would likely
be anonymous nodes. How about this?
<xsl:element name="{string(.)}"/>
.................David Marston



Re: Struggling to iterate over tokenized string

Posted by Santiago Pericas-Geertsen <Sa...@Sun.COM>.
Dave,

  It seems that you're not using the correct namespace for the  
tokenize function. This function is a so-called extension function,  
not part of the XSLT 1.0 set. See [1] for further details.

-- Santiago

[1] http://xml.apache.org/xalan-j/extensions_xsltc.html#exslt_ext

On Apr 9, 2007, at 12:59 AM, Dave Brosius wrote:

> I'm trying to loop over tokens in a comma seperated input  
> parameter. Something like this
>
> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ 
> Transform">
> <xsl:output method="xml" omit-xml-declaration="yes"/>
> <xsl:param name="input"/>
> <xsl:template match="/">
>    <test>
>    <xsl:for-each select="tokenize($input, ',')">
>        <xsl:element name="{name(.)}"/>
>    </xsl:for-each>
>    </test>
> </xsl:template>
> </xsl:transform>
>
> I'm getting this
>
> ERROR: 'Error checking type of the expression 'funcall(tokenize,  
> [funcall(string, [parameter-ref(input/reference)]), literal-expr 
> (,)])'.'
>
> FATAL ERROR: 'Could not compile stylesheet'
>
>
>
>
>
> Could someone point out what i'm doing wrong, please?


Re: Struggling to iterate over tokenized string

Posted by da...@us.ibm.com.
Dave Brosius asked about:
    <xsl:for-each select="tokenize($input, ',')">
        <xsl:element name="{name(.)}"/>
    </xsl:for-each>

In addition to needing a namespace qualifier for the tokenize function,
I think you probably meant to extract the value of each node, rather
than the name. If tokenize is returning a node-list, they would likely
be anonymous nodes. How about this?
<xsl:element name="{string(.)}"/>
.................David Marston