Monday, 14 July 2014

how to use fn:replace on selected attributes?



I have no experience with xslt but am trying to learn by tweaking some code.


In the XML I have multiple occurrences of distinct id and rid like so:



<fn id="TFN01t1"><label>*</label><p>Some text.</p></fn>
<fn id="TFN02t1"><label>**</label><p>Some text.</p></fn>
...
<p>This is a reference<xref ref-type="table-fn" rid="TFN01t1">*</xref></p>
<p>This is another reference<xref ref-type="table-fn" rid="TFN02t1">*</xref></p>


I need to perform the following regular expression in ID property of fn tags and in RID property of any xref tag and swap the number parts so that TFN02t1 becomes TFN1t02.



"find": TFN([0-9]+)t([1-9]+)
"replace": TFN\2t\1


I found this SO answer about fn:replace but dont know how to use it.


Any ideas?


No comments:

Post a Comment