I'm quite new to XSLT and have been struggling with implementing a recursive template, which goes through multiple text nodes and searches for a match. When creating a recursive template i get an error message saying "Required item type of first operand of '/' is node(); supplied value has item type xs:string". I don't know how to select the multiple nodes as nodes, instead of a string.
Objective: I have multiple test nodes like
<Chain>1 3 4 7 20 50 72 ...</Chain>
I want to iterate through these nodes to look for a matching number. When this number is found, i need to select a substring of a parent's element attribute.
Here's part of the stylesheet with the recursive template:
<xsl:template match="/l:LandXML/h:HexagonLandXML/h:Point/h:PointCode">
<xsl:variable name="id2" select="../@uniqueID"/>
<xsl:call-template name="tests">
<xsl:with-param name="input" select="/l:LandXML/h:HexagonLandXML/h:PlanFeature/h:CoordGeom/h:Spline/h:Chain"/>
<xsl:with-param name="id" select="$id2"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="tests">
<xsl:param name="id"/>
<xsl:param name="input"/>
<xsl:choose>
<xsl:when test="substring-before($input, ' ') = $id">
<xsl:value-of select="format-number(substring-before(substring-after($input/../@oID, '_'), '_'), '#')"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="tests">
<xsl:with-param name="input" select="substring-after($input, ' ')"/>
<xsl:with-param name="id" select="$id"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
For a better understaning, a full XML and XSLT is here: https://xsltfiddle.liberty-development.net/94hvTzd/17
Thanks in advance for any help.