我有xml文档如下,
<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>
我需要做的是从xslt我需要删除标记内url的子字符串。
示例:
像这样的原始xml文档,
<c type="Hyperlink">http:www.apple.com/accessibility/iphone/hearing.html
</c>
我需要转换如下:
<c type="Hyperlink">www.apple.com </c>
我搜索了XSLT inbuild函数以删除字符串中的某些子字符串,但我找不到这样的函数。
你可以提出我怎么做的建议吗?
答案 0 :(得分:1)
c
元素可以这种方式转换:
<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>
请注意,您的示例不是有效的XML文件,关闭标记时会出现问题。