I have some XSLT code that looks like this:
<xsl:variable name="writerFind" as="xs:string*">
<xsl:sequence select="('screenplay by ','written by ','written and directed by ')"/>
</xsl:variable>`
<xsl:for-each select="1 to count($writerFind)">
<xsl:variable name="x">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:variable name="writer"
select="functx:contains-any-of($cell3Data, subsequence($writerFind, $x, 1))"/>
<xsl:variable name="writerEnd" as="xs:string*">
<xsl:sequence select="(' ;','.')"/>
</xsl:variable>
This function checks $cell3Data (which is just a normalize-space()'d version of a node for the presence of those $writerFind trigger words (there can be more added later) and then returns the piece of the node's value after the trigger.
<xsl:function name="fun:contains-any-of" as="xs:string" xmlns:fun="http://www.fun.com">
<xsl:param name="arg" as="xs:string?"/>
<xsl:param name="searchString" as="xs:string"/>
<xsl:sequence
select="if (contains($arg,$searchString))
then substring-after($arg, $searchString)
else ''"
/>
</xsl:function>
What I'm trying to do, and keep stumbling over is to create a second function that returns the value of the new $writer BEFORE it encounters one of the $writerEnd triggers.
i.e. when the node says "Movie was written by John Smith ; directed by Edward Jones" the return value is "John Smith"
when the node says Movie screenplay by Bob Links." the return value is "Bob Links"
the first function works fine, the second one is giving me all kinds of trouble. Thoughts?