Edit online

Saxon, the transformation and validation engine used by Oxygen XML Editor, can be customized by adding custom functions (called Integrated Extension Functions) that can be called from XPath.

To define such a function, follow these steps:
  1. Create a file with a Java class that extends net.sf.saxon.lib.ExtensionFunctionDefinition. Here is an example:
    private static class ShiftLeft extends ExtensionFunctionDefinition {
      @Override
      public StructuredQName getFunctionQName() {
        return new StructuredQName("eg", "http://example.com/saxon-extension", "shift-left");
      }
    
    
      @Override
      public SequenceType[] getArgumentTypes() {
      	return new SequenceType[] {SequenceType.SINGLE_INTEGER, SequenceType.SINGLE_INTEGER};
      }
    
    
      @Override
      public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
      	return SequenceType.SINGLE_INTEGER;
      }
    
    
      @Override
      public ExtensionFunctionCall makeCallExpression() {
      	return new ExtensionFunctionCall() {
    	  public SequenceIterator call(SequenceIterator[] arguments, XPathContext context)
                        throws XPathException {
      	    long v0 = ((IntegerValue)arguments[0].next()).longValue();
      		long v1 = ((IntegerValue)arguments[1].next()).longValue();
      		long result = v0<<v1;
            return Value.asIterator(Int64Value.makeIntegerValue(result));
          }
        };
      }
    }
  2. Compile the class and add it to a JAR file.
  3. Add a file called net.sf.saxon.lib.ExtensionFunctionDefinition that contains the fully qualified name of the Java class in the META-INF/services/ folder of the JAR file.
    Note: To add more function definitions in the same JAR file, you need to add their fully qualified names on different lines.
To enable Oxygen XML Editor to pick up your custom function definition, the JAR file should be added to the classpath of the transformer. Here are some possibilities: