custom functions/instructions in xslt content completion

Post here questions and problems related to oXygen frameworks/document types.
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

custom functions/instructions in xslt content completion

Post 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
adrian
Posts: 2881
Joined: Tue May 17, 2005 4:01 pm

Re: custom functions/instructions in xslt content completion

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: custom functions/instructions in xslt content completion

Post 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
radu_pisoi
Posts: 404
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: custom functions/instructions in xslt content completion

Post 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.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: custom functions/instructions in xslt content completion

Post by Patrik »

Thanks for you efforts.
Regards,
Patrik
cdbruun
Posts: 2
Joined: Tue Aug 25, 2009 4:06 pm

Re: custom functions/instructions in xslt content completion

Post 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
radu_pisoi
Posts: 404
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: custom functions/instructions in xslt content completion

Post by radu_pisoi »

Hi Christoffer,

Unfortunately, this feature was not implemented yet. I will add your vote and increase its priority.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
cdbruun
Posts: 2
Joined: Tue Aug 25, 2009 4:06 pm

Re: custom functions/instructions in xslt content completion

Post by cdbruun »

Thank you!

/Christoffer
Post Reply