I have a working XSLT 2 or 3 process where I pass a single word string as a parameter into the XSL template. For this task I'm passing a surname which is used to find all <person>
elements in multiple XML documents where it's child <nL>
,name last, element matches the parameter I've passed. This works but I'd like to modify my XPATH expression to be able to pass a comma separated parameter. For example, I can now pass surname="Johnson" but would like to be able to pass surname="Johnson,Johnston"
I'm using the latest Saxon processor in java. I invoke the transformation with
java net.sf.saxon.Transform -s:all-sources.xml -xsl:xsl/index-person-param.xsl surname="Johnson"
all-sources.xml is an XML formated list of other XML files.
I will only include a small section of my code unless more is needed. This is likely a simple XPATH issue that I just don't understand.
Currently before my template match I have this parameter declaration
<xsl:param name="surname" as="xs:string" required="yes"/>
then I find all the matching <person>
elements with the following variable
<xsl:variable name="nameMatch" select="document(/files/file/@filename)//person[nL = $surname]"/>
This works when the $surname variable is a one-word string. How could I modify the predicate above so that $surname can contain two or more words separated by a comma?
I've tried several alterations using tokenize()
and contains()
but I've still not found a working solution.
Thanks,
Michael