Ambrosia

 view release on metacpan or  search on metacpan

share/Templates/db2xml.xsl  view on Meta::CPAN

<?xml version="1.0" encoding="utf-8"?>
 
<xsl:stylesheet version="1.0" 
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns="app://Ambrosia/EntityDataModel/2011/V1"
		>

<xsl:output method="xml" indent="yes" encoding="utf-8" />
<xsl:include href="incName.xsl" />
<xsl:include href="incTypes.xsl" />

<xsl:template match="*">
	<Application Language="en-us" Authorization="YES">
		<xsl:attribute name="Name">
			<xsl:value-of select="name()" /><!-- name of root element. (config->ID) -->
		</xsl:attribute>
		<xsl:attribute name="Label">
			<xsl:value-of select="//repository/config/@label" /><!-- config->Label -->
		</xsl:attribute>
		<xsl:attribute name="Charset">
			<xsl:value-of select="//repository/config/@charset" /><!-- config->Charset -->
		</xsl:attribute>

		<Config>
			<CommonGatewayInterface Engine="ApacheRequest">
				<Params
					Pragma        = "no-cache"
					Cache_Control = "no-cache, must-revalidate, no-store"
				/>
			</CommonGatewayInterface>

			<Host Debug="YES">
				<xsl:attribute name="Name">
					<xsl:value-of select="concat(name(), '.deploy')" />
				</xsl:attribute>
				<xsl:attribute name="ServerName">
					<xsl:value-of select="//repository/config/@ServerName" />
				</xsl:attribute>
				<xsl:attribute name="ServerPort">
					<xsl:value-of select="//repository/config/@ServerPort" />
				</xsl:attribute>
				<xsl:attribute name="PerlLibPath">
					<xsl:value-of select="//repository/config/@PerlLibPath" />
				</xsl:attribute>
				<xsl:attribute name="ProjectPath">
					<xsl:value-of select="//repository/config/@ProjectPath" />
				</xsl:attribute>
			</Host>
			<xsl:comment>you can add anofer host for test, production, etc.</xsl:comment>
		</Config>

		<DataSource>
			<xsl:apply-templates select="//repository/schema_list" mode="DataSource" />
		</DataSource>

		<Entitys>
			<xsl:apply-templates select="//repository/schema_list/tables" mode="entity" />
		</Entitys>


		<Relations>
			<xsl:apply-templates select="//repository/schema_list/tables[boolean(has_one)]" mode="relation" />
		</Relations>

		<MenuGroups>
			<Group Name="" Title="">
				<xsl:attribute name="Name">
					<xsl:value-of select="name()" /><!-- name of root element. (config->ID) -->
				</xsl:attribute>
				<xsl:attribute name="Title">
					<xsl:value-of select="//repository/config/@label" /><!-- config->Label -->
				</xsl:attribute>
				<xsl:apply-templates select="//repository/schema_list/tables" mode="menugroups" />
			</Group>
		</MenuGroups>
	</Application>
</xsl:template>

<!-- Create DataSource's list -->
<xsl:template match="//repository/schema_list" mode="DataSource">
	<Type>
		<xsl:attribute name="Name">
			<xsl:value-of select="@type" />
		</xsl:attribute>
		<Source>
			<xsl:attribute name="Name">
				<xsl:value-of select="config/@db_source" />
			</xsl:attribute>



( run in 2.009 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )