Need to take recent style from html tag through xslt -
<td style="vertical-align:top;padding-left:5.4pt; padding-right:5.4pt;border-top-color:#000000;border-top-color:#5f497a;width:159.60000000000002pt;"> <p style="margin-bottom:0pt;"> <span style="font-weight:bold;">one</span> <span style="font-weight:bold;">: 3pt blue</span> </p> </td>
hi all,
this sample portion of input html , using xslt 1.0. here, border-top-color occurs twice.but in xslt, have take recent style(border-top-color:#5f497a;
). how it?.or other solution(pre-processing through java).. please me..thanks in advance..
more semantically correct, stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <xsl:variable name="vreverse"> <xsl:call-template name="reverse"> <xsl:with-param name="pstring" select="concat(';',/td/@style,';')"/> </xsl:call-template> </xsl:variable> <xsl:variable name="vafter"> <xsl:call-template name="reverse"> <xsl:with-param name="pstring" select="substring-before($vreverse,':roloc-pot-redrob;')"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="substring-before($vafter,';')"/> </xsl:template> <xsl:template name="reverse"> <xsl:param name="pstring"/> <xsl:if test="$pstring"> <xsl:call-template name="reverse"> <xsl:with-param name="pstring" select="substring($pstring,2)"/> </xsl:call-template> <xsl:value-of select="substring($pstring,1,1)"/> </xsl:if> </xsl:template> </xsl:stylesheet>
output:
#5f497a
an xpath 2.0 expression:
substring-after( tokenize(/td/@style,';')[ contains(.,'border-top-color') ][last()], ':' )
Comments
Post a Comment