इस कोड को काम करने के लिए मैं क्या कर सकता हूं?एक्सएसएलटी: क्या मैं वैश्विक स्तर पर एक चर घोषित कर सकता हूं और बाद में इसे मान सकता हूं
<xsl:choose>
<xsl:when test='type = 6'>
<xsl:variable name='title' select='root/info/title' />
</xsl:when>
<xsl:when test='type = 7'>
<xsl:variable name='title' select='root/name' />
</xsl:when>
<xsl:otherwise>
<xsl:variable name='title'>unknown</xsl:variable>
</xsl:otherwise>
</xsl:choose>
<div class='title'>
<xsl:value-of select='$title'/>
</div>
इसका कारण यह है काम नहीं करता है जब मैं करना <xsl:value-of select='$title'/>
, $title
दायरे से बाहर है। मैंने दायरे के बाहर <xsl:variable name='title'/>
लाइन जोड़ने की कोशिश की, लेकिन यह या तो काम नहीं करेगा, क्योंकि जब मैं <xsl:variable name='title' select='root/info/title' />
को उदाहरण के लिए कॉल करता हूं, तो मैंने पहले ही इस चर को सेट कर दिया है। मुझे इसे कैसे हल करना चाहिए?
अच्छा सवाल, +1। तीन अलग-अलग समाधानों के लिए मेरा उत्तर देखें। :) –