xml - Normalize slashes in URL -
is there easy way of normalizing slashes of url xslt?
in example i'm converting rss feeds xslt , want build urls tags. can following line:
<skos:concept about="{/rss/channel/link}/tag/{@nicename}">
or
<skos:concept about="{/rss/channel/link}tag/{@nicename}">
sometimes link
has trailing slash , not. there easy function, make sure there slash? e.g.:
<skos:concept about="{normalize-slashs(/rss/channel/link/)}tag/{@nicename}">
assuming link contains no spaces, try =
translate(normalize-space(translate(/rss/channel/link, '/', ' ')), ' ', '/')
edit:
to remove closing slash $string, if exists:
substring($string, 1, string-length($string) - (substring($string, string-length($string))='/'))
in xslt 2.0 can shortened using ends-with() function.
Comments
Post a Comment