Your requirements statement is terribly hard to read, but it seems to be saying "Select the <details> with the given <title>. If there is a <categ>, select all <details> elements with the same <categ>. Otherwise, select all <details> elements with the same <list>."
<xsl:variable name="d" select="/root/details[title=$inputTitle]"/>
select="/root/details[($d/categ != '' and $d/categ = categ)
or ($d/categ = '' and $d/list = list]"/>
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference