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

Re: How to make a xsl:function that returns the funct

Subject: Re: How to make a xsl:function that returns the function()
From: Toshihiko Makita <tmakita@xxxxxxxxxxxxx>
Date: Sun, 20 Jan 2013 01:33:46 +0900
 Re: How to make a xsl:function that returns the  funct
This problem has been resolved by changing the code as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ahf="http://www.yahoo.co.jp/tmakita">

<xsl:template match="root">
<xsl:variable name="selectFunc" as="function(*)"
select="ahf:funcGetChildElementByName('d')"/>
<xsl:copy>
<xsl:sequence select="$selectFunc(.)"/>
</xsl:copy>
</xsl:template>

<xsl:function name="ahf:funcGetChildElementByName"
as="function(element()) as element()*">
<xsl:param name="prmElemName" as="xs:string"/>
<xsl:sequence select="let $en := $prmElemName,
$f := function($a as element(),$elemName as xs:string) as element()*
{$a/child::*[starts-with(name(),$elemName)]}
return $f(?,$en)"/>
</xsl:function>

<xsl:variable name="ahf:funcGetChildElementByName"
as="function(element(),xs:string) as element()*">
<xsl:sequence select="function($elem as element(),$elementName) as
element()* {$elem/child::*[starts-with(name(),$elementName)]}"/>
</xsl:variable>

</xsl:stylesheet>

Sorry for bother you.

Toshihiko Makita


(2013/01/20 0:16), Toshihiko Makita wrote:
> Hi List,
>
> I'm very interested in XSLT 3.0 and have a question about the function
> that returns the function as its return value.
> Is it possible to make a such xsl:function?
> I tested using the following code in oXygen 14.1 with Saxon 9.4.0.4.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="3.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:ahf="http://www.yahoo.co.jp/tmakita">
>
> <xsl:template match="root">
> <xsl:variable name="slectFunc" as="function(*)"
> select="ahf:funcGetChildElementByName('d')"/>
> <xsl:copy>
> <xsl:sequence select="$slectFunc(.)"/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:function name="ahf:funcGetChildElementByName" as="function(*)">
> <xsl:param name="prmElemName" as="xs:string"/>
> <xsl:sequence select="function($a as element()) as element()*
> {$a/child::*[starts-with(name(),$prmElemName)]}"/>
> </xsl:function>
>
> </xsl:stylesheet>
>
> However Saxon returns following error.
>
> System ID: D:\My Documents\Proj\XSLT-TEST\20130113-func\test.xsl
> Main validation file: D:\My Documents\Proj\XSLT-TEST\20130113-func\test.xsl
> Engine name: Saxon-EE 9.4.0.4
> Severity: error
> Description: 0
>
> Is there any workarounds?
>
> Regards,
>
> Toshihiko Makita

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.