SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Using InfoPath 2007 Translate function to do what XPath lower-case function does

Several days ago Joe and I found ourselves wanting to make sure we made the InfoPath “UserName()” function return all lower case characters and we decided to use the common XPath function “lower-case” but was surprised because it didn’t work. With a little research I found that we could use the InfoPath “Translate” function instead. I must say that it’s a little frustrating that some common XPath functions don’t work and you have to find the work around but if you do any InfoPath development you come accustom to it. Below is what we tried that didn’t work and what we did that did work.

What didn’t work: lower-case(xdUser:get-UserName())

What did work: translate(xdUser:get-UserName(), “ABCDEFGHIJKLMNOPQRSTUVWYXZ”, “abcdefghijklmnopqrstuvwyxz”)

Basically for “Translate” we had to specify every letter in the alphabet in UPPERCASE and then lowercase to make sure every character will get translated. For more information on “Translate” checkout this link http://office.microsoft.com/en-us/infopath/HA012330391033.aspx and do a search for “Translate” for the official description (It’s towards the bottom of the page).

If you foresee yourself using this more often then something to consider is creating a “Template Part” for this. It would be very simple because it would have two fields one called “translate_uppercase” and another “translate_lowercase” and each field default value would be the alphabet in the correct case. Then whenever you would want to use the “Translate” function you would add the “Translate Lower Case Template Part” to the form and build the expression as translate(fieldname, translate_uppercase, translate_lowercase). This would be a lot simpler than typing in all those letters and if you have more than one person doing InfoPath development it would create a standard way of doing it.

Cheers


Posted 12-19-2007 9:27 AM by mlotter

Comments

Paul Galvin wrote re: Using InfoPath 2007 Translate function to do what XPath lower-case function does
on 12-19-2007 12:19 PM

That's a great tip.  I think I wanted to do something similar earlier this year and abandoned it because I could not get it to work.

Thanks!

Michael Lotter's little view of the big world of SharePoint and InfoPath wrote Using The expression option and XPath statement for comparing two values in InfoPath 2007 Condition statement
on 01-18-2008 10:31 AM

In the post Using InfoPath 2007 Translate function to do what XPath lower-case function does I talked

ML's Chatter wrote Using The expression option and XPath statement for comparing two values in InfoPath 2007 Condition statement
on 12-11-2008 4:43 PM

Using The expression option and XPath statement for comparing two values in InfoPath 2007 Condition statement

George wrote re: Using InfoPath 2007 Translate function to do what XPath lower-case function does
on 12-15-2008 2:21 PM

But what XPath function can be used to do a "replace" of a phrase in the XML data?

For example, I have a blog that is putting "’" (remove quotes) in for apostrophes. I want to find all instances of that string and replace it with a single quote "'" (remove quotes), or with "'".

When I use the translate() function, it matches as your describe above, but doesn't look at the string as a whole phrase, rather each individual character in "’".

Do you know of another function that can achieve what I'm looking for?

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.