我想创建几个xsl:变量,它们可能是null,也可能不是null,然后加入它们:
<xsl:variable name="creatorType" select="replace(lib:merge(subfields/subfield[matches(@code,'[e]')],' '),'author|[.$]','')" />
<xsl:variable name="creatorAttribution" select="replace(lib:merge(subfields/subfield[matches(@code,'[j]')],' '),'[,-.]$','')" />
<xsl:variable name="creatorNameFullForm" select="replace(lib:merge(subfields/subfield[matches(@code,'[q]')],' '),'[,-()]$','')" />
<xsl:variable name="creatorAffiliation" select="replace(lib:merge(subfields/subfield[matches(@code,'[u]')],' '),'[,-.]$','')" />
string-join((xsl:sequence),&#39; delimiter&#39;)看起来很合适,但也加入了空值的变量。
<xsl:variable name="creatorDescriptors" select ="string-join(($creatorDates, $creatorType, $creatorAttribution, $creatorAffiliation),', ')"/>
你怎么会只有字符串连接非空xsl:变量?
我现在得到的东西是这样的:
Mozart, Wolfgang Amadeus (1756–1791, Composer, , )
答案 0 :(得分:5)
尝试使用此表达式(用您自己的变量名替换变量名),以便在序列中仅选择非空节点
<xsl:value-of select="string-join(($a, $b, $c, $d)[. != ''],', ')"/>