XSLT Validate and Concatenate Multiple Variables -
i have validate , concatenate multiple variable after validating them.
<xsl:variable name="val1" select="//xpath"/> <xsl:variable name="val2" select="//xpath"/> <xsl:variable name="val3" select="//xpath"/> <xsl:variable name="val4" select="//xpath"/> <xsl:variable name="val5" select="//xpath"/>
is there template available or can me doing this.
update comments
i want concatenate 5 values this: address, address1, city, state, zipcode
. if address
missing i'll output ", address1, city, state, zipcode
". want rid of first comma.
<xsl:variable name="__add" select="translate(//*/text()[contains(., 'address')]/following::td[contains(@class, 'fnt')][1], ',', '')"/> <xsl:variable name="address"> <xsl:for-each select="$__add | //*/text()[contains(., 'city')]/following::td[contains(@class, 'fnt')][1] | //*/text()[contains(., 'state')]/following::td[contains(@class, 'fnt')][1] | //*/text()[contains(., 'pincode')]/following::td[contains(@class, 'fnt')][1]"> <xsl:value-of select="concat(substring(', ', 1 div (position()!=1)), .)"/> </xsl:for-each> </xsl:variable>
in xslt 2.0: string-join((address, address1, city, state, zipcode), ',')
in xslt 1.0, provided you're outputting results in document order:
<xsl:for-each select="address | address1 | city | state | zipcode"> <xsl:if test="position() != 1">, </xsl:if> <xsl:value-of select="."/> </xsl:for-each>
if not in document order, many things in xslt 1.0, it's rather tedious.
Comments
Post a Comment