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

Trouble passing XSL function a parameter

Subject: Trouble passing XSL function a parameter
From: "C. Edward Porter cep@xxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Nov 2015 15:49:04 -0000
 Trouble passing XSL function a parameter
I am attempting to write a function to parse and return the pseudo-attributes
of a PI. In doing so, I am having trouble passing parameters. I am using
oXygen 17 and SaxonPE 9.6.0.5. My XSL and the test data are below:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:uspc="http://whatever.com"
    exclude-result-prefixes="xs uspc"
    version="2.0">

    <xsl:function name="uspc:parsePI">
        <xsl:param name="data" as="xs:string"/>
        <xsl:param name="att" as="xs:string"/>
        <xsl:variable name="searchstring">(<xsl:value-of
select="$att"/>=)('|")(.*?)(\2)</xsl:variable>
        <xsl:analyze-string select="$data" regex="$searchstring" flags="i">
            <xsl:matching-substring>
                <xsl:value-of select="regex-group(3)"/>
            </xsl:matching-substring>
        </xsl:analyze-string>
    </xsl:function>

    <xsl:template match="processing-instruction('uspc-end-add')">
        Contents: <xsl:value-of select="."/>
        <xsl:variable name="self" select="."/>
        SWS: <xsl:value-of select="uspc:parsePI($self, 'sws')"/>
    </xsl:template>

</xsl:stylesheet>


Test data:
<test>
<?uspc-end-add id="f104450-r0001"  sws="C139995_131101"  symbols="yes"?>
</test>

When I debug, it appears that the second parameter "att" is undefined in the
scope of the function. I'm not clear why this is the case.

I am aware that there is a saxon function that accomplishes this task,
unfortunately, our production environment isn't running Saxon, but is XSL2.0,
so I should be able to use my own function to accomplish this task.

Thanks in advance for any advice!

Regards,
Edward

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.