SPCEX-1.0.0.0 backend-api Deleted old transformation for meta

This commit is contained in:
mfd 2022-12-29 15:17:43 +03:00
parent 10cfe4f895
commit 6294fcd36d

View file

@ -1,197 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output version="1.0" method="text" indent="no" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="meta">
{
"version": "<xsl:value-of select="@version"/>",
<xsl:apply-templates select="*"/>
}
</xsl:template>
<xsl:template match="enums">
"enums": {
<xsl:apply-templates select="*" mode="enums"/>
}
</xsl:template>
<xsl:template match="objects">
,"objects": {
<xsl:apply-templates select="*" mode="objects"/>
}
</xsl:template>
<xsl:template match="views">
,"views": {
<!--xsl:apply-templates select="*" mode="views"/-->
}
</xsl:template>
<xsl:template match="reports"></xsl:template>
<xsl:template match="types">
,"types": [
<xsl:apply-templates select="*" mode="types"/>
]
</xsl:template>
<xsl:template match="*" mode="types">
<xsl:if test="position() > 1">,</xsl:if>
{
"code": "<xsl:value-of select="name(.)"/>",
<xsl:for-each select="@*">
"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>"
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
}
</xsl:template>
<xsl:template match="*" mode="enums">
<xsl:if test="position() > 1">,</xsl:if>
"<xsl:value-of select="name(.)"/>": {
<xsl:for-each select="@*">
"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>",
</xsl:for-each>
"fields": [<xsl:apply-templates select="*" mode="field"/>]
}
</xsl:template>
<xsl:template match="*" mode="objects">
<xsl:if test="position() > 1">,</xsl:if>
"<xsl:value-of select="name(.)"/>": {
<xsl:for-each select="@*">
"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>",
</xsl:for-each>
"fields": [<xsl:apply-templates select="*[name()!='actions']" mode="field"/>]
<xsl:apply-templates select="query|subscription|subscriptionHistory" mode="objects"/>
<xsl:if test="actions">,"actions":[<xsl:apply-templates select="actions" mode="objects"/>]</xsl:if>
}
</xsl:template>
<xsl:template match="query" mode="objects"></xsl:template>
<xsl:template match="subscription" mode="objects"></xsl:template>
<xsl:template match="subscriptionHistory" mode="objects"></xsl:template>
<xsl:template match="views" mode="objects"></xsl:template>
<xsl:template match="actions" mode="objects">
<xsl:for-each select="*">
<xsl:if test="position() > 1">,</xsl:if>
{"method":"<xsl:value-of select="name()"/>",
<xsl:for-each select="@*">
"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>",
</xsl:for-each>
"fields": [<xsl:apply-templates select="*" mode="field"/>]
}
</xsl:for-each>
</xsl:template>
<xsl:template match="*" mode="views">
<xsl:if test="position() > 1">,</xsl:if>
"<xsl:value-of select="name(.)"/>": {
<xsl:for-each select="@*">
"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>",
</xsl:for-each>
<xsl:if test="source">"sources": [<xsl:apply-templates select="source" mode="views"/>]</xsl:if>
<xsl:if test="set">,"fields":[<xsl:apply-templates select="set" mode="views"/>]</xsl:if>
}
</xsl:template>
<xsl:template match="source" mode="views">
<xsl:if test="position() > 1">,</xsl:if>
"<xsl:value-of select="@code"/>"
</xsl:template>
<xsl:template match="set" mode="views">
<xsl:if test="position() > 1">,</xsl:if>
<xsl:choose>
<xsl:when test="count(field)=1">
<xsl:apply-templates select="field"/>
</xsl:when>
<xsl:otherwise>
{<xsl:for-each select="field[position() = 1]">
<xsl:for-each select="@*[name()!='source']">
<xsl:if test="position() > 1">,</xsl:if>
"<xsl:value-of select="name()"/>":
<xsl:variable name="attrName"><xsl:value-of select="name()"/></xsl:variable>
{
<xsl:for-each select="parent::*/parent::*/field/@*[name()=$attrName]">
<xsl:apply-templates select="." mode="withSource"/>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
}
</xsl:for-each>
</xsl:for-each>
}
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*" mode="field">
<xsl:if test="position() > 1">,</xsl:if>
{"code": "<xsl:value-of select="name()"/>",
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="name()='type'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='length'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='searchable'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='sortable'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='visible'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='ignore'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='required'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='cacheable'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:otherwise>"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>"</xsl:otherwise>
</xsl:choose>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
}
</xsl:template>
<xsl:template match="value">
<xsl:if test="position() > 1">,</xsl:if>
{"<xsl:value-of select="name()"/>":
{
<xsl:for-each select="@*">
<xsl:choose>
<xsl:when test="name()='id'">"<xsl:value-of select="name()"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='code'">"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>"</xsl:when>
<xsl:when test="name()='name'">"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>"</xsl:when>
<xsl:otherwise>"<xsl:value-of select="name()"/>": "<xsl:value-of select="."/>"</xsl:otherwise>
</xsl:choose>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
}}
</xsl:template>
<xsl:template match="@*" mode="withSource">
<xsl:choose>
<xsl:when test="name()='type'">"<xsl:value-of select="parent::*/@source"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='length'">"<xsl:value-of select="parent::*/@source"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='searchable'">"<xsl:value-of select="parent::*/@source"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='sortable'">"<xsl:value-of select="parent::*/@source"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='visible'">"<xsl:value-of select="parent::*/@source"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='required'">"<xsl:value-of select="parent::*/@source"/>": <xsl:value-of select="."/></xsl:when>
<xsl:when test="name()='cacheable'">"<xsl:value-of select="parent::*/@source"/>": <xsl:value-of select="."/></xsl:when>
<xsl:otherwise>"<xsl:value-of select="parent::*/@source"/>": "<xsl:value-of select="."/>"</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>