xslt function to generate number which is based on attributes of aother element -
i trying convert xml quirky formats html.
i have this
<spec_span span_start="c2" span_end="c9" span_name="ab12" /> ... <table_entry span_name="ab12">text value</entry>
i trying convert
<td colspan="8">text value</td>
roughly needs done is.
- look span_spec id ab12
- strip 'c' prefix span_start , span_end
- subtract integer value left in span_start span_end
- add 1 final value.
i think should possible write function of sort it. string manipulation type casting , maths in xslt not sure about.
roughly needs done is.
- look span_spec id ab12
- strip 'c' prefix span_start , span_end
lookup in xslt best done using key. , stripping out known character easy using translate() function.
place @ top of stylesheet, outside of template:
<xsl:key name="spec_span" match="spec_span" use="@span_name" />
then apply input <table_entry>
(?) element:
<xsl:variable name="span" select="key('spec_span', @span_name)" /> <td colspan="{translate($span/@span_end, 'c', '') - translate($span/@span_start, 'c', '') + 1}">text value</td>
Comments
Post a Comment