annotate readme.md @ 12:191b81b2052b

first version of the xslt transform from xml to json
author cin
date Mon, 09 Apr 2018 06:43:46 +0300
parents d3542662cf70
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
1
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
2 # SINOPSYS
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
3
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
4 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
5 <package
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
6 xmlns="http://implab.org/schemas/data-model.v1.xsd"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
7 name="simple-model"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
8 >
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
9 <!-- import predefined types -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
10 <import href="types.xml"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
11
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
12 <!-- define entity -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
13 <entity name="Order">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
14 <!-- define primary key -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
15 <primaryKey name="Id" type="uuid"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
16
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
17 <!-- define simple property -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
18 <property name="OrderDate" type="dateTime"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
19
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
20 <!-- define hasA relation -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
21 <hasA name="Item" type="Item">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
22 <!-- specified a property which holds reference -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
23 <thisKey name="ItemId"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
24 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
25
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
26 <!-- define hasMany relation -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
27 <hasMany name="Comments" type="OrderComment">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
28 <otherKey name="Order"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
29 </hasMany>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
30 </entity>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
31
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
32 <entity name="Item">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
33 <primaryKey name="Id" type="uuid"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
34
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
35 <property name="Title" type="string" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
36
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
37 </entity>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
38
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
39 <entity name="OrderComment">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
40 <primaryKey name="Id" type="uuid" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
41
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
42 <property name="Comment" type="text" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
43
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
44 <property name="Date" type="dateTime" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
45
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
46 <hasA name="Order" type="Order">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
47 <thisKey name="OrderId" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
48 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
49 </entity>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
50 </package>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
51 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
52
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
53 # DESCRIPTION
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
54
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
55 Описание модели включает в себя описание наборов сущностей, каждый набор
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
56 называется пакетом.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
57
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
58 В пакете содержатся описания сущностей, а также объявления внешних типов,
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
59 которые используются при описании сущностей.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
60
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
61 Для уменьшения количества дублируемого кода, а также для упрощения читаемости
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
62 и упрощения сопровождения существует возможность импортирования уже объявленных
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
63 пакетов. В процессе сборки происходит предварительная обработка, которая
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
64 использует все директивы `import` для составления общего модуля, состоящего
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
65 из нескольких пакетов, при этом пакет с которого был начат процесс сборки
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
66 называется первичным и после окончания предварительной обработки для него будет
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
67 выполнена сборка.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
68
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
69 Каждая сущность модели состоит из нескольких типов членов, это
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
70 * Свойства - используются для хранения состояния сущности, аналогичны столбцам в таблице
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
71 * Ключи - информация для идентификации записей, каждая запись должна иметь по крайней мере первичный ключ.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
72 * Отношения - информация о связях между сущностями
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
73
9
d3542662cf70 working on members preprocessing
cin
parents: 2
diff changeset
74 Ключи рассматриваются являются специальным видом отношений, оны выделены отдельно
d3542662cf70 working on members preprocessing
cin
parents: 2
diff changeset
75 поскольку в генераторе моделей для них предусмотрены специальные механизмы, используемые
d3542662cf70 working on members preprocessing
cin
parents: 2
diff changeset
76 при реализации отношений.
d3542662cf70 working on members preprocessing
cin
parents: 2
diff changeset
77
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
78 ## Properties
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
79
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
80 ## PrimaryKey
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
81
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
82 Внешний ключ представляет собой набор уникальных данных, позволяющий однозначно
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
83 идентифицировать запись, при этом внешний ключ может состоять как из одного
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
84 поля (простые), так и из нескольких (составные)
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
85
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
86 Простые первичные ключи
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
87
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
88 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
89 <primaryKey name="Id" type="uuid"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
90 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
91
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
92 Составные первичные ключи
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
93
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
94 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
95 <primaryKey name="Id">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
96 <member name="Owner"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
97 <member name="SeqNum"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
98 </primaryKey>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
99 <property name="SeqNum" type="integer"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
100 <hasA name="Owner" type="User">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
101 <thisKey name="UserId" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
102 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
103 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
104 При описании составных ключей перечисляется набор членов сущности, которые
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
105 будут образовывать уникальный набор данных для первичного ключа, следует
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
106 отметить, что не все отношения храняться в самой сущности, например,
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
107 `hasMany` может хранится не в записях самой сущности, а в записях связанной
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
108 сущности, такие отношения нельзя включать в первичный ключ.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
109 Отношение `hasA`, напротив, как парвило хранится в свойствах самой сущности
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
110 и включение его в первичный ключ означает автоматическое включение всех
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
111 свойств.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
112
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
113 ## Relations
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
114
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
115 ### hasA
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
116
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
117 `hasA` это отношение, при котором текущей сущности может
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
118 соответсвовать одна связанная сущность. При реализации
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
119 данного отношение может быть указано свойство, используемое
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
120 для хранения ссылки при помощи дочернего элемента `thisKey`
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
121
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
122 `thisKey` указывает способ реализации отношения, при котором
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
123 в текущей сущности хранится информация для осуществления связи.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
124
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
125 По-умолчанию для связи используются первичные ключи, что
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
126 позволяет автоматически определять набор и типы необходимых
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
127 свойств для хранения ссылки.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
128
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
129 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
130 <hasA name="Order" type="Order" optional="true">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
131 <thisKey name="OrderId" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
132 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
133 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
134
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
135 В случях когда первичный ключ является сложным можно указать
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
136 префикс или явно перечислить свойства в которых будет хранится
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
137 связь
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
138
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
139 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
140 <property name="UserId" type="uuid"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
141 <property name="MemberNo" type="integer"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
142 <hasA name="Membership" type="Membership">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
143 <thisKey>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
144 <member name="UserId"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
145 <member name="MemberNo"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
146 </thisKey>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
147 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
148 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
149
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
150 ### hasMany
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
151
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
152 Отношение при котором с текущей записью связано произвольное
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
153 количество записей другой сущности.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
154
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
155 Как правило это отношение является комплиментарным к `hasA` с другой стороны.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
156
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
157 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
158 <hasMany name="Roles" type="Role">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
159 <otherKey name="User"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
160 </hasMany>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
161 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
162
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
163 `otherKey` указывает имя члена в связанной сущности, который хранит информацию
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
164 о связи, это может быть оношение, свойство или ключ.