Page 1 of 1

XSLT validation scenario with Saxon initializer class

Posted: Thu Mar 09, 2017 11:26 am
by Patrik
Hi,

I have configured a transformations scenario using a Saoxn initializer class to register a custom extension function. When validating the root file being used by this transformaton scenario the validation works fine.

I also created a validation scenario for xslt files included by this root file and set the file to be validated accordingly. Now when validating using this validations cenario I get an error that my custom function is unknown. But in the validtion scenario I foundno place to configure my Saxon initializer!?

Thanks and regards,
Patrik

Re: XSLT validation scenario with Saxon initializer class

Posted: Thu Mar 09, 2017 5:29 pm
by alex_jitianu
Hi Patrik,

Currently you can't set Saxon options in a validation scenario. In the version 19 (to be released in mid April) though, things will be better: we will detect the transformation scenario associated with the master and we will use it when validation. All you will have to do in the validation unit is to have to use <Default engine> as the engine used to validate the master.

Unfortunately, right now I don't see an easy solution for your use case because the Initializer class can only be set in the scenario options.

Best regards,
Alex

Re: XSLT validation scenario with Saxon initializer class

Posted: Fri Mar 10, 2017 12:45 pm
by Patrik
Hi Alex,

thanks for the information.

Im just wondering if it wouldn't be easier to implement (and teasier to understand for a user) if you would allow to set Saxon configurations in a validation scenario as well. Especially since there are use-cases when you don't have a transformation scenario at all. For instance I have some XSLT code that is only being executed from my custom Java code (be it as oXygen or DITA-OT plugin). Of course I could still just create a dummy transformation scenario that will never be executed and is just to handle the validation correctly - it just doesn't feel straight forward.

Regards,
Patrik

Re: XSLT validation scenario with Saxon initializer class

Posted: Fri Mar 10, 2017 4:13 pm
by alex_jitianu
Hi Patrik,

I agree. Having a Saxon configuration inside the validation scenario itself is the proper way to handle such situations. I've also added an issue for this feature but it's not going to make it in version 19 (development is currently frozen).

Best regards,
Alex

Re: XSLT validation scenario with Saxon initializer class

Posted: Wed Jan 24, 2018 12:12 pm
by Patrik
Just in case anybody else has this problem:

I found a nice way to handle custom extension functions: Just declare them in your xslt like this:

Code: Select all

<xsl:function name="my:myCustomFunction" as="xs:string" use-when="not(function-available('my:myCustomFunction'))">
<xsl:param name="1stParameter" as="xs:string"/>
<xsl:param name="anotherParameter" as="xs:boolean"/>
<xsl:message terminate="yes">ERROR: Custom extension function 'my:myCustomFunction' not registered.</xsl:message>
</xsl:function>
This has the great additional advantage that these functions will be supported by content completion...

Regards,
Patrik