Mercurial > pub > ModelGenerator
annotate xslt/csharp.xsl @ 4:d240adc2ac70
sync
author | cin |
---|---|
date | Thu, 01 Mar 2018 16:53:23 +0300 |
parents | cbdada054b4a |
children |
rev | line source |
---|---|
0
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
1 <?xml version="1.0" encoding="UTF-8"?> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
2 <xsl:stylesheet version="1.0" |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
4 xmlns:cs="http://implab.org/schemas/code-dom/csharp.v1.xsd"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
5 <xsl:import href="text-tools.xsl" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
6 |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
7 <!-- CODE GENERATION --> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
8 |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
9 <!-- GENERATE NAMESPACE --> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
10 <xsl:template match="cs:namespace"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
11 <xsl:param name="level" select="0" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
12 <xsl:call-template name="write-line"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
13 <xsl:with-param name="level" select="$level" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
14 <xsl:with-param name="text"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
15 <xsl:text>namespace </xsl:text> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
16 <xsl:value-of select="@name" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
17 <xsl:text> {</xsl:text> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
18 </xsl:with-param> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
19 </xsl:call-template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
20 <xsl:apply-templates> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
21 <xsl:with-param name="level" select="$level+1" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
22 </xsl:apply-templates> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
23 <xsl:call-template name="write-line"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
24 <xsl:with-param name="level" select="$level" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
25 <xsl:with-param name="text"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
26 } |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
27 </xsl:with-param> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
28 </xsl:call-template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
29 </xsl:template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
30 |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
31 <!-- GENERATE CLASS --> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
32 <xsl:template match="cs:class"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
33 <xsl:param name="level" select="0" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
34 <xsl:call-template name="write-line"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
35 <xsl:with-param name="level" select="$level" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
36 <xsl:with-param name="text"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
37 <xsl:text>class </xsl:text> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
38 <xsl:value-of select="@name" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
39 <xsl:text> {</xsl:text> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
40 </xsl:with-param> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
41 </xsl:call-template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
42 |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
43 <xsl:apply-templates mode="members"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
44 <xsl:with-param name="level" select="$level+1" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
45 <xsl:with-param name="declaringType" select="." /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
46 </xsl:apply-templates> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
47 |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
48 <xsl:call-template name="write-line"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
49 <xsl:with-param name="level" select="$level" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
50 <xsl:with-param name="text" select="'}'" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
51 </xsl:call-template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
52 </xsl:template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
53 |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
54 <!-- GENERATE FIELDS --> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
55 <xsl:template match="cs:field" mode="members"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
56 <xsl:param name="level" select="0" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
57 <xsl:call-template name="write-line"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
58 <xsl:with-param name="level" select="$level" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
59 <xsl:with-param name="text"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
60 <xsl:value-of select="concat(@type,' ', @name)" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
61 <xsl:if test="@initializer"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
62 <xsl:text> = </xsl:text> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
63 <xsl:value-of select="@initializer" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
64 </xsl:if> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
65 <xsl:text>;</xsl:text> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
66 </xsl:with-param> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
67 </xsl:call-template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
68 </xsl:template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
69 |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
70 <!-- GENERATE PROPERTIES --> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
71 <xsl:template match="cs:property" mode="members"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
72 <xsl:param name="level" select="0" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
73 <xsl:call-template name="write-line"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
74 <xsl:with-param name="level" select="$level" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
75 <xsl:with-param name="text" select="concat(@type,' ', @name, ' {')" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
76 </xsl:call-template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
77 <xsl:apply-templates> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
78 <xsl:with-param name="level" select="$level + 1" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
79 </xsl:apply-templates> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
80 <xsl:call-template name="write-line"> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
81 <xsl:with-param name="level" select="$level" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
82 <xsl:with-param name="text" select="'}'" /> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
83 </xsl:call-template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
84 </xsl:template> |
cbdada054b4a
Basic schemas for generating csharp internal dom from model definition
cin
parents:
diff
changeset
|
85 </xsl:stylesheet> |