Reputation: 21
I have xml document as follows,
<footnote>
<p type="Footnote Text">
<link ref="http://www.apple.com/accessibility/iphone/hearing.html">
<c type="Hyperlink">http:.apple.com/accessibility/iphone/hearing.html
</c>
</link>
</s>
</p>
</footnote>
what I need to do is from xslt I need to remove sub-strings of the url within tag.
Example :
original xml document like this,
<c type="Hyperlink">http:www.apple.com/accessibility/iphone/hearing.html
</c>
and I need to convert as follows :
<c type="Hyperlink">www.apple.com </c>
I searched for XSLT inbuild functions for remove certain substrings in a string but I could not find such a function.
can u give any suggestion how I can do it?
Upvotes: 0
Views: 767
Reputation: 9002
The c
element could be converted in this way:
<xsl:template match="c">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:variable name="sa" select="substring-after(.,':')"/>
<xsl:variable name="sb" select="substring-before($sa,'/')"/>
<xsl:value-of select="$sb"/>
</xsl:copy>
</xsl:template>
Please note that your example is not a valid XML file, there are problems with closing tags.
Upvotes: 1