1

In my ML db, we have documents with distributor code like 'DIST:5012' (DIST:XXXX) XXXX is a four-digit number.

currently, in my TDE, the below code works well.

enter image description here

However instead of concat all the raw distributor codes, I want to simply concat the number part only. I used the fn:substring-after XQuery function. However, it won't work. It won't show that distributorCode column in the SQL View anymore. (Below code does not work.)

![enter image description here

What is wrong? How to fix that?

Both fn:substring-after and fn:string-join is in TDE Dialect page. https://docs.marklogic.com/9.0/guide/app-dev/TDE#id_99178

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147

1 Answers1

1

substring-after() expects a single string as input, not a sequence of strings.

To demonstrate, this will not work:

let $dist := ("DIST:5012", "DIST:5013")
return substring-after($dist, "DIST:")

This will:

for $dist in ("DIST:5012", "DIST:5013")
return substring-after($dist, "DIST:")

I need to double check what XPath expressions will work in a DTE, you might be able to change it to apply the substring-after() function in the last step:

fn:string-join( distributors/distributor/urn/substring-after(., 'DIST:'), ';')
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147