Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use custom XSLT functions in conjunction of xs constructor functions ?

User_SAFN8Mar 20 2018

I'm using OSB 12c and JDeveloper 12.2.1.2.0.

How I can use and create XSLT functions with conjunction of xs constructor functions like xs:integer, xs:string or xs:date ? The following XSLT transformation results in my JDeveloper an error:

The first argument to the non-static Java function 'xecho' is not a valid object reference.

Capture.PNG

That prevents deployment from JDeveloper.

e002-transform.xsl:

<?xml version="1.0" encoding="UTF-8"?>

<?altova_samplexml ../test/e002-01.xml?>

<xsl:stylesheet version="2.0"

xmlns:fn="[http://www.w3.org/2005/xpath-functions](http://www.w3.org/2005/xpath-functions)"

xmlns:jh="[http://www.jani-hur.net/xslt-functions](http://www.jani-hur.net/xslt-functions)"

xmlns:xs="[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)"

xmlns:xsl="[http://www.w3.org/1999/XSL/Transform](http://www.w3.org/1999/XSL/Transform)"

exclude-result-prefixes="fn jh xs"

>

\<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

\<xsl:template match="text()"/>

\<xsl:function name="jh:xdouble" as="xs:integer">

    \<xsl:param name="value" as="xs:integer"/>

    \<xsl:sequence select="$value \* 2"/>

\</xsl:function>

\<xsl:function name="jh:xecho" as="xs:string">

    \<xsl:param name="value" as="xs:string"/>

    \<xsl:sequence select="$value"/>

\</xsl:function>

\<xsl:template match="input">

    \<output>

        \<xsl:apply-templates/>

    \</output>

\</xsl:template>

\<xsl:template match="integer">

    \<integerOriginal>

        \<!-- OSB 12c works when the following line is commented. 

        When the line is enabled the following error is reported by JDeveloper:

        The first argument to the non-static Java function 'xecho' is not a valid object reference. -->

        \<xsl:value-of select="xs:integer(.)"/>

    \</integerOriginal>

    \<integerDoubled>

        \<xsl:value-of select="jh:xdouble(.)"/>

    \</integerDoubled>

\</xsl:template>

\<xsl:template match="string">

    \<stringEcho>

        \<xsl:value-of select="jh:xecho(.)"/>

    \</stringEcho>

\</xsl:template>

</xsl:stylesheet>

When the above transformation is run in XMLSpy 2018 the following input file:

<input>

\<integer>1\</integer>

\<integer>13\</integer>

\<integer>42\</integer>

\<string>20-Mar-2018\</string>

\<string>Lorem ipsum\</string>

</input>

Is (correctly) transformed to the following output:

<?xml version="1.0" encoding="UTF-8"?>

<output>

\<integerOriginal>1\</integerOriginal>

\<integerDoubled>2\</integerDoubled>

\<integerOriginal>13\</integerOriginal>

\<integerDoubled>26\</integerDoubled>

\<integerOriginal>42\</integerOriginal>

\<integerDoubled>84\</integerDoubled>

\<stringEcho>20-Mar-2018\</stringEcho>

\<stringEcho>Lorem ipsum\</stringEcho>

</output>

In OSB the transformation is executed in a trivial pipeline assign action:

Capture.PNG

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 17 2018
Added on Mar 20 2018
0 comments
300 views