For Your example, using cts
functions, I would use the items related to that: sem:triple-subject()
and sem:triple-object()
Please keep in mind that IRIs and Strings are not the same.. Your data has IRIs and your expected result is string. I present a sample that matches what You state that You want:
xquery version "1.0-ml";
(:
Sample Output based on docs - sem triples
Also, your data suggests that all items are IRIs
:)
let $triples := (
sem:triple(sem:iri("a"), sem:iri("testName"), sem:iri("aa")),
sem:triple(sem:iri("b"), sem:iri("testName"), sem:iri("bb")),
sem:triple(sem:iri("c"), sem:iri("testName"), sem:iri("cc"))
)
return for $triple in $triples
return fn:string-join((xs:string(sem:triple-subject($triple)), xs:string(sem:triple-object($triple))), ",")
In this case, I cast as xs:string() to match your expected output and joined the subject and object by a comma for display purposes.
a,aa
b,bb
c,cc
But what about full IRIs:
sem:triple(sem:iri("c"), sem:iri("testName"), sem:iri("http://www.example.com#cc"))
The result of that result would be:
c, http://www.example.com#cc
I'll not take that further - just wanted to point out that you should be aware of what is actually behind an IRI since your sample was simplified.
Lastly, I would probably write a more specific SPARQL query to return just the subject and object and use xdmp:sparql()
or op:from-sparql()
if I were not in the cts space for my work already.