Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 4c31a68

Browse files
reyostallenbergniels-nijens
authored andcommitted
Add field-defined functionality for id column (#44)
1 parent a74e85e commit 4c31a68

1 file changed

Lines changed: 30 additions & 18 deletions

File tree

Resources/xsl/doctrine-mapping.xsl

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,41 @@
2929
<xsl:template match='object'>
3030
<xsl:element name='entity' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
3131
<xsl:attribute name='name'><xsl:value-of select='$objectNamespace'/><xsl:value-of select='@name'/></xsl:attribute>
32-
<xsl:element name='id' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
33-
<xsl:attribute name='name'>id</xsl:attribute>
34-
<xsl:attribute name='type'>integer</xsl:attribute>
35-
36-
<xsl:element name='generator' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
37-
<xsl:attribute name='strategy'>AUTO</xsl:attribute>
38-
</xsl:element>
39-
<xsl:element name='sequence-generator' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
40-
<xsl:attribute name='sequence-name'>
41-
<xsl:call-template name='lower-case'>
42-
<xsl:with-param name='value' select='@name'/>
43-
</xsl:call-template>
44-
<xsl:text>_seq</xsl:text>
45-
</xsl:attribute>
46-
<xsl:attribute name='allocation-size'>100</xsl:attribute>
47-
<xsl:attribute name='initial-value'>1</xsl:attribute>
48-
</xsl:element>
49-
</xsl:element>
32+
<xsl:apply-templates select='self::node()' mode='entityIdentifier'/>
5033
<xsl:apply-templates select='fields/field'/>
5134
<xsl:apply-templates select='fields/field' mode='fieldEntityReference'/>
5235
</xsl:element>
5336
</xsl:template>
5437

38+
<!--
39+
Add an id field to an entity.
40+
-->
41+
<xsl:template match='object' mode='entityIdentifier'>
42+
<xsl:element name='id' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
43+
<xsl:attribute name='name'>id</xsl:attribute>
44+
<xsl:attribute name='type'>integer</xsl:attribute>
45+
46+
<xsl:element name='generator' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
47+
<xsl:attribute name='strategy'>AUTO</xsl:attribute>
48+
</xsl:element>
49+
<xsl:element name='sequence-generator' namespace='http://doctrine-project.org/schemas/orm/doctrine-mapping'>
50+
<xsl:attribute name='sequence-name'>
51+
<xsl:call-template name='lower-case'>
52+
<xsl:with-param name='value' select='@name'/>
53+
</xsl:call-template>
54+
<xsl:text>_seq</xsl:text>
55+
</xsl:attribute>
56+
<xsl:attribute name='allocation-size'>100</xsl:attribute>
57+
<xsl:attribute name='initial-value'>1</xsl:attribute>
58+
</xsl:element>
59+
</xsl:element>
60+
</xsl:template>
61+
62+
<!--
63+
Don't add an id field to an entity when an id field is defined in a orm/field-defined.
64+
-->
65+
<xsl:template match='object[orm/field-defined[@name = "id"]]' mode='entityIdentifier'/>
66+
5567
<!--
5668
Add a field mapping to an entity.
5769
-->

0 commit comments

Comments
 (0)