You can translate the question and the replies:

Compounding a derived view

Hello, I am working on duplicating the behavior of an API, it works pretty good, all the fields are mapped etc. However, the in-place API expose the data after structuring it : { "cat1": { "a":"toto", "b":"titi" }, "cat2" :{ "c":"tata" } } while the denodo webservice I deployed expose it flat: { "a":"toto", "b":"titi", "c":"tata" } For a table that looks like : | a | b | c | | -------- | -------- | -------- | | toto | titi | tata | Do you know of a way to "compound", to structure the output of the webservice ?
user
08-09-2021 05:15:54 -0400

2 Answers

I found my answer, I used XSLT for those who found this subject and have the same question... ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- Affichage sopus forme d'Un JSON catégorisé des données non nulles --> <xsl:output omit-xml-declaration="yes"/> <xsl:variable name="cat1">|a|b|</xsl:variable> <xsl:variable name="cat2">|c|</xsl:variable> <xsl:template match="node()|@*"> [<xsl:for-each select="*">{"cat1":{<xsl:for-each select="*[not(@xsi:nil=true())]"> <xsl:if test="contains($cat1,concat('|',name(.),'|'))"> "<xsl:value-of select ="name(.)"/>":"<xsl:value-of select ="."/>"<xsl:if test='position() != last()'>, </xsl:if> </xsl:if> </xsl:for-each>}, {"cat2":{<xsl:for-each select="*[not(@xsi:nil=true())]"> <xsl:if test="contains($cat2,concat('|',name(.),'|'))"> "<xsl:value-of select ="name(.)"/>":"<xsl:value-of select ="."/>"<xsl:if test='position() != last()'>, </xsl:if> </xsl:if> </xsl:for-each>} }</xsl:for-each>] </xsl:template> <xsl:template match="*[@xsi:nil=true()]"/> </xsl:stylesheet> ```
user
13-09-2021 10:14:45 -0400
Hi, Yes, I would use XSLT to compound a derived view when using an API because XSLT allows for the transformation of incoming requests. I can use it to create different structures than what might be provided from an API which can provide me with the desired format. For an overview of XSLT transformations, please check out the [XSLT Transformations](https://community.denodo.com/docs/html/browse/latest/en/vdp/administration/publication_of_web_services/xslt_transformations/xslt_transformations) section of the Virtual DataPort Administration Guide. Hope this helps!
Denodo Team
14-09-2021 12:48:18 -0400
You must sign in to add an answer. If you do not have an account, you can register here