Hi I have xslt structure shown below
<xsl:template name="ConvertCriticalFlags">
<xsl:param name="src1"/>
<xsl:param name="src2"/>
<xsl:param name="src3"/>
<xsl:param name="src4"/>
<xsl:param name="src5"/>
<xsl:variable name="rslt" select="''"/>
<xsl:choose>
<xsl:when test="$src1 = 'YES'" >
<xsl:copy-of select="concat($rslt,',', '2TO4UNITS')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="''"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$src2 = 'YES'">
<xsl:copy-of select="concat($rslt,',', 'COMMERCIAL')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="''"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$src3 = 'YES'">
<xsl:copy-of select="concat($rslt,',', 'ACREAGE')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="''"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$src4 = 'YES'">
<xsl:copy-of select="concat($rslt,',', 'MOBILEHOME')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="''"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$src5 = 'YES'">
<xsl:copy-of select="concat($rslt,',', 'VACANTLAND')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="''"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="starts-with($rslt,',') = true">
<xsl:copy-of select="substring($rslt,2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$rslt"/>
</xsl:otherwise>
</xsl:choose>
I would like to concatenate all the data into one variable $rslt
but i am unable to do so Can any one suggest how to concatenate.
<xsl:variable name="rslt" select="string-join((
'2TO4UNITS'[$src1 = 'YES'],
'COMMERCIAL'[$src2 = 'YES'],
'ACREAGE'[$src3 = 'YES'],
'MOBILEHOME'[$src4 = 'YES'],
'VACANTLAND'[$src5 = 'YES']), ',')"/>
<xsl:template name="ConvertCriticalFlags">
<xsl:param name="src1"/>
<xsl:param name="src2"/>
<xsl:param name="src3"/>
<xsl:param name="src4"/>
<xsl:param name="src5"/>
<xsl:variable name="rslt">
<xsl:if test="$src1 = 'YES'">,2TO4UNITS</xsl:if>
<xsl:if test="$src2 = 'YES'">,COMMERCIAL</xsl:if>
<xsl:if test="$src3 = 'YES'">,ACREAGE</xsl:if>
<xsl:if test="$src4 = 'YES'">,MOBILEHOME</xsl:if>
<xsl:if test="$src5 = 'YES'">,VACANTLAND</xsl:if>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($rslt,',')">
<xsl:copy-of select="substring($rslt,2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$rslt"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
To capture a sequence of nodes into a variable in XSLT 2.0, use this form...
<xsl:variable name="rslt">
... sequence constructors go here..
<xsl:variable>
... instead of the form ...
<xsl:variable name="rslt" select="bla bla bla" />
在第一个变量中定义所有选择条件,其中包含所有结果。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.