Replace characters and count

4 views
Skip to first unread message

danieldotnet

unread,
Mar 26, 2020, 4:08:18 PM3/26/20
to orb...@googlegroups.com
Hello Together
In a long text I should replace two characters (comma and spaces) with
nothing and then count the number of characters left after the replacement.
How can I do this in Orbeon Forms?

Thank you for ideas.
Best regards,
Daniel

--
Sent from: http://discuss.orbeon.com/

Alessandro Vernet

unread,
Mar 26, 2020, 5:25:34 PM3/26/20
to orb...@googlegroups.com
Hi Daniel,

Assuming you're using this expression for validation, or something of that
sort that can refer to the current context, the following should do the
trick:

string-length(translate(., ', ', ''))

You'll let me know if this works for you,

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet

danieldotnet

unread,
Mar 27, 2020, 2:37:38 PM3/27/20
to orb...@googlegroups.com
Hi Alessandro
Thank you very much, this works.
I calculate the value (number of characters) divided by 9, I should check
the result for decimal places (result may not have decimal places, must be
INT). Do you have an idea how I can do this check the easiest way?

Best regards and thanks for your help,
Daniel

Alessandro Vernet

unread,
Mar 30, 2020, 2:08:57 PM3/30/20
to orb...@googlegroups.com
Hi Daniel,

You can use: `. castable as xs:integer`.
You'll let me know if this is indeed what you were aiming for.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet

danieldotnet

unread,
Apr 2, 2020, 2:30:26 PM4/2/20
to orb...@googlegroups.com
Hi Alessandro
Thank you, but in my case this not work without Errors.

if (string-length(translate(., ', ', ''))/9 castable as xs:integer) then
true else false

when I open the form I get the error "An error has occurred while processing
the request."

Best regards,
Daniel

Alessandro Vernet

unread,
Apr 3, 2020, 2:22:28 PM4/3/20
to orb...@googlegroups.com
Hi Daniel,

What is the `/9` for in your expression? Is that a typo or where you trying
to do something with the number 9? Also in XPath, it's not `true` and
`false`, but `true()` and `false()`. I.e. those are functions, not keywords,
as is the case in many other languages. Finally, instead of `if (something)
then true() else false()`, you just write `something`.

You'll let me know if with this you manage to do what you were looking for.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet

Alessandro Vernet

unread,
Apr 27, 2020, 1:36:13 PM4/27/20
to orb...@googlegroups.com
Hi Daniel, did you manage to make that expression work? If not, you'll let me
know what you tried and how it fails for you, so we can help.

danieldotnet

unread,
Apr 30, 2020, 1:05:21 PM4/30/20
to orb...@googlegroups.com
Hi Alex,
Sorry for the late reply. I was able to solve the problem differently, so
this case is over. But thanks for the help.
Best regards,
Daniel

Alessandro Vernet

unread,
May 1, 2020, 12:31:52 PM5/1/20
to orb...@googlegroups.com
Got it Daniel, perfect then, as long as you found a way to filter unwanted
characters, and thank you for the update.

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply all
Reply to author
Forward
0 new messages