'XSLT: How to parse out an element into multiple variables
I am trying to parse out full name out of a single field and store them into different variables so I can use them uniquely as FirstName, MiddleName, LastName. I am pulling out the name from a top level of a node:
wd:Payee/@wd:Descriptor
which contains a full name of something like
John F Kennedy
I tried using
tokenize(wd:Payee/@wd:Descriptor, '\s+')
However, I'm getting an extra element, which happens to be the pattern used in the function:
("John","F","Kennedy","\s+")
Any ideas why? Or any other better ideas how to accomplish this?
Solution 1:[1]
It's hard to tell for sure without a minimal reproducible example, but it looks like your @wd:Descriptor can contain multiple space symbols.
Have you tried to normalize spaces like so:
tokenize(normalize-space(wd:Payee/@wd:Descriptor), '\s+')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dharman |