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

Inserting global parameter value into xsl:function

Subject: Inserting global parameter value into xsl:function
From: Clay Redding <credding@xxxxxxxxxxxxx>
Date: Wed, 18 Jun 2003 13:20:46 -0400
xsl parameter value
Hi list, I am somewhat of an XSL 2.0 newbie, and I have a fairly simple question that doesn't necessarily have anything to do with 2.0, but involves the xsl:function element.

In my XSL I have defined a function that will take a required, top-level parameter (called 'position'), and then feeds this position into a variable (called 'forward') that calls the function ('forwardURL') with the 'postion' parameter as the value that references the value I need. The function is used to return a URL value from the XML doc. That URL should be available for referencing later in the HTML output through the 'forward' global attribute.

Whenever I try to invoke the code below, it chokes on data typing issues, saying that it cannot add xs:string to xs:integer. What it is trying to do is take the ($position) reference in the "forward" variable and add it within the function to 1. But it's treating $position as a string, not as an integer passed on as a value. How can I reference $position (or any other variable/parameter) within a select/XPath-esque attribute so that it doesn't treat $position as a literal string? Do I use curly braces, brackets, or what?

I'm using Saxon 7.5.1 as servlet, with JDK 1.4.1.

Thanks for any help you can give.
Clay

<xsl:stylesheet version="2.0" xmlns:njp="http://...,etc." xmlns:xs="http://...,etc." xmlns:mets="http://..., etc.">
<!-- shortened for brevity -->


<xsl:param name="position" required="yes" as="xs:integer"/>
<xsl:variable name="forward" as="xs:string" select="njp:forwardURL($position)"/>


<xsl:variable name="array">
<xsl:for-each select="mets:mets/mets:fileSec/mets:fileGrp/mets:file/mets:FLocat">
<id><xsl:value-of select="@ID"/></id>
<url><xsl:value-of select="@xlink:href"/></url>
<position><xsl:value-of select="position() - 1"/></position>
</xsl:for-each>
<xsl:for-each select="$dmdSec">
<dmd><xsl:value-of select="."/></dmd>
</xsl:for-each>
</xsl:variable>


<xsl:function name="njp:forwardURL">
<xsl:param name="placeholder"/>
<xsl:sequence select="$array/url[$placeholder + 1]"/>
</xsl:function>
...

<!-- the following appears within an xsl:template -->
<img id="mypic" class="border" alt="Page" src="{$forward}"/>


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.