This is a very copy of my question posted here I only need to notice that this is happening in the XMLTABLE of the teiid engine. I'm parsing the following xml content:
<AttributeSets>
<ns2:ItemAttributes xml:lang="de-DE">
<ns2:Creator Role="Role1">Creator One</ns2:Creator>
<ns2:Creator Role="Role2">Creator Two</ns2:Creator>
<ns2:Creator Role="Role3">Creator Three</ns2:Creator>
</ns2:ItemAttributes>
</AttributeSets>
using
Select * From
XMLTABLE(XMLNAMESPACES( DEFAULT 'http://ns1',
'http://ns2/default.xsd' as ns2 ),
'AttributeSets/ns2:ItemAttributes' PASSING x.AttributeSets
COLUMNS
Creator STRING PATH 'string-join(//ns2:Creator/(@Role, node()) , '', '')'
) p;
Here x.AttributeSets is an xml typed variable with the content from above.
I'm trying to format and combine this into one line using xpath. Something like:
string-join(//ns2:Creator/concat(./text(), @Role), ', ')
I think, i'm somewhere close, because this:
string-join(//ns2:Creator/@Role , ', ')
works and gives me a comma-separated list of roles: Role1, Role2, Role3
and this
string-join(//ns2:Creator/node(), ', ')
combines the values of creators: "Creator One, Creator Two, Creator Three".
I'd like the final output of
Role1: Creator One, Role2: Creator Two, Role3: Creator Three
The most I could get was:
string-join(//ns2:Creator/(@Role, node()) , ', ')
This comma-separates all roles and creators into one line. For some reason the concat operator seems no to work. Could you please help.