Skip to content

Instantly share code, notes, and snippets.

@LeifW
Created July 17, 2010 21:12
Show Gist options
  • Save LeifW/479861 to your computer and use it in GitHub Desktop.
Save LeifW/479861 to your computer and use it in GitHub Desktop.
import net.sf.saxon.functions.ExtensionFunctionCall
import net.sf.saxon.om.SequenceIterator
import net.sf.saxon.om.SingletonIterator.makeIterator
import net.sf.saxon.om.SingleNodeIterator
import net.sf.saxon.expr.XPathContext
import net.sf.saxon.om.StructuredQName
import net.sf.saxon.value.SequenceType.{SINGLE_STRING, SINGLE_ELEMENT_NODE}
import net.sf.saxon.value.StringValue
class ExtFunCall extends ExtensionFunctionCall {
def call(args:Array[SequenceIterator], context:XPathContext) = makeIterator( new StringValue("hello") )
}
import net.sf.saxon.functions.ExtensionFunctionDefinition
import net.sf.saxon.om.StructuredQName
import net.sf.saxon.value.SequenceType
import SequenceType.{SINGLE_STRING, SINGLE_ELEMENT_NODE}
class ExtFunDef extends ExtensionFunctionDefinition {
val getFunctionQName = new StructuredQName("mp", "http://musicpath.org", "sparql")
val getMinimumNumberOfArguments = 1
//val getMaximumNumberOfArguments = 1
val getArgumentTypes = List(SINGLE_STRING).toArray
def getResultType(suppliedArgumentTypes:Array[SequenceType]) = SINGLE_ELEMENT_NODE
def makeCallExpression = new ExtFunCall
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment