You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
348 lines
15 KiB
348 lines
15 KiB
<?xml version="1.0" encoding="UTF-8"?> |
|
<!--In diesem Script wird die edustore.xml für Modrian Version 4 erzeugt--> |
|
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
|
<xsl:output method="xml" encoding="UTF-8" indent="yes"/> |
|
|
|
<xsl:template match="/"> |
|
<xsl:text>
</xsl:text> |
|
<xsl:comment>Automatisch generiert von Edustore durch tabelle_xml_mondrian4.xsl </xsl:comment> |
|
<xsl:text>
</xsl:text> |
|
<Schema name="HISinOne" metamodelVersion="4.0"> |
|
<xsl:text>
</xsl:text> |
|
|
|
<PhysicalSchema> |
|
<!--erst Dimensionstabellen:--> |
|
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement/sqlerg/row[col[f_name='is_fact_table_aggr_field']/wert='0' and col[f_name='foreignkey_tab']/wert !='']"> |
|
<xsl:variable name="foreignkey_tab"><xsl:value-of select="col[f_name='foreignkey_tab']/wert"/></xsl:variable> |
|
<xsl:call-template name="getPhysicalSchema"> |
|
</xsl:call-template> |
|
</xsl:for-each> |
|
<!--dann Faktentabelle:--> |
|
<xsl:for-each select="distinct-values(/ergebnisse/ergebnis/ergebniselement/sqlerg/row[col[f_name='fact_table_name']/wert!='']/col[f_name='fact_table_name' and wert !='']/wert)"> |
|
<Table name="{.}" alias= "{.}"/> |
|
</xsl:for-each> |
|
|
|
</PhysicalSchema> |
|
|
|
<!--Dimensionen--> |
|
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement/sqlerg/row[col[f_name='is_fact_table_aggr_field' and wert='0']]"> |
|
|
|
<xsl:variable name="hasAll"> |
|
<xsl:choose> |
|
<xsl:when test="col[f_name='is_summable']/wert = '0'">false</xsl:when> |
|
<xsl:otherwise>true</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:variable> |
|
<xsl:variable name="dimensionName"><xsl:value-of select="concat('dim_',col[f_name='fact_table_field_name']/wert)" /></xsl:variable> |
|
<xsl:variable name="dimensionCaption"><xsl:value-of select="col[f_name='fact_table_field_caption']/wert" /></xsl:variable> |
|
|
|
<xsl:variable name="tableName"><xsl:value-of select="col[f_name='fact_table_name']/wert" /></xsl:variable> |
|
|
|
<Dimension caption="{$dimensionCaption}" name="{$dimensionName}" > |
|
<xsl:choose> |
|
<xsl:when test="col[f_name='foreignkey_tab']/wert !=''"> |
|
<!-- mit Dim-Tabelle--> |
|
<xsl:attribute name="table"> |
|
<xsl:choose> |
|
<xsl:when test="col[f_name='foreignkey_cond']/wert!=''"> |
|
<xsl:value-of select="concat('view_',col[f_name='fact_table_field_name']/wert)" /> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="col[f_name='foreignkey_tab']/wert" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:attribute> |
|
<xsl:attribute name="key"><xsl:value-of select="concat('attr_',col[f_name='fact_table_field_name']/wert)" /></xsl:attribute> |
|
<Attributes> |
|
<Attribute caption="{col[f_name='fact_table_field_caption']/wert}" name="{concat('attr_',col[f_name='fact_table_field_name']/wert)}" |
|
keyColumn="{col[f_name='foreignkey_pk_col']/wert}" |
|
nameColumn="{col[f_name='foreignkey_name_col']/wert}" |
|
hasHierarchy="false" |
|
orderByColumn="{col[f_name='foreignkey_ordinal_col']/wert}"/> |
|
|
|
</Attributes> |
|
|
|
</xsl:when> |
|
<xsl:otherwise> |
|
<!--degenerateDimension--> |
|
<Hierarchy hasAll="true"> |
|
<!-- No table element here. Fact table is assumed. --> |
|
<Level caption="{col[f_name='fact_table_field_caption']/wert}" |
|
name="{concat('level_',col[f_name='fact_table_field_name']/wert)}" |
|
column="{col[f_name='fact_table_field_name']/wert}" uniqueMembers="true"/> |
|
</Hierarchy> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</Dimension> |
|
<!-- |
|
<Attributes> |
|
<xsl:choose> |
|
<xsl:when test="$srctable != ''"> |
|
<xsl:call-template name="getAttributes"> |
|
<xsl:with-param name="srctable" select="$srctable" /> |
|
<xsl:with-param name="name_trans" select="$name_trans" /> |
|
<xsl:with-param name="srctable_pk" select="@srctable_pk" /> |
|
<xsl:with-param name="srctable_type" select="@srctable_type" /> |
|
<xsl:with-param name="srctable_namecolumn" select="@srctable_namecolumn" /> |
|
</xsl:call-template> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<Attribute name="{$name_trans}" keyColumn="apnr" nameColumn="druck" caption="{@name}" orderByColumn="apnr"> |
|
<xsl:choose> |
|
<xsl:when test="$hasAll = 'true'"> |
|
<xsl:attribute name="hierarchyAllMemberName">Alle</xsl:attribute> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:attribute name="hierarchyHasAll">false</xsl:attribute> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</Attribute> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</Attributes> |
|
<xsl:if test="$srctable != ''"> |
|
<Hierarchies> |
|
<Hierarchy name="{@name}" allMemberName="Alle"> |
|
<xsl:call-template name="getLevels"> |
|
<xsl:with-param name="srctable" select="$srctable" /> |
|
<xsl:with-param name="name_trans" select="$name_trans" /> |
|
<xsl:with-param name="srctable_pk" select="@srctable_pk" /> |
|
<xsl:with-param name="srctable_type" select="@srctable_type" /> |
|
<xsl:with-param name="srctable_namecolumn" select="@srctable_namecolumn" /> |
|
</xsl:call-template> |
|
</Hierarchy> |
|
</Hierarchies> |
|
</xsl:if> |
|
</Dimension>--> |
|
</xsl:for-each> |
|
<Cube name="{concat('cube_',/ergebnisse/ergebnis/ergebniselement/sqlerg/row[@no='0']/col[f_name='fact_table_name']/wert)}" |
|
caption="{/ergebnisse/ergebnis/ergebniselement/sqlerg/row[@no='0']/col[f_name='fact_table_caption']/wert}"> |
|
<Dimensions> |
|
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement/sqlerg/row[col[f_name='is_fact_table_aggr_field' and wert='0']]"> |
|
|
|
<Dimension source="{concat('dim_',col[f_name='fact_table_field_name']/wert)}"/> |
|
</xsl:for-each> |
|
</Dimensions> |
|
<MeasureGroups> |
|
<MeasureGroup table="{/ergebnisse/ergebnis/ergebniselement/sqlerg/row[@no='0']/col[f_name='fact_table_name']/wert}" |
|
name="{concat('measuregroup_',/ergebnisse/ergebnis/ergebniselement/sqlerg/row[@no='0']/col[f_name='fact_table_name']/wert)}"> |
|
<Measures> |
|
<Measure name="{concat('measure_',/ergebnisse/ergebnis/ergebniselement/sqlerg/row/col[f_name='is_fact_table_aggr_field' and wert='1']/../col[f_name='fact_table_field_name']/wert)}" |
|
caption="{/ergebnisse/ergebnis/ergebniselement/sqlerg/row/col[f_name='is_fact_table_aggr_field' and wert='1']/../col[f_name='fact_table_field_caption']/wert}" |
|
column="{/ergebnisse/ergebnis/ergebniselement/sqlerg/row/col[f_name='is_fact_table_aggr_field' and wert='1']/../col[f_name='fact_table_field_name']/wert}" |
|
aggregator="sum" formatString="#,###"/> |
|
</Measures> |
|
<DimensionLinks> |
|
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement/sqlerg/row[col[f_name='is_fact_table_aggr_field']/wert='0' and col[f_name='foreignkey_tab']/wert !='']"> |
|
|
|
<ForeignKeyLink dimension="{concat('dim_',col[f_name='fact_table_field_name']/wert)}" |
|
foreignKeyColumn="{col[f_name='fact_table_field_name']/wert}"/> |
|
</xsl:for-each> |
|
</DimensionLinks> |
|
</MeasureGroup> |
|
</MeasureGroups> |
|
</Cube> |
|
|
|
<xsl:for-each select="module/olap-system/cubes/cube"> |
|
<Cube name="{calculation/query-head/@fact-table}" caption="{name}"> |
|
<Dimensions> |
|
<xsl:for-each select="dimensions/dimension"> |
|
<Dimension source="{@blueprint}" /> |
|
</xsl:for-each> |
|
</Dimensions> |
|
<MeasureGroups> |
|
<MeasureGroup table="{calculation/query-head/@fact-table}"> |
|
<Measures> |
|
<xsl:choose> |
|
<xsl:when test="measures"> |
|
<xsl:for-each select="measures/measure"> |
|
<Measure> |
|
<xsl:copy-of select="@*" /> |
|
<xsl:if test=". != ''"> |
|
<MeasureExpression> |
|
<SQL> |
|
<xsl:value-of select="." /> |
|
</SQL> |
|
</MeasureExpression> |
|
</xsl:if> |
|
</Measure> |
|
</xsl:for-each> |
|
|
|
</xsl:when> |
|
<xsl:otherwise> |
|
<Measure name="Anzahl" column="summe" aggregator="sum" formatString="#,###" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</Measures> |
|
<DimensionLinks> |
|
<xsl:for-each select="dimensions/dimension"> |
|
<xsl:variable name="name" |
|
select="/module/olap-system/dimension-blueprints/dimension-blueprint[@system_key=current()/@blueprint]/@name"/> |
|
<ForeignKeyLink dimension="{@blueprint}" foreignKeyColumn="{@name}" /> |
|
</xsl:for-each> |
|
</DimensionLinks> |
|
</MeasureGroup> |
|
</MeasureGroups> |
|
</Cube> |
|
</xsl:for-each> |
|
|
|
</Schema> |
|
</xsl:template> |
|
|
|
<xsl:template name="getAttributes"> |
|
<!--Wrapper für spezielle Dimensionstabellen oder Views --> |
|
<xsl:param name="srctable" /> |
|
<xsl:param name="name_trans" /> |
|
<xsl:param name="srctable_pk" /> |
|
<xsl:param name="srctable_type" /> |
|
<xsl:param name="srctable_namecolumn" /> |
|
<!--alle Spalten außer dem Primärschlüssel sind Levels, wobei srctable_namecolumn die Namensspalte für den Primärschlüssel ist--> |
|
<!--bei Views brauchen wir andere XPATH-Selektion als bei table-Elementen:--> |
|
<xsl:choose> |
|
<xsl:when test="$srctable_type='view'"> |
|
<xsl:for-each select="/module/database/views/view [@name=$srctable]/columns/column[@name != $srctable_pk ]"> |
|
<!--der Hierarchiehöchste Level muss im Mondrian-Schema am Anfang stehen, |
|
Konvention in BI ist aber, daß die höheren Levels ganz hinten stehen. |
|
Daher sort order="descending" --> |
|
<xsl:sort select="position()" data-type="number" order="descending"/> |
|
<xsl:call-template name="getAttributeElement"> |
|
<xsl:with-param name="srctable" select="$srctable"/> |
|
<xsl:with-param name="name_trans" select="$name_trans"/> |
|
<xsl:with-param name="srctable_pk" select="$srctable_pk" /> |
|
<xsl:with-param name="srctable_namecolumn" select="$srctable_namecolumn" /> |
|
</xsl:call-template> |
|
</xsl:for-each> |
|
<!-- falls die Dimension im Kernmodul definiert ist:--> |
|
<xsl:for-each select="document('../install/conf/kern.xml')//module/database/views/view [@name=$srctable]/columns/column[@name != $srctable_pk ] "> |
|
<xsl:sort select="position()" data-type="number" order="descending"/> |
|
<xsl:call-template name="getAttributeElement"> |
|
<xsl:with-param name="srctable" select="$srctable"/> |
|
<xsl:with-param name="name_trans" select="$name_trans"/> |
|
<xsl:with-param name="srctable_pk" select="$srctable_pk" /> |
|
<xsl:with-param name="srctable_namecolumn" select="$srctable_namecolumn" /> |
|
</xsl:call-template> |
|
</xsl:for-each> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:for-each select="/module/database/table [@name=$srctable]/columns/column[@name != $srctable_pk ]"> |
|
<!--der Hierarchiehöchste Level muss im Mondrian-Schema am Anfang stehen, |
|
Konvention in BI ist aber, daß die höheren Levels ganz hinten stehen. |
|
Daher sort order="descending" --> |
|
<xsl:sort select="position()" data-type="number" order="descending"/> |
|
<xsl:call-template name="getAttributeElement"> |
|
<xsl:with-param name="srctable" select="$srctable"/> |
|
<xsl:with-param name="name_trans" select="$name_trans"/> |
|
<xsl:with-param name="srctable_pk" select="$srctable_pk" /> |
|
<xsl:with-param name="srctable_namecolumn" select="$srctable_namecolumn" /> |
|
</xsl:call-template> |
|
</xsl:for-each> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:template> |
|
|
|
<xsl:template name="getAttributeElement"> |
|
<!--erzeugt Level-Elemente für Spalten ind speziellen Dimensionstabellen/Views --> |
|
<xsl:param name="srctable" /> |
|
<xsl:param name="name_trans" /> |
|
<xsl:param name="srctable_pk" /> |
|
<xsl:param name="srctable_namecolumn" /> |
|
<xsl:choose> |
|
<xsl:when test="@currentlyUsed='false'"> |
|
<!-- Spalte ausblenden --> |
|
</xsl:when> |
|
<xsl:when test="@name=$srctable_namecolumn"> |
|
<Attribute caption="{@description}" name="{$name_trans}" nameColumn="{@name}" keyColumn="{$srctable_pk}" hasHierarchy="false" orderByColumn="{$srctable_pk}" /> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<Attribute caption="{@description}" name="{$srctable}_{@name}" keyColumn="{@name}" hasHierarchy="false" orderByColumn="{@name}" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:template> |
|
|
|
<xsl:template name="getLevels"> |
|
<xsl:param name="srctable" /> |
|
<xsl:param name="name_trans" /> |
|
<xsl:param name="srctable_pk" /> |
|
<xsl:param name="srctable_type" /> |
|
<xsl:param name="srctable_namecolumn" /> |
|
<xsl:choose> |
|
<xsl:when test="$srctable_type='view'"> |
|
<xsl:for-each select="/module/database/views/view [@name=$srctable]/columns/column[@name != $srctable_pk ]"> |
|
<!--der Hierarchiehöchste Level muss im Mondrian-Schema am Anfang stehen, |
|
Konvention in BI ist aber, daß die höheren Levels ganz hinten stehen. |
|
Daher sort order="descending" --> |
|
<xsl:sort select="position()" data-type="number" order="descending"/> |
|
<xsl:call-template name="getLevelElement"> |
|
<xsl:with-param name="srctable" select="$srctable"/> |
|
<xsl:with-param name="name_trans" select="$name_trans"/> |
|
<xsl:with-param name="srctable_namecolumn" select="$srctable_namecolumn" /> |
|
</xsl:call-template> |
|
</xsl:for-each> |
|
<!-- falls die Dimension im Kernmodul definiert ist:--> |
|
<xsl:for-each select="document('../install/conf/kern.xml')//module/database/views/view [@name=$srctable]/columns/column[@name != $srctable_pk ] "> |
|
<xsl:sort select="position()" data-type="number" order="descending"/> |
|
<xsl:call-template name="getLevelElement"> |
|
<xsl:with-param name="srctable" select="$srctable"/> |
|
<xsl:with-param name="name_trans" select="$name_trans"/> |
|
<xsl:with-param name="srctable_namecolumn" select="$srctable_namecolumn" /> |
|
</xsl:call-template> |
|
</xsl:for-each> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:for-each select="/module/database/table [@name=$srctable]/columns/column[@name != $srctable_pk ]"> |
|
<!--der Hierarchiehöchste Level muss im Mondrian-Schema am Anfang stehen, |
|
Konvention in BI ist aber, daß die höheren Levels ganz hinten stehen. |
|
Daher sort order="descending" --> |
|
<xsl:sort select="position()" data-type="number" order="descending"/> |
|
<xsl:call-template name="getLevelElement"> |
|
<xsl:with-param name="srctable" select="$srctable"/> |
|
<xsl:with-param name="name_trans" select="$name_trans"/> |
|
<xsl:with-param name="srctable_namecolumn" select="$srctable_namecolumn" /> |
|
</xsl:call-template> |
|
</xsl:for-each> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:template> |
|
|
|
<xsl:template name="getLevelElement"> |
|
<xsl:param name="srctable" /> |
|
<xsl:param name="name_trans" /> |
|
<xsl:param name="srctable_namecolumn" /> |
|
<xsl:choose> |
|
<xsl:when test="@currentlyUsed='false'"> |
|
<!-- Spalte ausblenden --> |
|
</xsl:when> |
|
<xsl:when test="@name=$srctable_namecolumn"> |
|
<Level caption="{@description}" attribute="{$name_trans}" /> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<Level caption="{@description}" attribute="{$srctable}_{@name}" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:template> |
|
<xsl:template name="getPhysicalSchema"> |
|
<xsl:choose> |
|
<xsl:when test="col[f_name='foreignkey_cond']/wert =''"> |
|
<Table name="{col[f_name='foreignkey_tab']/wert}" alias= "{col[f_name='foreignkey_tab']/wert}" keyColumn="{col[f_name='foreignkey_pk_col']/wert}"/> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<Query alias="{concat('view_',col[f_name='fact_table_field_name']/wert)}"> |
|
<ExpressionView> |
|
<SQL dialect="generic"> |
|
<xsl:text>SELECT </xsl:text><xsl:value-of select="col[f_name='foreignkey_pk_col']/wert"/><xsl:text>,</xsl:text> |
|
<xsl:value-of select="col[f_name='foreignkey_name_col']/wert"/><xsl:text> |
|
FROM </xsl:text> <xsl:value-of select="col[f_name='foreignkey_tab']/wert"/><xsl:text> |
|
WHERE </xsl:text> <xsl:value-of select="col[f_name='foreignkey_cond']/wert"/></SQL> |
|
</ExpressionView> |
|
</Query> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
|
|
<!--[f_name='foreignkey_tab' and wert=$foreignkey_tab] |
|
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement/sqlerg/row/col"> |
|
|
|
|
|
</xsl:for-each> |
|
--> |
|
</xsl:template> |
|
</xsl:stylesheet>
|
|
|