Reputation: 33572
Using XPath 1.0 in XSLT SharePoint 2013, I have two objectives:
/path/to/library/could/be/any/length/Library Name/file.extension
To extract document id QYZM2HKWQCSZ-3-3 from the following:
http://sharepoint01/sites/temp/_layouts/15/DocIdRedir.aspx?ID=QYZM2HKWQCSZ-3-3, QYZM2HKWQCSZ-3-3
How to extract the desired strings?
OAN, for some reason Document Id column return the full blown path to the resource as opposed to Id only.
Any suggestions, how to get Id only (to avoid substring preprocessing)?
Upvotes: 1
Views: 733
Reputation: 38682
?ID=
is fixed, and also the colon following the ID. If so, you can use substring-after(substring-before(., ','), '?ID=')
. Replace the context .
by some XPath expression selecting the string.Upvotes: 1
Reputation: 163322
For (1), write a recursive template as follows. Pass the input string as a parameter.
(a) if not(contains(substring-after($input, '/'), '/'))
then return substring-before($input, '/')
(b) otherwise, make a recursive call passing (substring-after($input, '/'))
as the parameter.
(c) add some error-handling logic to make sure you terminate if the input string doesn't contain a '/'
.
Upvotes: 2