3 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
4 xmlns:opensrf="http://opensrf.org/xmlns/opensrf"
5 xmlns:cdbi="http://opensrf.org/xmlns/opensrf/cdbi"
6 xmlns:database="http://opensrf.org/xmlns/opensrf/database"
7 xmlns:perl="http://opensrf.org/xmlns/opensrf/perl"
8 xmlns:javascript="http://opensrf.org/xmlns/opensrf/javascript"
9 xmlns:c="http://opensrf.org/xmlns/opensrf/c">
10 <xsl:output method="text" />
11 <xsl:strip-space elements="*"/>
13 <xsl:template match="/">
14 <xsl:apply-templates select="opensrf:fieldmapper/opensrf:classes"/>
19 <!-- sub-templates -->
20 <xsl:template match="opensrf:classes">
21 <xsl:for-each select="opensrf:class">
22 <xsl:sort select="@id"/>
23 <xsl:apply-templates select="."/>
25 <xsl:apply-templates select="opensrf:class/opensrf:links/opensrf:link[@type='has_a']"/>
26 <xsl:apply-templates select="opensrf:class/opensrf:links/opensrf:link[@type='has_many']"/>
31 <xsl:template match="opensrf:class">
32 #-------------------------------------------------------------------------------
33 # <xsl:value-of select="$driver"/> Class definition for "<xsl:value-of select="@id"/>" (<xsl:value-of select="cdbi:class"/>)
34 #-------------------------------------------------------------------------------
35 package <xsl:value-of select="@cdbi:class"/>;
36 use base '<xsl:value-of select="cdbi:superclass"/>';
38 __PACKAGE__->table("<xsl:value-of select="database:table[@rdbms=$driver]/database:name"/>");
39 <xsl:if test="database:table[@rdbms=$driver]/database:sequence">
40 __PACKCAGE__->sequence("<xsl:value-of select="database:table[@rdbms=$driver]/database:sequence"/>");
43 __PACKAGE__->columns(Primary => <xsl:apply-templates select="opensrf:fields/opensrf:field[@database:primary='true']"/>);
44 <xsl:if test="opensrf:fields/opensrf:field[@database:required='true' and not(@database:primary='true')]">
46 Essential => <xsl:apply-templates
47 select="opensrf:fields/opensrf:field[@database:required='true' and not(@database:primary='true')]"/>
50 <xsl:if test="opensrf:fields/opensrf:field[not(@database:required='true') and not(@database:primary='true')]">
52 Others => <xsl:apply-templates
53 select="opensrf:fields/opensrf:field[not(@database:required='true') and not(@database:primary='true')]"/>
60 <xsl:template match="database:table">
65 <xsl:template match="opensrf:field">
66 '<xsl:value-of select='@name'/>',
71 <xsl:template match="opensrf:link">
72 <xsl:variable name='source' select='@source'/>
73 <xsl:value-of select="../../@cdbi:class"/>-><xsl:value-of select="@type"/>(
74 <xsl:value-of select="@field"/> => '<xsl:value-of select="//*[@id=$source]/@cdbi:class"/>'