[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Trouble passing XSL function a parameter

Subject: [xsl] 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

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 My XSL and the test data are below:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="xs uspc"

    <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
        <xsl:analyze-string select="$data" regex="$searchstring" flags="i">
                <xsl:value-of select="regex-group(3)"/>

    <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')"/>


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

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!


Current Thread