Author |
Message
|
petervh |
Posted: Tue Sep 04, 2007 1:23 am Post subject: Using fn:substring |
|
|
Apprentice
Joined: 15 Jun 2006 Posts: 31
|
I'm trying to use the fn:substring function in a mapping node expression to truncate the first character from the source field before it gets mapped to the target field.
I coded:
fn:substring($Source/xxx/xxx from 2 for 3)
in the editor but I get an error "Invalid expression syntax: expression sequence". I'm sure this is pretty easy, but I can't seem to get it to work. Can someone help? Thanks. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 04, 2007 1:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
fn:substring does not exist, as far as I know.
You need to use xs:substring, which uses positional parameters, not named parameters...
so xs:substring($Source/xxx/xxx,2,3) _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
petervh |
Posted: Tue Sep 04, 2007 2:00 am Post subject: |
|
|
Apprentice
Joined: 15 Jun 2006 Posts: 31
|
According to my info centre and the "ctrl space" help, the fn:substring does exist (Toolkit V6.0.2). Anybody tried this function? |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 04, 2007 2:48 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I don't mean to seem to be arguing, but I've not found such a link myself in the online Info Center....
Can you cite?
I know for a fact that xs:substring works. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
petervh |
Posted: Tue Sep 04, 2007 4:26 am Post subject: |
|
|
Apprentice
Joined: 15 Jun 2006 Posts: 31
|
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 04, 2007 6:02 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
andypiper |
Posted: Tue Sep 04, 2007 11:27 pm Post subject: |
|
|
 Acolyte
Joined: 29 Oct 2001 Posts: 59 Location: London
|
Oops. This is my bad (in the article). Jeff is quite right, you need to use xs:substring to invoke the XPath substring function, and that takes numeric parameters. It's documented in the XPath language spec:
http://www.w3.org/TR/xpath#function-substring
Sorry for the confusion. |
|
Back to top |
|
 |
petervh |
Posted: Wed Sep 05, 2007 5:49 am Post subject: |
|
|
Apprentice
Joined: 15 Jun 2006 Posts: 31
|
OK. I managed to get this working. Seems that the Toolkit is a little "variable" in this regard... Could have been a memory/project rebuild issue perhaps.
I used: fn:substring($source/xx/xx, 2, 3) and it worked to truncate the source to position 2 for 3 bytes! Thanks for your help. |
|
Back to top |
|
 |
|