I am trying to create a function that takes one pram and then queries the input XML in several ways based on the input. My problem is that when I try to query the input xml and store a value in a variable while in the function I get the error:
'/' cannot select the root node of the tree containing the context item: the context item is absent
How can I query the XML from within the function? Below is the XSLT
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lang="info:lc/xmlns/codelist-v1"
xmlns:foo="http://whatever">
<xsl:output indent="yes" />
<xsl:function name="foo:get-prefered">
<xsl:param name="field-name"/>
<xsl:variable name="var1" select="sources/source[@type='A']/name" />
</xsl:function>
<xsl:template match="/">
<xsl:value-of select="foo:get-prefered(10)"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>