In XSLT 1.0, you can use a technique called Oliver Becker's method, which means writing the use
in this form
concat(
substring(Str1,1 div Cond),
substring(Str2,1 div not(Cond))
)
So, in your case, you could write your xsl:key
like this:
<xsl:key name="item2" match="SHOPITEM" use="concat(
substring(substring-before(PRODUCT, ' SIZE.'), 1 div (contains(PRODUCT, ' SIZE.'))),
substring(PRODUCT, 1 div (not(contains(PRODUCT, ' SIZE.'))))
)" />
Whether you consider this readable is another matter.
However, in this particular case, for the logic you are trying to implement, you could also write the key like this:
<xsl:key name="item" match="SHOPITEM" use="substring-before(concat(PRODUCT, ' SIZE.'), ' SIZE.')" />
So, if the PRODUCT
contains SIZE.
it will find the text before the first occurrence. If not, it will the concatenated SIZE.
which effectively get the whole string
See examples in action at http://xsltfiddle.liberty-development.net/jyRYYij