Page 1 of 1

custom functions/instructions in xslt content completion

Posted: Sat Mar 28, 2015 7:35 pm
by Patrik
Hi,

I have implemented some custom functions for saxon xslt and will add some custom instructions as well. Is there any way I can add these to the content completion?

I noticed that the custom functions in the saxon namespace are already included while the saxon instructions are not!?

Thanks and regards,
Patrik

Re: custom functions/instructions in xslt content completion

Posted: Mon Mar 30, 2015 5:56 pm
by adrian
Hi,

It is possible, but the mechanism wasn't really designed with customization in mind. This requires patching via the Oxygen/lib/endorsed/builtin folder (as we discussed on another thread for Schematron stylesheets).
The builtin custom functions from the Saxon namespace are found in oxygen.jar/builtin/xsl-annotations/functions/. Extract these files in the appropriate folder, Oxygen/lib/endorsed/builtin/xsl-annotations/functions/ and modify them there (or copy them there afterwards).

Regards,
Adrian

Re: custom functions/instructions in xslt content completion

Posted: Mon Mar 30, 2015 7:10 pm
by Patrik
Hi Adrian,

this seems to work only for functions within the saxon namespace. I added the folowing code for testing:

Code: Select all

<function>
<name>saxon:test-saxon</name>
<namespace>http://saxon.sf.net/</namespace>
<signature>
<return>xs:string*</return>
</signature>
<description xml:space="preserve">Test-Function in saxon namespace 'http://saxon.sf.net/'</description>
</function>
<function>
<name>test:test-test</name>
<namespace>http://www.test.de</namespace>
<signature>
<return>xs:string*</return>
</signature>
<description xml:space="preserve">Test-Function in test namespace 'http://www.test.de'</description>
</function>
Both test-functions are only recognized in the saxon-namespace: When typing "saxon:test-" both entries are suggested. After "test:" there is no suggestion by content completion. So the namespace-element in the file appears to be ignored.

However, custom extension functions for saxon need a different namespace identifying the responsible java class. Thus, I can't register them this way.

Any other idea?

To "register" extension elements I guess I have to overwrite the xml schemas "XSL2.0Schema.xsd", ...?

Thanks and regards,
Patrik

Re: custom functions/instructions in xslt content completion

Posted: Thu Apr 02, 2015 11:40 am
by radu_pisoi
Patrik wrote: Both test-functions are only recognized in the saxon-namespace: When typing "saxon:test-" both entries are suggested. After "test:" there is no suggestion by content completion. So the namespace-element in the file appears to be ignored.
As Adrian already said, there is no special mechanism designed for adding Saxon extension functions or instructions.

We thought that adding new functions to oxygen.jar/builtin/xsl-annotations/functions/saxon-functions.xml will be an workaround for this problem.

I've investigated a bit more this situation and I've discovered that this workaround doesn't work because all of these extension functions are considered to be in a fixed namespace: 'http://saxon.sf.net/'.

I'm afraid that there is no solution/workaround to update the list displayed by the content completion by adding custom Saxon extension functions.
Patrik wrote: Any other idea?

To "register" extension elements I guess I have to overwrite the xml schemas "XSL2.0Schema.xsd", ...?
Yes, this is an workaround. But it will work only when you are editing XSLT 2.0 stylesheets. For XSLT 3.0, you should update the 'xslt3.0.rng' schema.

I will add a feature request on our side to allow an user to customize the list proposed by the content completion assistant with custom Saxon functions or instructions.

Re: custom functions/instructions in xslt content completion

Posted: Thu Apr 02, 2015 12:03 pm
by Patrik
Thanks for you efforts.
Regards,
Patrik

Re: custom functions/instructions in xslt content completion

Posted: Mon Feb 22, 2016 4:40 pm
by cdbruun
Any news on this ?

I would love to have the ability to define what functions are used in when completing XSLT in select="".

I have a lot of Java extension objects that defines many functions used in my stylesheets e.g.:

Code: Select all

<xsl:if test="json:putBool($typeRoot,'singleClickExpand','true')"/>
and

Code: Select all

<xsl:choose>
<xsl:when test="sql:ExecuteQuery()">
<xsl:for-each select="sql:ResultSet()">
And being able to just start writing select="sql:" and then getting a list of declared functions would be very valueable.


I do not want Oxygen XML to try and find the functions directly from java code. I would like to be able to define a list of function names and arguments.

Best regards
Christoffer Bruun

Re: custom functions/instructions in xslt content completion

Posted: Tue Feb 23, 2016 10:21 am
by radu_pisoi
Hi Christoffer,

Unfortunately, this feature was not implemented yet. I will add your vote and increase its priority.

Re: custom functions/instructions in xslt content completion

Posted: Tue Feb 23, 2016 10:40 am
by cdbruun
Thank you!

/Christoffer