XALAN extension function Extension function, e.g. in SAXON

I want to convert XML using XSLT using XALAN. Now I want to use the extension function, this function should be added to the JAVA source, for example, in SAXON:

Method:

TransformerFactory tFactory = TransformerFactory.newInstance(); Configuration c = ((net.sf.saxon.TransformerFactoryImpl) tFactory).getConfiguration(); c.registerExtensionFunction(new FooExtension()); 

FooExtension:

 public class FooExtension extends ExtensionFunctionDefinition { private static final long serialVersionUID = -8143237239412146617L; @Override public SequenceType[] getArgumentTypes() { return new SequenceType[] { SequenceType.EMPTY_SEQUENCE }; } @Override public StructuredQName getFunctionQName() { return new StructuredQName("ns", "http://namespace", "generate-guid"); } } 

But how does this work in XALAN (? FunctionTable?,? FunctionResolver?,? URIResolver?), I have to do this by source, I am not allowed to add a class to XSLT.

Thanks!!

+1
source share
2 answers

When registering a function in your Java code, you still have to declare a namespace in the stylesheet, right? In this case, I do not think that there are many conceptual differences between execution

 xmlns:ns="http://namespace" 

or

 xmlns:ns="xalan://package.classname" 

The implementation simply needs to contain a static function, additional examples can be found at http://xml.apache.org/xalan-j/extensions.html#ex-java-namespace and http://www.ibm.com/developerworks/library/ x-xalanextensions.html

0
source

There is excellent documentation on this subject from the Xalan project: http://xml.apache.org/xalan-j/extensions_xsltc.html

0
source

Source: https://habr.com/ru/post/953805/


All Articles