Want to seperate table border width using xslt
Input html style::
border: #5f497a 3pt solid;
or
border: 3pt #5f497a solid;
or
border: solid #5f497a 3pt;
Hi all, These all are my possible html input style from whi开发者_运维百科ch i have to fetch only the border width (3) using xslt 1.0. Please help me..Thanks in advance..
Note:I will have always one digit before pt
This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="table">
<xsl:apply-templates select="@style"/>
</xsl:template>
<xsl:template match="@style">
<xsl:if test="string-length() >0">
<xsl:variable name="vValues"
select="substring-after(.,':')"/>
<xsl:variable name="vNormalized" select=
"translate(normalize-space(concat(';',$vValues)),
' ',
';')
"/>
<xsl:variable name="vEndingWidth" select=
"substring-before($vNormalized,'pt;')"/>
<xsl:variable name="vLength"
select="string-length($vEndingWidth)"/>
<xsl:value-of select="substring($vEndingWidth, $vLength)"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
when applied on the following XML document:
<t>
<table style="border: #5f497a 3pt solid;"/>
<table style="border: 3pt #5f497a solid;"/>
<table style="border: solid #5f497a 3pt;"/>
</t>
produces the wanted, correct results:
3
3
3
精彩评论