Article
Problem
A reader described the following situation:
"I have a problem with the delimited text driver, when the input has attributes written in all capital letters and I need to convert them to title case. I have managed to change attributes with just one word to "Title Case" using reformat in Transformation policy, but some attibutes have more than one word. For example, Firstnames = "JOHN PETER"
goes to = "John peter" using reformat.
How do I detect the space and change the second, third, etc. words' first
letters to uppercase? Should I write a Input transformation policy using XSL template that converts a string from "ALL CAPITAL LETTERS" to "Title Case"?"
And here's the response from Lothar Haegar ...
Solution
If you can live with a less than 100%-solution, something like this
might work for you:
<do-reformat-op-attr name="UPPERCASE">
<arg-value>
<token-replace-all regex="\ba" replace-with="A">
<token-replace-all regex="\bb" replace-with="B">
<token-replace-all regex="\bc" replace-with="C">
[D,E,F...]
<token-lower-case>
<token-local-variable name="current-value"/>
</token-lower-case>
[another 23x...]
</token-replace-all>
</token-replace-all>
</token-replace-all>
</arg-value>
</do-reformat-op-attr>
Note that "\b" matches word boundaries. Take a look at the following reference; it helped me a lot:
http://www.regular-expressions.info/reference.html.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 2911 reads


0