Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why fn:substring-after Xquery function could not be used inside ML TDE

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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:'), ';')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading